Last active
May 17, 2016 22:53
-
-
Save reklis/84a9cd0dedf73fa56488 to your computer and use it in GitHub Desktop.
zsh profile baseline
This file contains hidden or 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
| for f (~/.zshrc.d/**/*.sh) { | |
| source $f | |
| } | |
| source ~/.zsh-keybindings | |
| source ~/.zsh-prompt |
This file contains hidden or 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
| # http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html | |
| # http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Builtins | |
| # http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Standard-Widgets | |
| # Make sure that the terminal is in application mode when zle is active, since | |
| # only then values from $terminfo are valid | |
| if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then | |
| function zle-line-init() { | |
| echoti smkx | |
| } | |
| function zle-line-finish() { | |
| echoti rmkx | |
| } | |
| zle -N zle-line-init | |
| zle -N zle-line-finish | |
| fi | |
| bindkey -e # Use emacs key bindings | |
| bindkey '\ew' kill-region # [Esc-w] - Kill from the cursor to the mark | |
| bindkey -s '\el' 'ls\n' # [Esc-l] - run command: ls | |
| bindkey '^r' history-incremental-search-backward # [Ctrl-r] - Search backward incrementally for a specified string. The string may begin with ^ to anchor the search to the beginning of the line. | |
| if [[ "${terminfo[kpp]}" != "" ]]; then | |
| bindkey "${terminfo[kpp]}" up-line-or-history # [PageUp] - Up a line of history | |
| fi | |
| if [[ "${terminfo[knp]}" != "" ]]; then | |
| bindkey "${terminfo[knp]}" down-line-or-history # [PageDown] - Down a line of history | |
| fi | |
| if [[ "${terminfo[kcuu1]}" != "" ]]; then | |
| bindkey "${terminfo[kcuu1]}" up-line-or-search # start typing + [Up-Arrow] - fuzzy find history forward | |
| fi | |
| if [[ "${terminfo[kcud1]}" != "" ]]; then | |
| bindkey "${terminfo[kcud1]}" down-line-or-search # start typing + [Down-Arrow] - fuzzy find history backward | |
| fi | |
| if [[ "${terminfo[khome]}" != "" ]]; then | |
| bindkey "${terminfo[khome]}" beginning-of-line # [Home] - Go to beginning of line | |
| fi | |
| if [[ "${terminfo[kend]}" != "" ]]; then | |
| bindkey "${terminfo[kend]}" end-of-line # [End] - Go to end of line | |
| fi | |
| bindkey ' ' magic-space # [Space] - do history expansion | |
| bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - move forward one word | |
| bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - move backward one word | |
| if [[ "${terminfo[kcbt]}" != "" ]]; then | |
| bindkey "${terminfo[kcbt]}" reverse-menu-complete # [Shift-Tab] - move through the completion menu backwards | |
| fi | |
| bindkey '^?' backward-delete-char # [Backspace] - delete backward | |
| if [[ "${terminfo[kdch1]}" != "" ]]; then | |
| bindkey "${terminfo[kdch1]}" delete-char # [Delete] - delete forward | |
| else | |
| bindkey "^[[3~" delete-char | |
| bindkey "^[3;5~" delete-char | |
| bindkey "\e[3~" delete-char | |
| fi | |
| # Edit the current command line in $EDITOR | |
| autoload -U edit-command-line | |
| zle -N edit-command-line | |
| bindkey '\C-x\C-e' edit-command-line | |
| ## Fix weird sequence that rxvt produces | |
| #bindkey -s '^[[Z' '\t' | |
| # |
This file contains hidden or 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
| # ------------------------------------------------------------------------ | |
| # spiral prompt theme | |
| # ------------------------------------------------------------------------ | |
| # Color shortcuts | |
| RED=$fg[red] | |
| MAGENTA=$fg[magenta] | |
| YELLOW=$fg[yellow] | |
| GREEN=$fg[green] | |
| WHITE=$fg[white] | |
| BLUE=$fg[blue] | |
| RED_BOLD=$fg_bold[red] | |
| MAGENTA_BOLD=$fg_bold[magenta] | |
| YELLOW_BOLD=$fg_bold[yellow] | |
| GREEN_BOLD=$fg_bold[green] | |
| WHITE_BOLD=$fg_bold[white] | |
| BLUE_BOLD=$fg_bold[blue] | |
| RESET_COLOR=$reset_color | |
| # icons | |
| PROMPT_CHARACTER="»" | |
| ERRORICON="\xe2\x9d\x8c\x0a" | |
| GITICON="%{$WHITE_BOLD%}깉%{$RESET_COLOR%}" | |
| HGICON="%{$WHITE_BOLD%}☿%{$RESET_COLOR%}" | |
| SVNICON="%{$WHITE_BOLD%}㏜%{$RESET_COLOR%}" | |
| function testok { | |
| RETVAL=$? | |
| if [[ $RETVAL -ne 0 ]]; then | |
| echo -e "${ERRORICON} %{$RED_BOLD%} $RETVAL %{$RESET_COLOR%} " | |
| fi | |
| } | |
| precmd () { | |
| # sets the tab title to current dir | |
| echo -ne "\e]1;${PWD##*/}\a" | |
| # command timer | |
| (( _start >= 0 )) && set -A _elapsed $_elapsed $(( SECONDS-_start )) | |
| _start=-1 | |
| } | |
| preexec () { | |
| (( $#_elapsed > 10 )) && set -A _elapsed $_elapsed[-10,-1] | |
| typeset -ig _start=SECONDS | |
| } | |
| function elapsedtime() { | |
| seconds=${_elapsed[-1]} | |
| if [[ 0 -ne $seconds ]]; then | |
| echo -en "%{$BLUE_BOLD%}${seconds}s%{$RESET_COLOR%}" | |
| fi | |
| } | |
| function gitprompt() { | |
| branch=`git branch -v 2>/dev/null | grep -o "^\*.*" | cut -d ' ' -f 2` | |
| if [[ -n "${branch}" ]]; then | |
| numchanges=`git status -s 2>/dev/null | wc -l | sed 's/\ *//'` | |
| echo -en "${GITICON} %{$GREEN_BOLD%}${branch}%{$RESET_COLOR%} " | |
| if [[ 0 -eq ${numchanges} ]]; then | |
| echo -en "%{$GREEN_BOLD%}${numchanges}%{$RESET_COLOR%} " | |
| else | |
| echo -en "%{$YELLOW%}${numchanges}%{$RESET_COLOR%} " | |
| fi | |
| fi | |
| } | |
| function hgprompt() { | |
| branch=`hg branch 2>/dev/null` | |
| if [[ -n "${branch}" ]]; then | |
| numchanges=`hg status | wc -l | grep -o '\d'` | |
| echo -en "${HGICON} %{$GREEN_BOLD%}${branch}%{$RESET_COLOR%} " | |
| if [[ 0 -eq ${numchanges} ]]; then | |
| echo -en "%{$GREEN_BOLD%}${numchanges}%{$RESET_COLOR%} " | |
| else | |
| echo -en "%{$YELLOW%}${numchanges}%{$RESET_COLOR%} " | |
| fi | |
| fi | |
| } | |
| function svnprompt() { | |
| branch=`svn info 2>/dev/null | egrep '(^Relative URL|^Revision|^Last Changed Rev)' | sed -e 's/Relative URL: .*\///' -e 's/Revision: / @/' -e 's/Last Changed Rev: / ∆/' | tr -d '\n'` | |
| if [[ -n "${branch}" ]]; then | |
| numchanges=`svn status | wc -l | sed 's/\ *//'` | |
| echo -en "${SVNICON} %{$MAGENTA_BOLD%}${branch}%{$RESET_COLOR%} " | |
| if [[ 0 -eq ${numchanges} ]]; then | |
| echo -en "%{$GREEN_BOLD%}${numchanges}%{$RESET_COLOR%} " | |
| else | |
| echo -en "%{$YELLOW%}${numchanges}%{$RESET_COLOR%} " | |
| fi | |
| fi | |
| } | |
| # Prompt format | |
| PROMPT='$(testok)$(elapsedtime) | |
| %{$YELLOW%}${PWD/#$HOME/~}%{$RESET_COLOR%} | |
| %{$BLUE%}${PROMPT_CHARACTER}%{$RESET_COLOR%} ' | |
| RPROMPT='%{$GREEN_BOLD%}$(svnprompt)$(gitprompt)$(hgprompt)%{$RESET_COLOR%}' |
This file contains hidden or 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
| # common globals | |
| export SHELL=/usr/local/bin/zsh | |
| export TMP=/tmp | |
| # setup custom user bin directories | |
| export PATH="$HOME/.bin:$PATH" | |
| export PATH="$PATH:$HOME/.npm-packages/bin" | |
| # setup history | |
| HISTFILE=$HOME/.zsh_history | |
| HISTSIZE=10000 | |
| SAVEHIST=10000 | |
| WORDCHARS='' | |
| # turn on color names | |
| autoload -U colors && colors | |
| # turn on completion | |
| autoload -U compinit | |
| zmodload zsh/complist | |
| compinit -i | |
| compdef mcd=cd | |
| # setup custom tab completion | |
| zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' | |
| zstyle ':completion:*' list-colors '' | |
| zstyle ':completion:*:*:*:*:*' menu select | |
| zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' | |
| zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w" | |
| zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories | |
| zstyle ':completion::complete:*' use-cache 1 | |
| zstyle ':completion::complete:*' cache-path $HOME/.zsh-cache/ | |
| zstyle '*' single-ignored show | |
| zstyle ':completion:*' squeeze-slashes true | |
| zstyle ':completion:*' expand 'yes' | |
| zstyle ':completion:*' insert-tab pending | |
| # man zshmodules | |
| zmodload zsh/mathfunc | |
| zmodload zsh/pcre | |
| # man zshoptions | |
| setopt login | |
| setopt prompt_subst | |
| setopt auto_menu | |
| setopt complete_in_word | |
| unsetopt always_to_end | |
| setopt auto_cd | |
| setopt cdable_vars | |
| setopt auto_name_dirs | |
| setopt auto_pushd | |
| setopt pushd_ignore_dups | |
| setopt pushd_minus | |
| setopt pushd_silent | |
| setopt pushd_to_home | |
| setopt extended_history | |
| setopt hist_expire_dups_first | |
| setopt hist_ignore_dups | |
| setopt hist_ignore_space | |
| setopt hist_verify | |
| setopt inc_append_history_time | |
| unsetopt inc_append_history | |
| unsetopt share_history | |
| setopt monitor | |
| setopt long_list_jobs | |
| setopt check_jobs | |
| unsetopt hup | |
| unsetopt correct_all | |
| unsetopt correct | |
| unsetopt flow_control |
This file contains hidden or 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
| setopt interactive | |
| setopt zle |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment