diff --git a/.bashrc b/.bashrc index ec2e5ed..d19d15a 100644 --- a/.bashrc +++ b/.bashrc @@ -1,163 +1,73 @@ -# Enable the subsequent settings only in interactive sessions -case $- in - *i*) ;; - *) return;; -esac +# .bashrc -# Path to your oh-my-bash installation. -export OSH=~/.oh-my-bash -source ~/.local/bin/bashmarks.sh -# Set name of the theme to load. Optionally, if you set this to "random" -# it'll load a random theme each time that oh-my-bash is loaded. -OSH_THEME="bakke" +# Source global definitions +if [ -f /etc/bashrc ]; then + . /etc/bashrc +fi -# If you set OSH_THEME to "random", you can ignore themes you don't like. -# OMB_THEME_RANDOM_IGNORED=("powerbash10k" "wanelo") +# User specific environment +if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]; then + PATH="$HOME/.local/bin:$HOME/bin:$PATH" +fi +export PATH -# Uncomment the following line to use case-sensitive completion. -# OMB_CASE_SENSITIVE="true" +# Uncomment the following line if you don't like systemctl's auto-paging feature: +# export SYSTEMD_PAGER= -# Uncomment the following line to use hyphen-insensitive completion. Case -# sensitive completion must be off. _ and - will be interchangeable. -# OMB_HYPHEN_SENSITIVE="false" +# User specific aliases and functions +if [ -d ~/.bashrc.d ]; then + for rc in ~/.bashrc.d/*; do + if [ -f "$rc" ]; then + . "$rc" + fi + done +fi +unset rc -# Uncomment the following line to disable bi-weekly auto-update checks. -# DISABLE_AUTO_UPDATE="true" +# My script -# Uncomment the following line to change how often to auto-update (in days). -# export UPDATE_OSH_DAYS=13 +lori() { + local lori_name="${1}" + declare -A lori_list + lori_list=( + [dist_list]="df -h" + ) -# Uncomment the following line to disable colors in ls. -# DISABLE_LS_COLORS="true" + if [[ -z ${lori_list[$lori_name]} || -z "$lori_name" || "$lori_name" == "-h" ]]; then + echo "COMMANDS:" + printf "%-20s %s\n" "keys" "command" + echo "=============================" + for key in "${!lori_list[@]}"; do + printf "%-20s %s\n" "$key" "${lori_list[$key]}" + done | sort + return 0 + else + if [[ -n "$BASH" && -t 0 ]]; then -# Uncomment the following line to disable auto-setting terminal title. -# DISABLE_AUTO_TITLE="true" + local command_to_insert="${lori_list[$lori_name]}" + bind '"\e[0n": "'"${command_to_insert}"'"' + printf '\e[5n' + else + echo "${lori_list[$lori_name]}" + fi + return 0 + fi +} -# Uncomment the following line to enable command auto-correction. -# ENABLE_CORRECTION="true" +_lori_completion() { + local curl prev opts + COMPREPLY=() + curl="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts=$(lori -h | awk 'NR>4 {print $1}') + if [[ ${curl} == * ]]; then + COMPREPLY=($(compgen -W "${opts}" -- ${curl})) + return 0 + fi +} -# Uncomment the following line to display red dots whilst waiting for completion. -# COMPLETION_WAITING_DOTS="true" - -# Uncomment the following line if you want to disable marking untracked files -# under VCS as dirty. This makes repository status check for large repositories -# much, much faster. -# DISABLE_UNTRACKED_FILES_DIRTY="true" - -# Uncomment the following line if you don't want the repository to be considered dirty -# if there are untracked files. -# SCM_GIT_DISABLE_UNTRACKED_DIRTY="true" - -# Uncomment the following line if you want to completely ignore the presence -# of untracked files in the repository. -# SCM_GIT_IGNORE_UNTRACKED="true" - -# Uncomment the following line if you want to change the command execution time -# stamp shown in the history command output. One of the following values can -# be used to specify the timestamp format. -# * 'mm/dd/yyyy' # mm/dd/yyyy + time -# * 'dd.mm.yyyy' # dd.mm.yyyy + time -# * 'yyyy-mm-dd' # yyyy-mm-dd + time -# * '[mm/dd/yyyy]' # [mm/dd/yyyy] + [time] with colors -# * '[dd.mm.yyyy]' # [dd.mm.yyyy] + [time] with colors -# * '[yyyy-mm-dd]' # [yyyy-mm-dd] + [time] with colors -# If not set, the default value is 'yyyy-mm-dd'. -# HIST_STAMPS='yyyy-mm-dd' - -# Uncomment the following line if you do not want OMB to overwrite the existing -# aliases by the default OMB aliases defined in lib/*.sh -# OMB_DEFAULT_ALIASES="check" - -# Would you like to use another custom folder than $OSH/custom? -# OSH_CUSTOM=/path/to/new-custom-folder - -# To disable the uses of "sudo" by oh-my-bash, please set "false" to -# this variable. The default behavior for the empty value is "true". -OMB_USE_SUDO=true - -# To enable/disable display of Python virtualenv and condaenv -# OMB_PROMPT_SHOW_PYTHON_VENV=true # enable -# OMB_PROMPT_SHOW_PYTHON_VENV=false # disable - -# Which completions would you like to load? (completions can be found in ~/.oh-my-bash/completions/*) -# Custom completions may be added to ~/.oh-my-bash/custom/completions/ -# Example format: completions=(ssh git bundler gem pip pip3) -# Add wisely, as too many completions slow down shell startup. -completions=( - git - composer - ssh -) - -# Which aliases would you like to load? (aliases can be found in ~/.oh-my-bash/aliases/*) -# Custom aliases may be added to ~/.oh-my-bash/custom/aliases/ -# Example format: aliases=(vagrant composer git-avh) -# Add wisely, as too many aliases slow down shell startup. -aliases=( - general -) - -# Which plugins would you like to load? (plugins can be found in ~/.oh-my-bash/plugins/*) -# Custom plugins may be added to ~/.oh-my-bash/custom/plugins/ -# Example format: plugins=(rails git textmate ruby lighthouse) -# Add wisely, as too many plugins slow down shell startup. -plugins=( - git - sudo - progress - bashmarks - pyenv -) - -# Which plugins would you like to conditionally load? (plugins can be found in ~/.oh-my-bash/plugins/*) -# Custom plugins may be added to ~/.oh-my-bash/custom/plugins/ -# Example format: -# if [ "$DISPLAY" ] || [ "$SSH" ]; then -# plugins+=(tmux-autoattach) -# fi - -source "$OSH"/oh-my-bash.sh - -# User configuration -# export MANPATH="/usr/local/man:$MANPATH" - -# You may need to manually set your language environment -# export LANG=en_US.UTF-8 - -# Preferred editor for local and remote sessions -# if [[ -n $SSH_CONNECTION ]]; then -# export EDITOR='vim' -# else -# export EDITOR='mvim' -# fi - -# Compilation flags -# export ARCHFLAGS="-arch x86_64" - -# ssh -# export SSH_KEY_PATH="~/.ssh/rsa_id" - -# Set personal aliases, overriding those provided by oh-my-bash libs, -# plugins, and themes. Aliases can be placed here, though oh-my-bash -# users are encouraged to define aliases within the OSH_CUSTOM folder. -# For a full list of active aliases, run `alias`. -# -# Example aliases -# alias bashconfig="mate ~/.bashrc" -# alias ohmybash="mate ~/.oh-my-bash" -# Mount Folder ansibal gateway -#alias afup="sshfs root@ansible:/opt/ansible /home/h0lik/dev/ansible" -#alias afdown="fusermount -u /home/h0lik/dev/ansible" -#Dev folder ansibal -#alias af="cd /home/h0lik/dev/ansible" -## Start/Stop VM ansible -#alias agup="sudo virsh start ansible" -#alias agdown="sudo virsh shutdown ansible" -##Connect SSH ansible-gateway -#alias assh="ssh ansible" -#alias devsrv="ssh worksrv" -#alias grep="grep --color=auto" -#alias host-ssh="/home/h0lik/.bin/./ssh-host.sh" -if [ -f ~/.dotfiles/.bash_aliases ]; then +complete -F _lori_completion lori +# load bash alias +if [ -f ~/.dotfiles/bash_aliases ]; then . ~/.dotfiles/.bash_aliases fi diff --git a/.bashrc.bak b/.bashrc.bak new file mode 100644 index 0000000..ec2e5ed --- /dev/null +++ b/.bashrc.bak @@ -0,0 +1,163 @@ +# Enable the subsequent settings only in interactive sessions +case $- in + *i*) ;; + *) return;; +esac + +# Path to your oh-my-bash installation. +export OSH=~/.oh-my-bash +source ~/.local/bin/bashmarks.sh +# Set name of the theme to load. Optionally, if you set this to "random" +# it'll load a random theme each time that oh-my-bash is loaded. +OSH_THEME="bakke" + +# If you set OSH_THEME to "random", you can ignore themes you don't like. +# OMB_THEME_RANDOM_IGNORED=("powerbash10k" "wanelo") + +# Uncomment the following line to use case-sensitive completion. +# OMB_CASE_SENSITIVE="true" + +# Uncomment the following line to use hyphen-insensitive completion. Case +# sensitive completion must be off. _ and - will be interchangeable. +# OMB_HYPHEN_SENSITIVE="false" + +# Uncomment the following line to disable bi-weekly auto-update checks. +# DISABLE_AUTO_UPDATE="true" + +# Uncomment the following line to change how often to auto-update (in days). +# export UPDATE_OSH_DAYS=13 + +# Uncomment the following line to disable colors in ls. +# DISABLE_LS_COLORS="true" + +# Uncomment the following line to disable auto-setting terminal title. +# DISABLE_AUTO_TITLE="true" + +# Uncomment the following line to enable command auto-correction. +# ENABLE_CORRECTION="true" + +# Uncomment the following line to display red dots whilst waiting for completion. +# COMPLETION_WAITING_DOTS="true" + +# Uncomment the following line if you want to disable marking untracked files +# under VCS as dirty. This makes repository status check for large repositories +# much, much faster. +# DISABLE_UNTRACKED_FILES_DIRTY="true" + +# Uncomment the following line if you don't want the repository to be considered dirty +# if there are untracked files. +# SCM_GIT_DISABLE_UNTRACKED_DIRTY="true" + +# Uncomment the following line if you want to completely ignore the presence +# of untracked files in the repository. +# SCM_GIT_IGNORE_UNTRACKED="true" + +# Uncomment the following line if you want to change the command execution time +# stamp shown in the history command output. One of the following values can +# be used to specify the timestamp format. +# * 'mm/dd/yyyy' # mm/dd/yyyy + time +# * 'dd.mm.yyyy' # dd.mm.yyyy + time +# * 'yyyy-mm-dd' # yyyy-mm-dd + time +# * '[mm/dd/yyyy]' # [mm/dd/yyyy] + [time] with colors +# * '[dd.mm.yyyy]' # [dd.mm.yyyy] + [time] with colors +# * '[yyyy-mm-dd]' # [yyyy-mm-dd] + [time] with colors +# If not set, the default value is 'yyyy-mm-dd'. +# HIST_STAMPS='yyyy-mm-dd' + +# Uncomment the following line if you do not want OMB to overwrite the existing +# aliases by the default OMB aliases defined in lib/*.sh +# OMB_DEFAULT_ALIASES="check" + +# Would you like to use another custom folder than $OSH/custom? +# OSH_CUSTOM=/path/to/new-custom-folder + +# To disable the uses of "sudo" by oh-my-bash, please set "false" to +# this variable. The default behavior for the empty value is "true". +OMB_USE_SUDO=true + +# To enable/disable display of Python virtualenv and condaenv +# OMB_PROMPT_SHOW_PYTHON_VENV=true # enable +# OMB_PROMPT_SHOW_PYTHON_VENV=false # disable + +# Which completions would you like to load? (completions can be found in ~/.oh-my-bash/completions/*) +# Custom completions may be added to ~/.oh-my-bash/custom/completions/ +# Example format: completions=(ssh git bundler gem pip pip3) +# Add wisely, as too many completions slow down shell startup. +completions=( + git + composer + ssh +) + +# Which aliases would you like to load? (aliases can be found in ~/.oh-my-bash/aliases/*) +# Custom aliases may be added to ~/.oh-my-bash/custom/aliases/ +# Example format: aliases=(vagrant composer git-avh) +# Add wisely, as too many aliases slow down shell startup. +aliases=( + general +) + +# Which plugins would you like to load? (plugins can be found in ~/.oh-my-bash/plugins/*) +# Custom plugins may be added to ~/.oh-my-bash/custom/plugins/ +# Example format: plugins=(rails git textmate ruby lighthouse) +# Add wisely, as too many plugins slow down shell startup. +plugins=( + git + sudo + progress + bashmarks + pyenv +) + +# Which plugins would you like to conditionally load? (plugins can be found in ~/.oh-my-bash/plugins/*) +# Custom plugins may be added to ~/.oh-my-bash/custom/plugins/ +# Example format: +# if [ "$DISPLAY" ] || [ "$SSH" ]; then +# plugins+=(tmux-autoattach) +# fi + +source "$OSH"/oh-my-bash.sh + +# User configuration +# export MANPATH="/usr/local/man:$MANPATH" + +# You may need to manually set your language environment +# export LANG=en_US.UTF-8 + +# Preferred editor for local and remote sessions +# if [[ -n $SSH_CONNECTION ]]; then +# export EDITOR='vim' +# else +# export EDITOR='mvim' +# fi + +# Compilation flags +# export ARCHFLAGS="-arch x86_64" + +# ssh +# export SSH_KEY_PATH="~/.ssh/rsa_id" + +# Set personal aliases, overriding those provided by oh-my-bash libs, +# plugins, and themes. Aliases can be placed here, though oh-my-bash +# users are encouraged to define aliases within the OSH_CUSTOM folder. +# For a full list of active aliases, run `alias`. +# +# Example aliases +# alias bashconfig="mate ~/.bashrc" +# alias ohmybash="mate ~/.oh-my-bash" +# Mount Folder ansibal gateway +#alias afup="sshfs root@ansible:/opt/ansible /home/h0lik/dev/ansible" +#alias afdown="fusermount -u /home/h0lik/dev/ansible" +#Dev folder ansibal +#alias af="cd /home/h0lik/dev/ansible" +## Start/Stop VM ansible +#alias agup="sudo virsh start ansible" +#alias agdown="sudo virsh shutdown ansible" +##Connect SSH ansible-gateway +#alias assh="ssh ansible" +#alias devsrv="ssh worksrv" +#alias grep="grep --color=auto" +#alias host-ssh="/home/h0lik/.bin/./ssh-host.sh" +if [ -f ~/.dotfiles/.bash_aliases ]; then +. ~/.dotfiles/.bash_aliases +fi diff --git a/.zshrc b/.zshrc new file mode 100644 index 0000000..bc75bdc --- /dev/null +++ b/.zshrc @@ -0,0 +1,149 @@ +# If you come from bash you might have to change your $PATH. +# export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH + +# Path to your Oh My Zsh installation. +export ZSH="$HOME/.oh-my-zsh" +export PATH="$PATH:$HOME/.bin" +export ANSIBLE_CONFIG="$HOME/ansible/ansible.cfg" +export PATH="/usr/local/bin:$PATH" +export EDITOR="nvim" +export PATH=~/.local/bin:$PATH +source ~/.profile +export SRVADMIN_ENV="$HOME/.config/srvadmin-config.ini" +# Set name of the theme to load --- if set to "random", it will +# load a random theme each time Oh My Zsh is loaded, in which case, +# to know which specific one was loaded, run: echo $RANDOM_THEME +# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes +ZSH_THEME="dpoggi" + +# Set list of themes to pick from when loading at random +# Setting this variable when ZSH_THEME=random will cause zsh to load +# a theme from this variable instead of looking in $ZSH/themes/ +# If set to an empty array, this variable will have no effect. +# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) + +# Uncomment the following line to use case-sensitive completion. +# CASE_SENSITIVE="true" + +# Uncomment the following line to use hyphen-insensitive completion. +# Case-sensitive completion must be off. _ and - will be interchangeable. +# HYPHEN_INSENSITIVE="true" + +# Uncomment one of the following lines to change the auto-update behavior +# zstyle ':omz:update' mode disabled # disable automatic updates +# zstyle ':omz:update' mode auto # update automatically without asking +# zstyle ':omz:update' mode reminder # just remind me to update when it's time + +# Uncomment the following line to change how often to auto-update (in days). +# zstyle ':omz:update' frequency 13 + +# Uncomment the following line if pasting URLs and other text is messed up. +# DISABLE_MAGIC_FUNCTIONS="true" + +# Uncomment the following line to disable colors in ls. +# DISABLE_LS_COLORS="true" + +# Uncomment the following line to disable auto-setting terminal title. +# DISABLE_AUTO_TITLE="true" + +# Uncomment the following line to enable command auto-correction. +# ENABLE_CORRECTION="true" + +# Uncomment the following line to display red dots whilst waiting for completion. +# You can also set it to another string to have that shown instead of the default red dots. +# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f" +# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765) +# COMPLETION_WAITING_DOTS="true" + +# Uncomment the following line if you want to disable marking untracked files +# under VCS as dirty. This makes repository status check for large repositories +# much, much faster. +# DISABLE_UNTRACKED_FILES_DIRTY="true" + +# Uncomment the following line if you want to change the command execution time +# stamp shown in the history command output. +# You can set one of the optional three formats: +# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" +# or set a custom format using the strftime function format specifications, +# see 'man strftime' for details. +# HIST_STAMPS="mm/dd/yyyy" + +# Would you like to use another custom folder than $ZSH/custom? +# ZSH_CUSTOM=/path/to/new-custom-folder + +# Which plugins would you like to load? +# Standard plugins can be found in $ZSH/plugins/ +# Custom plugins may be added to $ZSH_CUSTOM/plugins/ +# Example format: plugins=(rails git textmate ruby lighthouse) +# Add wisely, as too many plugins slow down shell startup. +plugins=(git tmux tmuxinator sudo history) + +source $ZSH/oh-my-zsh.sh + +# User configuration + +# export MANPATH="/usr/local/man:$MANPATH" + +# You may need to manually set your language environment +# export LANG=en_US.UTF-8 + +# Preferred editor for local and remote sessions +# if [[ -n $SSH_CONNECTION ]]; then +# export EDITOR='vim' +# else +# export EDITOR='nvim' +# fi + +# Compilation flags +# export ARCHFLAGS="-arch $(uname -m)" + +# Set personal aliases, overriding those provided by Oh My Zsh libs, +# plugins, and themes. Aliases can be placed here, though Oh My Zsh +# users are encouraged to define aliases within a top-level file in +# the $ZSH_CUSTOM folder, with .zsh extension. Examples: +# - $ZSH_CUSTOM/aliases.zsh +# - $ZSH_CUSTOM/macos.zsh +# For a full list of active aliases, run `alias`. +lori() { + local lori_name="${1}" + typeset -A lori_list + + + lori_list=( + disk_size "df -h" + ) + + if [[ -z ${lori_list[$lori_name]} || -z "$lori_name" || "$lori_name" == "-h" ]]; then + echo "AVAILABLE COMMANDS:\n" + printf "%-20s %s\n" "command" + echo "----------------------" + for key in "${(@k)lori_list}"; do + printf "%-20s %s\n" "$key" "${lori_list[$key]}" + done | sort + return 0 + else + print -zr "${lori_list[$lori_name]}" + return 0 + fi +} +_lori_completion() { + local -a keys + keys=($(lori -h | awk 'NR>4 {print $1}')) + compadd "$@" -- "${keys[@]}" +} +compdef _lori_completion lori +# Example aliases +# alias zshconfig="mate ~/.zshrc" +# alias ohmyzsh="mate ~/.oh-my-zsh" +alias vim="nvim" +alias untar="tar xvf" +alias uz="unzip" +alias yz="yazi" +alias tf="terraform" +alias ap-key="cat ~/.myconfig/id_ed25519.pub" +alias tfp="tf plan" +alias tfa="tf apply" +alias tfd="tf destroy" +alias ga="git add ." +alias gc='git commit -m' +alias gp="git push" diff --git a/.bash_aliases b/alias/bash_aliases similarity index 100% rename from .bash_aliases rename to alias/bash_aliases diff --git a/alias/zsh_aliases b/alias/zsh_aliases new file mode 100644 index 0000000..59f55d4 --- /dev/null +++ b/alias/zsh_aliases @@ -0,0 +1,12 @@ +alias vim="nvim" +alias untar="tar xvf" +alias uz="unzip" +alias yz="yazi" +alias tf="terraform" +alias ap-key="cat ~/.myconfig/id_ed25519.pub" +alias tfp="tf plan" +alias tfa="tf apply" +alias tfd="tf destroy" +alias ga="git add ." +alias gc='git commit -m' +alias gp="git push"