Last active
June 17, 2020 16:59
-
-
Save averne/9f979add5a25b7d62b9892b9620f7187 to your computer and use it in GitHub Desktop.
Zsh dotfiles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .zshenv | |
export ZDOTDIR=~/.config/zsh | |
export DEVKITPRO=/opt/devkitpro | |
export DEVKITARM=${DEVKITPRO}/devkitARM | |
export DEVKITPPC=${DEVKITPRO}/devkitPPC | |
export PATH=${DEVKITPRO}/tools/bin:$PATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .zshrc | |
# History | |
HISTFILE=~/.cache/zshhist | |
HISTSIZE=1000 | |
SAVEHIST=1000 | |
# Options | |
setopt autocd | |
setopt cdablevars | |
setopt correct | |
setopt globdots | |
setopt histignoredups | |
# Colors | |
autoload -Uz colors && colors | |
# Autocompletion | |
autoload -Uz compinit && compinit -d ~/.cache/zsh/zcompdump | |
zstyle ":completion:*" menu select | |
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' | |
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} | |
setopt COMPLETE_ALIASES | |
# Search history | |
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 | |
# Source control | |
autoload -Uz vcs_info | |
precmd_vcs_info() { vcs_info } | |
precmd_functions+=( precmd_vcs_info ) | |
zstyle ':vcs_info:*' enable git | |
zstyle ':vcs_info:*' check-for-changes true | |
zstyle ':vcs_info:git*' formats "%{${fg[yellow]}%} %m%u%c%{${fg[cyan]}%}[%{${fg[blue]}%}%s%{${fg[cyan]}%}][%{${fg[green]}%}%b%{${fg[cyan]}%}]%{$reset_color%}" | |
# Rename utility | |
autoload zmv | |
# Pacman hook | |
rehash_precmd() { | |
if [[ -a /var/cache/zsh/pacman ]]; then | |
local paccache_time="$(date -r /var/cache/zsh/pacman +%s%N)" | |
if (( zshcache_time < paccache_time )); then | |
rehash | |
zshcache_time="$paccache_time" | |
fi | |
fi | |
} | |
zshcache_time="$(date +%s%N)" | |
autoload -Uz add-zsh-hook | |
add-zsh-hook -Uz precmd rehash_precmd | |
# Keybindings | |
bindkey -e | |
bindkey "\e[3~" delete-char # Del | |
bindkey "^[[A" up-line-or-beginning-search # Up | |
bindkey "^[[B" down-line-or-beginning-search # Down | |
bindkey "^[[1;3C" forward-word # Alt-left | |
bindkey "^[[1;3D" backward-word # Alt-right | |
bindkey "^[[1;5C" end-of-line # Ctrl-left | |
bindkey "^[[1;5D" beginning-of-line # Ctrl-right | |
# Prompt | |
setopt prompt_subst | |
if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then | |
export host_col="%{${fg[red]}%}%M%f" | |
else | |
export host_col="%{${fg[blue]}%}%M%f" | |
fi | |
export PS1=${(j::Q)${(Z:Cn:):-" | |
%{${fg[cyan]}%}[%f | |
%(!.%{${fg[red]}%}%n%f.%{${fg[green]}%}%n%f) | |
%{${fg[cyan]}%}@%f | |
${host_col} | |
%{${fg[cyan]}%}][%f | |
%{${fg_bold[blue]}%}%20<...<%~%<<%f%{$reset_color%} | |
%{${fg[cyan]}%}]%f | |
%(!.%{${fg[red]}%}%#%f.%{${fg[blue]}%}$%f) | |
' ' | |
"}} | |
export RPS1=$'%(?..%F{red}%?)${vcs_info_msg_0_}' | |
# Functions | |
man() { | |
env \ | |
LESS_TERMCAP_mb=$(printf "\e[1;31m") \ | |
LESS_TERMCAP_md=$(printf "\e[1;34m") \ | |
LESS_TERMCAP_me=$(printf "\e[0m") \ | |
LESS_TERMCAP_se=$(printf "\e[0m") \ | |
LESS_TERMCAP_so=$(printf "\e[1;42;37m") \ | |
LESS_TERMCAP_ue=$(printf "\e[0m") \ | |
LESS_TERMCAP_us=$(printf "\e[1;36m") \ | |
man "$@" | |
} | |
rangercd () { | |
tmp="$(mktemp)" | |
ranger --choosedir="$tmp" "$@" | |
if [[ -f $tmp ]]; then | |
dir="$(cat "$tmp")" | |
rm -f "$tmp" | |
[ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir" | |
fi | |
} | |
bindkey -s "^o" "rangercd\n" | |
mkcd() { | |
mkdir -p "$*" | |
cd "$*" | |
} | |
py() { | |
clear | |
bpython | |
} | |
duh() { | |
du -hs $PWD | |
} | |
# Aliases | |
alias mv="mv -i" | |
alias cp="cp -i" | |
alias df="df -h" | |
alias du="du -hc" | |
alias ls="ls -F --color=auto --group-directories-first" | |
alias la="ls -lAh --color=auto --group-directories-first" | |
alias grep="grep --color=auto" | |
alias less="less -s -M +Gg" | |
alias dd="dd status=progress" | |
alias rg="ranger" | |
alias countryroads="cd ~" | |
alias xclipi="xclip -selection clipboard -i" | |
alias xclipo="xclip -selection clipboard -o" | |
alias xclipii="xclip -selection clipboard -i -t image/png" | |
alias xclipoi="xclip -selection clipboard -o -t image/png" | |
alias vzshrc="vim ~/.config/zsh/.zshrc" | |
# Syntax highlighting | |
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh | |
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets) | |
# Autosuggestions | |
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment