Skip to content

Instantly share code, notes, and snippets.

@havenwood
Created May 7, 2020 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save havenwood/d150bc5a8aff8e920ce8c114773c300d to your computer and use it in GitHub Desktop.
Save havenwood/d150bc5a8aff8e920ce8c114773c300d to your computer and use it in GitHub Desktop.
My ~/.zshrc file
##
# zsh
autoload colors && colors
autoload -Uz compinit && compinit -i
autoload -Uz add-zsh-hook
setopt auto_cd cdablevars beep nomatch notify
setopt completeinword extendedglob globdots prompt_subst interactivecomments
setopt appendhistory sharehistory incappendhistory hist_ignore_space hist_ignore_all_dups
bindkey -e
##
# autocompletion
zstyle ":completion:*" matcher-list "m:{a-zA-Z}={A-Za-z}" "r:|[._-]=* r:|=*" "l:|=* r:|=*"
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/cache
zstyle ':completion:*' completer _complete _match _approximate
zstyle ':completion:*:match:*' original only
zstyle ':completion:*:approximate:*' max-errors 1 numeric
zstyle ':completion:*:functions' ignored-patterns '_*'
zstyle ':completion:*:*:kill:*' menu yes select
zstyle ':completion:*:kill:*' force-list always
zstyle ':completion:*:cd:*' ignore-parents parent pwd
##
# chruby
function () {
source "/usr/local/share/chruby/chruby.sh"
source "/usr/local/share/chruby/auto.sh"
compctl -g "$HOME/.rubies/*(:t)" chruby
}
##
# aliases
alias virus-scan="freshclam -v && clamscan -r --bell -i"
alias chrome-http2="echo '\"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome\" --enable-websocket-over-http2'"
alias code="code -g"
alias first="head -n1"
alias bytes="ruby -e 'puts ARGF.each_byte.to_a'"
alias cat="bat -p"
alias tree="tree -C"
alias ccat="ccat --bg=dark"
alias wa="echo 'Ruby is 和.'"
alias -s rb="atom"
alias perl6="rlwrap perl6"
alias .clear="clear"
alias airport="/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport"
alias ls="exa"
# alias ls="ls -G"
function autosuggest() {
source "/usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh"
fpath=(/usr/local/share/zsh-completions $fpath)
}
autosuggest
unfunction autosuggest
##
# syntax highlighting
function highlight() {
source "/usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
typeset -A ZSH_HIGHLIGHT_STYLES
ZSH_HIGHLIGHT_STYLES[alias]='fg=magenta,bold'
ZSH_HIGHLIGHT_STYLES[command]='fg=cyan'
ZSH_HIGHLIGHT_STYLES[function]='fg=green'
}
highlight
unfunction highlight
##
# pwny protection
function () {
source "$HOME/.pony_protection.sh"
alias hostname="echo square"
alias hide="pmset displaysleepnow"
if [[ -n "$ZSH_VERSION" ]]; then
add-zsh-hook preexec pwny_protection
elif [[ -n "$BASH_VERSION" ]]; then
trap 'pwny_protection' DEBUG
fi
}
##
# truffleruby
function jt() {
cd "$TRUFFLERUBY_HOME" || exit
ruby "$TRUFFLERUBY_HOME/tool/jt.rb" "$@"
cd "$OLDPWD" || exit
}
##
# prompt
function git_status() {
[[ -d ".git" ]] && echo "$(git_emoji) ($(git_branch))"
}
function git_tracked_clean() {
git diff --no-ext-diff --quiet
}
function git_untracked_clean() {
[[ -z "$(git ls-files --others -z --exclude-standard)" ]]
}
function git_emoji() {
git update-index -q --ignore-submodules --refresh
git_tracked_clean && git_untracked_clean && echo "🌼" || echo "🍄"
}
function git_branch() {
local branch=$(git symbolic-ref -q HEAD -- || git name-rev --name-only --no-undefined --always HEAD)
echo "${branch#(refs/heads/|tags/)}"
}
function no-emoji-prompt() {
export PROMPT='%F{44}%~%f '
}
alias quick="no-emoji-prompt"
function emoji-prompt() {
export PROMPT='%F{44}%~%F{49}$(git_status)%f '
}
alias slow="emoji-prompt"
emoji-prompt
function right-prompt() {
export RPROMPT='Snugbear!'
}
function no-right-prompt {
unset RPROMPT
}
##### en fin #####
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment