142 lines
3.9 KiB
Bash
142 lines
3.9 KiB
Bash
# $HOME/.config/zsh/.zshrc
|
|
# Note: Install zsh-completions package
|
|
|
|
setopt hist_find_no_dups
|
|
setopt extended_history
|
|
setopt inc_append_history
|
|
setopt auto_pushd
|
|
setopt pushd_ignore_dups
|
|
setopt pushd_silent
|
|
setopt pushd_minus
|
|
setopt pushd_to_home
|
|
setopt prompt_subst
|
|
|
|
# Prompt
|
|
prompt_git_info () {
|
|
bn=$(git bn 2>/dev/null)
|
|
if [[ $? -eq 0 ]]; then
|
|
echo " %F{#aaaaaa}(%F{green}$bn%F{#aaaaaa})"
|
|
fi
|
|
}
|
|
PROMPT='%F{#666666}[%F{#AAAAAA}%n%F{#aaaaaa}@%F{red}%m %F{blue}%1~$(prompt_git_info)%F{white}%F{#666666}]%F{white}%# %f'
|
|
RPROMPT='%(?.%F{green}√%f.%F{red}%?%f) %F{#666666}%*%f'
|
|
|
|
# Completion
|
|
# The following lines were added by compinstall
|
|
|
|
zstyle ':completion:*' completer _complete _ignored _match _prefix
|
|
zstyle ':completion:*' expand prefix suffix
|
|
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
|
|
zstyle ':completion:*' menu select=1
|
|
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
|
|
zstyle :compinstall filename '/home/rob/.config/zsh/.zshrc'
|
|
|
|
autoload -Uz compinit
|
|
compinit
|
|
# End of lines added by compinstall
|
|
|
|
# Search using up/down cursors
|
|
# https://unix.stackexchange.com/a/285151/185944
|
|
# TODO: fuzzy search broken
|
|
autoload -U up-line-or-beginning-search
|
|
autoload -U down-line-or-beginning-search
|
|
zle -N up-line-or-beginning-search
|
|
zle -N down-line-or-beginning-search
|
|
bindkey "^[[A" up-line-or-beginning-search # up
|
|
bindkey "^[[B" down-line-or-beginning-search # down
|
|
|
|
# Vim keymap
|
|
bindkey -v
|
|
bindkey '^w' backward-kill-word
|
|
bindkey '^r' history-incremental-search-backward
|
|
|
|
# Other aliases
|
|
alias be="bundle exec"
|
|
alias berc="bundle exec rails console"
|
|
alias bers="bundle exec rails server"
|
|
alias berspec="bundle exec rspec --no-profile"
|
|
alias c-="cd -"
|
|
alias c.="cd .."
|
|
alias cdg=cdgit
|
|
alias cdgit='cd $(git rev-parse --show-toplevel)'
|
|
alias clp="tmux kill-pane"
|
|
alias clw="tmux kill-window"
|
|
alias d="dirs -v"
|
|
alias dc="docker-compose -f docker-compose.yml"
|
|
alias dcd="docker-compose -f docker-compose.yml -f docker-compose.development.yml"
|
|
alias gb="go build"
|
|
alias gba="go build ./..."
|
|
alias gbat="go build ./... && go test ./..."
|
|
alias gc="git commit"
|
|
alias gd="git diff"
|
|
alias gg="go get"
|
|
alias gl="git pull"
|
|
alias gp="git push"
|
|
alias gst="git status"
|
|
alias gt="go test"
|
|
alias gta="go test ./..."
|
|
alias k9="kill -9"
|
|
alias ll="exa -l --group-directories-first --git"
|
|
alias ls="exa --color=auto"
|
|
alias ng="noglob"
|
|
alias pg="pgrep -fa"
|
|
alias pk="pkill -fc"
|
|
alias rez="source $HOME/.zshenv && source $ZDOTDIR/.zshrc"
|
|
alias sc="systemctl"
|
|
alias sk="setkeys"
|
|
alias ssc="sudo systemctl"
|
|
alias sysc="systemctl"
|
|
alias rggo="rg -g '*\.go' -g '!vendor/'"
|
|
alias rggt="rg -g '*\_test.go' -g '!vendor/'"
|
|
alias tm="tmux attach"
|
|
alias tmd="tmux new -s default -c $HOME || tmux attach -t default"
|
|
alias tms="tmuxsess"
|
|
alias wg="sudo wg"
|
|
alias wgdown="sudo wgdown"
|
|
alias wgup="sudo wgup"
|
|
alias zzz="sudo systemctl hibernate"
|
|
# recursive grep with line numbers and colour, ignoring binary files:
|
|
alias gnr="grep -nR -I --color"
|
|
# same but case-insensitive:
|
|
alias gnri="grep -nRi -I --color"
|
|
|
|
# On boot, power on bluetooth and start xfce
|
|
if [ $(tty) = "/dev/tty1" ]; then
|
|
bluetoothctl power on
|
|
startx
|
|
fi
|
|
|
|
# For Linux, disable Caps-Lock:
|
|
if [ -x "setxkbmap" ]; then
|
|
setxkbmap -option caps:none
|
|
fi
|
|
|
|
# Set zshfunctions dir as per https://github.com/alacritty/alacritty/blob/master/INSTALL.md#shell-completions
|
|
fpath+=${ZDOTDIR:-~}/functions
|
|
|
|
# fzf configuration
|
|
export KEYTIMEOUT=2
|
|
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
|
|
|
|
# set PATHs (highest priority last)
|
|
export PATH=$HOME/go/bin:$PATH
|
|
export PATH=$HOME/local/sbin:$PATH
|
|
export PATH=$HOME/local/bin:$PATH
|
|
export PATH=$HOME/bin:$PATH
|
|
export PATH=$HOME/.local/bin:$PATH
|
|
export PATH=$HOME/script:$PATH
|
|
|
|
export VIMPLUGIN="$HOME/.vim/pack/git-plugins"
|
|
|
|
# source local zshrc, if it exists (not: not in git)
|
|
if [ -f $ZDOTDIR/.zshrc.local ]; then
|
|
. $ZDOTDIR/.zshrc.local
|
|
fi
|
|
|
|
# set up asdf
|
|
if [ -f $HOME/.asdf/asdf.sh ]; then
|
|
. $HOME/.asdf/asdf.sh
|
|
else
|
|
echo "Warning: asdf not found, skipping"
|
|
fi
|