Skip to content

Instantly share code, notes, and snippets.

@hiroaki-yamamoto
Created April 17, 2015 13:08
Show Gist options
  • Save hiroaki-yamamoto/83552975c4626334b737 to your computer and use it in GitHub Desktop.
Save hiroaki-yamamoto/83552975c4626334b737 to your computer and use it in GitHub Desktop.
.zshrc I'm usually using on OS X
#Load auto completion module, colors, and history functions.
autoload -U compinit promptinit colors smart-insert-last-word
compinit
promptinit
colors
zstyle ':completion:*:default' menu select=1 ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z} r:|[-_.]=**'
#Prompt
PROMPT="[%{$fg[green]%B%}%n%{%b$reset_color%}@%{$fg[magenta]%B%}%M%{%b$reset_color%} (%{$fg[yellow]%B%}%l%{%b$reset_color%}) %{$fg[cyan]%B%}%~%{%b$reset_color%}]"
case $(id -u) in
0)
PROMPT="${PROMPT}# "
;;
*)
PROMPT="${PROMPT}$ "
;;
esac
export PROMPT
#Set autocd (is known as bash) and autopushd.
setopt autocd autopushd
#Set displaying shrinked completion
setopt list_packed extended_glob
#Set waiting 10 sec. when rm *
#setopt rmstar_wait
#Set going home when pushd without arguments.
setopt pushd_to_home
#Set ignoring history duplication.
setopt hist_ignore_dups hist_ignore_all_dups
#Ignore space in the history file.
setopt hist_ignore_space
#Increase history,
setopt inc_append_history
#Ignore pushd duplication.
setopt pushd_ignore_dups
#Completion alias
setopt completealiases
#Prompt spell fix,
setopt prompt_subst always_last_prompt
xhost +local:root>/dev/null 2>&1
alias ls="ls -G"
bindkey "^[[A" history-search-backward
bindkey "^[[B" history-search-forward
bindkey "\e[1;2D" beginning-of-line # Home
bindkey "\e[1;2C" end-of-line # End
bindkey "\e[5~" beginning-of-history # PageUp
bindkey "\e[6~" end-of-history # PageDown
bindkey "\e[2~" quoted-insert # Ins
bindkey "\e[3~" delete-char # Del
bindkey "\e[5C" forward-word
bindkey "\eOc" emacs-forward-word
bindkey "\e[5D" backward-word
bindkey "\eOd" emacs-backward-word
bindkey "\e\e[C" forward-word
bindkey "\e\e[D" backward-word
bindkey "\e[Z" reverse-menu-complete # Shift+Tab
bindkey "^W" insert-last-word
if [[ $TERM_PROGRAM == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]] {
function chpwd {
local SEARCH=' '
local REPLACE='%20'
local PWD_URL="file://$HOSTNAME${PWD//$SEARCH/$REPLACE}"
printf '\e]7;%s\a' "$PWD_URL"
}
chpwd
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment