Files
dotfiles/.zshrc

472 lines
13 KiB
Bash

#################################################################################
#
#__ __ _____ _ ____ __ _
#| \/ |_ _|__ /___| |__ / ___|___ _ __ / _(_) __ _
#| |\/| | | | | / // __| '_ \ | | / _ \| '_ \| |_| |/ _` |
#| | | | |_| |/ /_\__ \ | | || |__| (_) | | | | _| | (_| |
#|_| |_|\__, /____|___/_| |_(_)____\___/|_| |_|_| |_|\__, |
# |___/ |___/
# by @paramah
#
#################################################################################
alias egrep="grep -E"
alias fgrep="grep -F"
#Load my environment exports
[ -f ~/.exports ] && source ~/.exports
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
export PATH=$HOME/bin:/usr/local/bin:$PATH
export PATH="${PATH}:${HOME}/.local/bin/"
export PATH="${PATH}:${HOME}/.config/composer/vendor/bin"
# paramah configuration
export PATH="/usr/bin/core_perl:$PATH"
export PATH="/home/paramah/.gem/ruby/2.4.0/bin:$PATH"
export PATH="/home/paramah/.gem/ruby/2.3.0/bin:$PATH"
export PATH="/home/paramah/.gem/ruby/2.5.0/bin:$PATH"
export PATH="/home/paramah/.gem/ruby/2.7.0/bin:$PATH"
export PATH="/home/paramah/.local/bin:$PATH"
export PATH="/home/paramah/.cache/rebar3/bin":$PATH
export PATH=/home/paramah/.captain/bin:$PATH
#Home bin (last always!)
export PATH="/home/paramah/go/bin:$PATH"
export PATH="/var/lib/snapd/snap/bin:$PATH"
export PATH="/home/paramah/bin:$PATH"
#symfony
export PATH="$HOME/.symfony/bin:$PATH"
export PATH="/home/paramah/.linkerd2/bin:$PATH"
#dotnet
export DOTNET_ROOT=$HOME/.dotnet
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
#source /usr/share/zsh-theme-powerlevel9k/powerlevel9k.zsh-theme
#ZSH_THEME="powerlevel9k/powerlevel9k"
#POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status background_jobs_joined virtualenv nodeenv)
ZSH_THEME="powerlevel10k/powerlevel10k"
export CHROME_BIN=/usr/bin/chromium
source /usr/bin/virtualenvwrapper.sh
plugins=(
zsh-autosuggestions
#virtualenvwrapper
virtualenv
#taskwarrior
#timewarrior
archlinux
systemd
themes
git
fzf
aws
ssh-agent
#git-flow-completion
docker
golang
terraform
asdf
#aterminal
poetry
#fzf-tab-completion
sd
)
source ~/.zplug/init.zsh
zplug 'ytet5uy4/fzf-widgets'
zplug 'zsh-users/zaw'
zplug "pbar1/zsh-terraform"
zplug 'voronkovich/project.plugin.zsh'
#zplug romkatv/powerlevel10k, as:theme, depth:1
zplug "jocelynmallon/zshmarks"
zplug "djui/alias-tips"
zplug "zpm-zsh/clipboard"
zplug "kazhala/dotbare"
# autocomplete on steroids
zstyle ':completion:*' fzf-search-display true
zstyle ':completion::*:ls::*' fzf-completion-opts --preview='eval head {1}'
zstyle ':completion::*:cat::*' fzf-completion-opts --preview='eval head {1}'
# Map widgets to key
bindkey '^ge' fzf-select-widget
bindkey '^@.' fzf-edit-dotfiles
bindkey '^@c' fzf-change-directory
bindkey '^@n' fzf-change-named-directory
bindkey '^@f' fzf-edit-files
bindkey '^@k' fzf-kill-processes
bindkey '^gs' fzf-exec-ssh
bindkey '^/' fzf-change-recent-directory
bindkey '^r' fzf-insert-history
bindkey '^xf' fzf-insert-files
bindkey '^xd' fzf-insert-directory
bindkey '^xn' fzf-insert-named-directory
## Git
bindkey '^@g' fzf-select-git-widget
bindkey '^@ga' fzf-git-add-files
bindkey '^@gc' fzf-git-change-repository
# GitHub
bindkey '^@h' fzf-select-github-widget
bindkey '^@hs' fzf-github-show-issue
bindkey '^@hc' fzf-github-close-issue
## Docker
bindkey '^@d' fzf-select-docker-widget
bindkey '^@dc' fzf-docker-remove-containers
bindkey '^@di' fzf-docker-remove-images
bindkey '^@dv' fzf-docker-remove-volumes
zplug load
source $ZSH/oh-my-zsh.sh
# Preferred editor for local and remote sessions
if [[ -n $SSH_CONNECTION ]]; then
export EDITOR='vim'
else
export EDITOR='nvim'
fi
export DISABLE_AUTO_TITLE='true'
TMPDIR=/home/paramah/.tmp/
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
TRAPWINCH() {
zle && { zle reset-prompt; zle -R }
}
autoload bashcompinit
bashcompinit
dsh(){
docker exec -it $1 sh -c "stty cols $COLUMNS rows $LINES && sh";
}
dbash(){
docker exec -it $1 bash -c "stty cols $COLUMNS rows $LINES && bash";
}
_goinside(){
COMPREPLY=( $(docker ps --format "{{.Names}}" -f name=$2) );
}
complete -F _goinside dsh;
complete -F _goinside dbash;
export goinside;
###################################
# _ _
# __ _| (_) __ _ ___ ___ ___
# / _` | | |/ _` / __|/ _ \/ __|
# | (_| | | | (_| \__ \ __/\__ \
# (_)__,_|_|_|\__,_|___/\___||___/
#
##########################################################################################
alias egrep="grep -E"
alias fgrep="grep -F"
alias l="tmuxp load -y "
alias dc="docker-compose"
alias d="docker"
alias t="tmux"
alias b="buku --suggest"
alias j="jrnl"
alias g="git"
alias wh="curl wttr.in/Gliwice"
alias drestart="sudo systemctl restart docker"
alias dstop="sudo systemctl stop docker"
alias dstart="sudo systemctl start docker"
#alias ls="exa"
alias yaycc="yay -Sc"
alias frp="frpc -c ~/frpc.ini"
alias mleft="xrandr --output HDMI1 --rotation left"
alias mnormal="xrandr --output HDMI1 --rotation normal"
alias l="sudo systemctl restart docker && tmux kill-server"
alias crl="dbus-send --session --dest=org.Cinnamon.LookingGlass --type=method_call /org/Cinnamon/LookingGlass org.Cinnamon.LookingGlass.ReloadExtension string:'EXTENSION_UUID' string:'APPLET'"
alias easy-rsa="docker run --rm -it -v /home/paramah/myCertificateAuthority:/pki draeath/easyrsa"
# alias cat="bat"
#alias ping='~/bin/prettyping --nolegend'
alias sourcec="docker run --publish 7080:7080 --rm --volume ~/.sourcegraph/config:/etc/sourcegraph --volume ~/.sourcegraph/data:/var/opt/sourcegraph --volume /var/run/docker.sock:/var/run/docker.sock sourcegraph/server:2.11.2"
alias hadolint="docker run --rm -i hadolint/hadolint"
alias vim="nvim"
alias j="jump"
alias b="bookmark"
alias r="ranger"
alias k="kubectl"
alias paste-online="wl-paste |lenpaste-cli"
dd_telegram-desktop () { # launch telegram and send it to scratchpad
(/usr/bin/telegram-desktop &)
sleep 2
i3-msg '[class="Telegram"] move scratchpad'
}
mattermost-desktop () { # launch telegram and send it to scratchpad
(/usr/bin/mattermost-desktop &)
sleep 2
i3-msg '[class="Mattermost"] move scratchpad'
}
theme () {
wal -qi $WALLPAPER
setwallpaper $WALLPAPER
cp ~/.cache/wal/mako ~/.config/mako/config
systemctl --user restart mako
systemctl --user restart waybar
~/bin/alawal.sh
}
alias tf=terraform
alias tfw="terraform workspace"
autoload -U +X bashcompinit && bashcompinit
complete -o nospace -C /usr/bin/vault vault
#wal -i ~/Wallpapers/5sense1.jpg
#wal -i ~/Wallpapers/steampunk_1.jpg
#wal -i ~/Wallpapers/steampunk_5.jpg
#wal -i ~/Wallpapers/rail.jpg
#wal -i ~/Wallpapers/forrest_new.jpg
#wal -i ~/Wallpapers/cyberpunk_city.jpg
#xrdb ~/.Xresources
#neofetch
#
#### TODO
#source <(hcloud completion zsh)
#eval "$(starship init zsh)"
#eval "$(jira --completion-script-zsh)"
#eval "$(_JZ_COMPLETE=source_zsh jz)"
eval "$(_HAJDUK_COMPLETE=source_zsh hajduk)"
#eval "$(_H_COMPLETE=source_zsh h)"
eval "$(direnv hook zsh)"
#eval "$(register-python-argcomplete gitlab)"
alias tf=terraform
alias tfw="terraform workspace"
alias easy-rsa="docker run --rm -it -v /home/paramah/secrets/rsa:/pki -v /home/paramah/.aws:/root/.aws -e AWS_PROFILE=sandbox -e KMS_KEY_ID=test paramah/easyrsa"
# alias genpass="< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;"
alias genpass="gopass pwgen -1 32"
function tfv(){
terraform validate -var-file=vars/$(terraform workspace show).tfvars $1
}
function tfp(){
terraform plan -var-file=vars/$(terraform workspace show).tfvars $1
}
function tfa(){
terraform apply -var-file=vars/$(terraform workspace show).tfvars $1
}
function tfc(){
terraform console -var-file=vars/$(terraform workspace show).tfvars $1
}
function gitc(){
git commit -a -S $1
}
function ec2-list(){
aws ec2 describe-instances \
--filter "Name=instance-state-name,Values=running" \
--query "Reservations[*].Instances[*].[Tags[?Key=='Name'].Value|[0], PublicIpAddress, PrivateIpAddress, LaunchTime, InstanceId]" \
--output table
}
function ec2-connect(){
HOST=$(ec2-list | fzf --layout=reverse --border=none | awk '{print $4}' |sed 's/|//')
gum confirm "Add host to Stream Sage VPN route?" && skrzat mikrotik tovpn jazzy-l2tp jazzy ${HOST}
USER=$(gum choose "ec2-user" "admin" "ubuntu" "bitnami")
jssh $USER@$HOST
}
function ec2-vpc-connect(){
HOST=$(ec2-list | fzf --layout=reverse --border=none | awk '{print $6}')
USER=$(gum choose "ec2-user" "admin" "ubuntu" "bitnami")
jssh $USER@$HOST
}
function targetgroups-list(){
LB_ARN=$(aws elbv2 describe-load-balancers --query "LoadBalancers[*][LoadBalancerName, LoadBalancerArn]" --output table |fzf | awk '{print $4}')
echo LB_ARN
}
function tester-toogle(){
if [[ $(aws ec2 describe-instances --instance-ids $EC_TESTER_ID --query 'Reservations[].Instances[].State[].Name' --output text) = "running" ]] ; then \
aws ec2 stop-instances --instance-ids $EC_TESTER_ID; \
elif [[ $(aws ec2 describe-instances --instance-ids $EC_TESTER_ID --query 'Reservations[].Instances[].State[].Name' --output text) = "stopped" ]] ; then \
aws ec2 start-instances --instance-ids $EC_TESTER_ID ; \
fi
}
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet
#complete -o nospace -C /usr/bin/terraform terraform
source $HOME/.oh-my-zsh/custom/plugins/fzf-tab-completion/zsh/fzf-zsh-completion.sh
autoload -Uz bashcompinit && bashcompinit
complete -C aws_completer aws
# eval "$(_MOLECULE_COMPLETE=source molecule)"
#. ~/.cache/wal/colors.sh
#
#
function prompt_docker_host() {
if [[ ! -z "${DOCKER_HOST}" ]]; then
proto="$(echo $DOCKER_HOST | grep :// | sed -e's,^\(.*://\).*,\1,g')"
url=$(echo $DOCKER_HOST | sed -e s,$proto,,g)
user="$(echo $url | grep @ | cut -d@ -f1)"
hostport=$(echo $url | sed -e s,$user@,,g | cut -d/ -f1)
host="$(echo $hostport | sed -e 's,:.*,,g')"
p10k segment -b black -f yellow -t "!!DOCKER: ${host}"
fi
}
function prompt_jzmode() {
if [ -f .jz-mode ]; then
p10k segment -b '#012845' -f white -t $(cat .jz-mode)
fi
if [ -f .ledo-mode ]; then
p10k segment -b '#012845' -f white -t $(cat .ledo-mode)
fi
}
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS+=docker_host
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS+=jzmode
decodeuuid() {
http https://www.uuidtools.com/api/decode/$1 |jq
}
rpg () {
rpg-cli "$@"
cd "$(rpg-cli pwd)"
}
mh() {
xrandr --output DP1-1 --auto --right-of eDP1
xrandr --output DP1-2 --auto --left-of eDP1
theme
}
mb() {
xrandr --output DP1-1-1 --auto --right-of eDP1
xrandr --output DP1-1-8 --auto --left-of eDP1
theme
}
export PAGER=bat
#alias ls="exa"
#cat ~/.ideas
#
if [[ "${TERM}" != "" && "${TERM}" == "xterm-256color" ]]
then
precmd()
{
print -Pn "\e]0;%~\a"
}
preexec()
{
echo -en "\e]0;$(id --user --name)@$(hostname): ${1}\a"
}
fi
#PROG=tea _CLI_ZSH_AUTOCOMPLETE_HACK=1 source "/home/paramah/.config/tea/autocomplete.zsh"
#PROG=ledo _CLI_ZSH_AUTOCOMPLETE_HACK=1 source "/home/paramah/.config/ledo/autocomplete.zsh"
PATH="/home/paramah/perl5/bin${PATH:+:${PATH}}"; export PATH;
PERL5LIB="/home/paramah/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
PERL_LOCAL_LIB_ROOT="/home/paramah/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
PERL_MB_OPT="--install_base \"/home/paramah/perl5\""; export PERL_MB_OPT;
PERL_MM_OPT="INSTALL_BASE=/home/paramah/perl5"; export PERL_MM_OPT;
PATH="/home/paramah/.local/share/gem/ruby/3.0.0/bin${PATH:+${PATH}}"; export PATH;
#source <(clockify-cli completion zsh)
#source <(kubectl completion zsh)
source <(helm completion zsh)
source <(kubectl completion zsh)
POWERLEVEL9K_DISABLE_CONFIGURATION_WIZARD=true
typeset -g POWERLEVEL9K_DIR_CLASSES=(
'~/Projects/jazzy.pro(|/*)' WORK ''
'~/Projects/streamsage(|/*)' WORKSS ''
'~/Projects/streamsage.io(|/*)' WORKSS ''
'~/Projects/stream-sage(|/*)' WORKSS ''
'~/Projects/Private(|/*)' PRIVATE ''
'~/Projects/cynarski.dev(|/*)' PRIVATE ''
'~/Projects/CyfroweNiebo(|/*)' NIEBO ''
'~(|/*)' HOME ''
'*' DEFAULT '')
typeset -g POWERLEVEL9K_DIR_WORK_VISUAL_IDENTIFIER_EXPANSION='(j!)'
typeset -g POWERLEVEL9K_DIR_WORKSS_VISUAL_IDENTIFIER_EXPANSION='<<o>>'
typeset -g POWERLEVEL9K_DIR_PRIVATE_VISUAL_IDENTIFIER_EXPANSION='(℀ )'
typeset -g POWERLEVEL9K_DIR_NIEBO_VISUAL_IDENTIFIER_EXPANSION='[☰ ]'
typeset -g POWERLEVEL9K_AWS_SHOW_ON_DEMAND=''
#export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
#export GPG_TTY=$(tty)
#gpgconf --launch gpg-agent
#gpg-connect-agent updatestartuptty /bye >/dev/null
#export NVM_DIR="$HOME/.nvm"
#[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
#[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
#
autoload bashcompinit
bashcompinit
source /usr/lib/python3.12/site-packages/argcomplete/bash_completion.d/_python-argcomplete
# pnpm
export PNPM_HOME="/home/paramah/.local/share/pnpm"
case ":$PATH:" in
*":$PNPM_HOME:"*) ;;
*) export PATH="$PNPM_HOME:$PATH" ;;
esac
# pnpm end
#