dotfiles/.zshrc

188 lines
4.1 KiB
Bash
Raw Normal View History

2018-04-04 17:37:05 +02:00
source ~/.zplug/init.zsh
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
2020-09-28 23:16:07 +02:00
# zplug 'zsh-users/zsh-autosuggestions'
# zplug 'Aloxaf/fzf-tab'
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-27 13:56:54 +02:00
## Completion
autoload -Uz compinit
compinit
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"
2020-09-27 13:56:54 +02:00
## Aliases
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'
2020-09-27 13:56:54 +02:00
alias xc='xclip -selection clipboard'
2021-03-31 11:02:29 +02:00
alias c='cut -c-${COLUMNS}'
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 ()
{
nvr --remote $(readlink -f "$@")
2021-04-02 17:31:47 +02:00
echo -e "\x1b]2;$(_title) $(date +%s):nvim\x1b\\"
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
2020-04-22 18:54:47 +02:00
command -v kubectl >/dev/null 2>&1 && source <(kubectl completion zsh)
2019-12-02 11:30:13 +01:00
export PATH=$HOME/.krew/bin:$PATH
2021-01-12 19:39:52 +01:00
## linkerd
command -v linkerd >/dev/null 2>&1 && source <(linkerd completion zsh)
2020-09-27 13:56:54 +02:00
## Flux
2021-03-31 11:02:29 +02:00
command -v flux >/dev/null 2>&1 && source <(flux completion zsh)
2019-10-19 12:36:29 +02:00
2021-04-15 14:40:05 +02:00
## Tekton cli
command -v tkn >/dev/null 2>&1 && source <(tkn completion zsh)
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
2017-08-09 08:43:48 +02:00
2019-09-03 14:50:36 +02:00
## Golang
2020-09-27 13:56:54 +02:00
export PATH=$HOME/go/bin:$PATH
2019-09-03 14:50:36 +02:00
GOPROXY=https://proxy.golang.org/
## Ansible
export ANSIBLE_NOCOWS=1
2019-01-01 19:48:52 +01:00
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
autoload -U +X bashcompinit && bashcompinit
complete -o nospace -C /usr/bin/vault vault