dotfiles/.zshrc

217 lines
5 KiB
Bash
Raw Normal View History

2018-04-04 17:37:05 +02:00
source ~/.zplug/init.zsh
2021-06-17 11:29:04 +02:00
2018-04-04 17:37:05 +02:00
zplug "plugins/git", from:oh-my-zsh
2020-08-21 08:28:02 +02:00
zplug "zsh-users/zsh-completions"
2020-09-27 16:38:35 +02:00
zplug 'zsh-users/zsh-syntax-highlighting', defer:2
zplug 'zsh-users/zsh-history-substring-search', defer:3
2018-04-04 17:37:05 +02:00
if ! zplug check --verbose; then
printf "Install? [y/N]: "
if read -q; then
echo; zplug install
fi
fi
zplug load
2020-09-27 16:38:35 +02:00
## History
HISTSIZE=50000
SAVEHIST=50000
HISTFILE=~/.zsh_history
setopt append_history
setopt extended_history
setopt hist_expire_dups_first
setopt hist_fcntl_lock
setopt hist_ignore_all_dups
setopt hist_ignore_space
setopt HIST_IGNORE_SPACE
setopt hist_lex_words
setopt hist_reduce_blanks
setopt hist_save_no_dups
setopt hist_subst_pattern
setopt hist_verify
setopt share_history
## zsh settings
setopt pipe_fail
setopt auto_pushd
setopt no_beep
setopt no_rm_star_silent
setopt extended_glob
setopt ksh_glob
setopt null_glob
2020-09-28 17:05:15 +02:00
## Autosuggest
2020-09-28 23:16:07 +02:00
# ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#D7CCC8,italic"
# ZSH_AUTOSUGGEST_USE_ASYNC=1
# ZSH_AUTOSUGGEST_STRATEGY=(history completion)
## fasd
alias a='fasd -a' # any
alias s='fasd -si' # show / search / select
alias d='fasd -d' # directory
alias f='fasd -f' # file
alias sd='fasd -sid' # interactive directory selection
alias sf='fasd -sif' # interactive file selection
alias z='fasd_cd -d' # cd, same functionality as j in autojump
alias zz='fasd_cd -d -i' # cd with interactive selection
2021-04-15 19:41:37 +02:00
if command -v pazi &>/dev/null; then
eval "$(pazi init zsh)" # or 'bash'
fi
2020-09-28 23:16:07 +02:00
redraw-prompt() {
local precmd
for precmd in $precmd_functions; do
$precmd
done
zle reset-prompt
}
zle -N redraw-prompt
_jump() {
2021-04-15 19:41:37 +02:00
z --pipe="fzf"
2020-09-28 23:16:07 +02:00
zle && zle redraw-prompt
}
zle -N _jump
2020-09-28 17:05:15 +02:00
2020-09-27 16:38:35 +02:00
## Keybindings
bindkey -e
2020-10-19 12:20:28 +02:00
bindkey '^[[A' history-beginning-search-backward
bindkey '^[[B' history-beginning-search-forward
2020-09-28 23:16:07 +02:00
bindkey '^P' history-beginning-search-backward
bindkey '^N' history-beginning-search-forward
bindkey '^g' _jump
2020-09-27 16:38:35 +02:00
2020-09-27 13:56:54 +02:00
## Gnupg / gpg / ssh / yubikey
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
2019-12-04 17:28:14 +01:00
2020-04-22 08:30:34 +02:00
## Pager
2020-11-15 14:30:52 +01:00
export LESS="--mouse --wheel-lines=1 -nRXF"
2021-06-19 11:55:31 +02:00
## Clipboard OSC 52
function clip { echo -en "\x1b]52;c;$(base64 -w0)\x07" }
2020-09-27 13:56:54 +02:00
## Aliases
2021-06-19 11:55:31 +02:00
alias c='cut -c-${COLUMNS}'
2020-09-27 13:56:54 +02:00
alias dotgit='git --work-tree $HOME --git-dir $HOME/.dot_git'
2020-09-28 17:05:15 +02:00
alias l=bat
2019-10-19 12:36:29 +02:00
alias ls=exa
2020-09-27 13:56:54 +02:00
alias tail='tail -n $LINES'
alias timestamp='TZ=Z date "+%Y%m%dT%H%M%SZ"'
alias tree='exa --tree'
2020-11-15 14:30:52 +01:00
alias v=vgrep
alias ve='env EDITOR= vgrep -s'
2021-06-19 11:55:31 +02:00
alias xc=clip
2018-01-17 21:38:11 +01:00
2020-11-15 14:30:52 +01:00
2021-04-02 17:31:47 +02:00
## Prompt
eval "$(starship init zsh)"
function _title(){
printf '%-16.16s' "$(starship module directory | sed 's/\x1b\[[0-9;]*m//g')"
}
function set_win_title(){
echo -ne "\033]0; $(_title) \007"
}
set_win_title
2018-01-03 08:47:21 +01:00
## vim
2020-09-27 13:56:54 +02:00
export EDITOR=nvim
2018-01-03 08:47:21 +01:00
export NVIM_LISTEN_ADDRESS=/tmp/nvimsocket
e ()
{
2021-06-17 11:29:04 +02:00
nvr --nostart --remote $(readlink -f "$@")
2021-07-22 10:32:46 +02:00
tmux select-window -t1
2018-01-03 08:47:21 +01:00
}
2020-09-28 13:43:50 +02:00
## fzf
export FZF_TMUX=1
export FZF_COMPLETION_TRIGGER=";"
export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git'
. /usr/share/fzf/completion.zsh
. /usr/share/fzf/key-bindings.zsh
2020-09-05 13:20:38 +02:00
## direnv
eval "$(direnv hook zsh)"
2020-09-27 13:56:54 +02:00
## Kubernetes
2021-10-21 16:29:20 +02:00
command -v kubectl >/dev/null 2>&1 && kubectl completion zsh > "${fpath[1]}/_kubectl"
2019-12-02 11:30:13 +01:00
export PATH=$HOME/.krew/bin:$PATH
2021-01-12 19:39:52 +01:00
## linkerd
2021-07-22 10:32:46 +02:00
if [ ! -f "${fpath[1]}/_linkerd" ]; then
command -v linkerd >/dev/null 2>&1 && linkerd completion zsh > "${fpath[1]}/_linkerd"
fi
2021-01-12 19:39:52 +01:00
2020-09-27 13:56:54 +02:00
## Flux
2021-07-22 10:32:46 +02:00
if [ ! -f "${fpath[1]}/_flux" ]; then
command -v flux >/dev/null 2>&1 && source <(flux completion zsh)
fi
2019-10-19 12:36:29 +02:00
2021-04-15 14:40:05 +02:00
## Tekton cli
2021-07-22 10:32:46 +02:00
if [ ! -f "${fpath[1]}/_tkn" ]; then
command -v tkn >/dev/null 2>&1 && tkn completion zsh > "${fpath[1]}/_tkn"
fi
2021-04-15 14:40:05 +02:00
2021-06-17 11:29:04 +02:00
## kapp
2021-07-22 10:32:46 +02:00
if [ ! -f "${fpath[1]}/_kapp" ]; then
command -v kapp >/dev/null 2>&1 && kapp completion zsh --tty=false > "${fpath[1]}/_kapp"
fi
2021-06-17 11:29:04 +02:00
## talos cli
2021-07-22 10:32:46 +02:00
if [ ! -f "${fpath[1]}/_talosctl" ]; then
command -v talosctl >/dev/null 2>&1 && talosctl completion zsh > "${fpath[1]}/_talosctl"
fi
2021-06-17 11:29:04 +02:00
2020-09-27 13:56:54 +02:00
## Google Cloud
2017-08-09 08:43:48 +02:00
[ -f /opt/google-cloud-sdk/completion.zsh.inc ] && source /opt/google-cloud-sdk/completion.zsh.inc
2021-01-03 13:16:07 +01:00
# hack until gcloud works with python 3.9
export CLOUDSDK_PYTHON=python2
2019-09-03 14:50:36 +02:00
## Golang
2020-09-27 13:56:54 +02:00
export PATH=$HOME/go/bin:$PATH
2021-07-22 10:32:46 +02:00
GOPROXY=https://athens.aarn.shelman.io
2019-09-03 14:50:36 +02:00
## Ansible
export ANSIBLE_NOCOWS=1
2019-01-01 19:48:52 +01:00
2021-07-22 10:32:46 +02:00
## Docker
export DOCKER_BUILDKIT=1
2021-04-15 14:40:05 +02:00
## PostgreSQL Operator
export PATH=/home/dln/.pgo/pgo:$PATH
export PGOUSER=/home/dln/.pgo/pgo/pgouser
export PGO_CA_CERT=/home/dln/.pgo/pgo/client.crt
export PGO_CLIENT_CERT=/home/dln/.pgo/pgo/client.crt
export PGO_CLIENT_KEY=/home/dln/.pgo/pgo/client.key
export PGO_APISERVER_URL='https://127.0.0.1:8443'
export PGO_NAMESPACE=pgo
2020-09-27 16:38:35 +02:00
export PATH=$HOME/bin:$PATH
2020-10-11 14:09:53 +02:00
2021-07-22 10:32:46 +02:00
# ## Completion
2021-06-17 11:29:04 +02:00
autoload -Uz compinit
2021-07-22 10:32:46 +02:00
compinit -i
2021-10-21 16:29:20 +02:00
## AWS
if [ -x /usr/bin/aws_zsh_completer.sh ]; then
source /usr/bin/aws_zsh_completer.sh
fi
2021-12-20 12:08:29 +01:00
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/home/dln/google-cloud-sdk/path.zsh.inc' ]; then . '/home/dln/google-cloud-sdk/path.zsh.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/home/dln/google-cloud-sdk/completion.zsh.inc' ]; then . '/home/dln/google-cloud-sdk/completion.zsh.inc'; fi