diff --git a/.gitignore b/.gitignore index 8fdfae286..5de4c7027 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ locals.zsh log/.zsh_history projects.zsh -custom/* -!custom/example -!custom/example.zsh +custom +custom/*.zsh +*.un~ cache + +.DS_Store diff --git a/custom/example/example.plugin.zsh b/custom/example/example.plugin.zsh deleted file mode 100644 index 406f27445..000000000 --- a/custom/example/example.plugin.zsh +++ /dev/null @@ -1,2 +0,0 @@ -# Add your own custom plugins in the custom/plugins directory. Plugins placed -# here will override ones with the same name in the main plugins directory. diff --git a/lib/aliases.zsh b/lib/aliases.zsh deleted file mode 100644 index b47de5bde..000000000 --- a/lib/aliases.zsh +++ /dev/null @@ -1,25 +0,0 @@ -# Push and pop directories on directory stack -alias pu='pushd' -alias po='popd' - -# Basic directory operations -alias ...='cd ../..' -alias -- -='cd -' - -# Super user -alias _='sudo' - -#alias g='grep -in' - -# Show history -alias history='fc -l 1' - -# List direcory contents -alias lsa='ls -lah' -alias l='ls -la' -alias ll='ls -l' -alias sl=ls # often screw this up - -alias afind='ack-grep -il' - -alias x=extract diff --git a/lib/directories.zsh b/lib/directories.zsh index cf884040f..e43d03772 100644 --- a/lib/directories.zsh +++ b/lib/directories.zsh @@ -28,13 +28,6 @@ alias md='mkdir -p' alias rd=rmdir alias d='dirs -v' -# mkdir & cd to it -function mcd() { - mkdir -p "$1" && cd "$1"; -} - -alias d='dirs -v' - # List direcory contents alias l1='tree --dirsfirst -ChFL 1' alias l2='tree --dirsfirst -ChFL 2' @@ -46,3 +39,8 @@ alias ll3='tree --dirsfirst -ChFupDaL 3' alias l='l1' alias ll='ll1' + +# mkdir & cd to it +function mcd() { + mkdir -p "$1" && cd "$1"; +} diff --git a/lib/functions.zsh b/lib/functions.zsh index b29d3e482..14ff8fb15 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -10,11 +10,6 @@ function upgrade_oh_my_zsh() { /bin/sh $ZSH/tools/upgrade.sh } -function take() { - mkdir -p $1 - cd $1 -} - function extract() { unset REMOVE_ARCHIVE diff --git a/lib/git.zsh b/lib/git.zsh index ce4de5598..1deca8715 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -4,12 +4,19 @@ function git_prompt_info() { echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" } -# Checks if working tree is dirty -parse_git_dirty() { - if [[ -n $(git status -s 2> /dev/null) ]]; then - echo "$ZSH_THEME_GIT_PROMPT_DIRTY" - else - echo "$ZSH_THEME_GIT_PROMPT_CLEAN" +parse_git_dirty () { + gitstat=$(git status 2>/dev/null | grep '\(# Untracked\|# Changes\|# Changed but not updated:\)') + + if [[ $(echo ${gitstat} | grep -c "^# Changes to be committed:$") > 0 ]]; then + echo -n "$ZSH_THEME_GIT_PROMPT_DIRTY" + fi + + if [[ $(echo ${gitstat} | grep -c "^\(# Untracked files:\|# Changed but not updated:\)$") > 0 ]]; then + echo -n "$ZSH_THEME_GIT_PROMPT_UNTRACKED" + fi + + if [[ $(echo ${gitstat} | grep -v '^$' | wc -l | tr -d ' ') == 0 ]]; then + echo -n "$ZSH_THEME_GIT_PROMPT_CLEAN" fi } @@ -20,6 +27,15 @@ function git_prompt_ahead() { fi } +# +# Will return the current branch name +# Usage example: git pull origin $(current_branch) +# +function current_branch() { + ref=$(git symbolic-ref HEAD 2> /dev/null) || return + echo ${ref#refs/heads/} +} + # Formats prompt string for current git commit short SHA function git_prompt_short_sha() { SHA=$(git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" diff --git a/lib/key-bindings.zsh b/lib/key-bindings.zsh index 9f28d5761..dbb54086e 100644 --- a/lib/key-bindings.zsh +++ b/lib/key-bindings.zsh @@ -25,21 +25,6 @@ bindkey "^[[3~" delete-char bindkey "^[3;5~" delete-char bindkey "\e[3~" delete-char -# consider emacs keybindings: - -#bindkey -e ## emacs key bindings -# -#bindkey '^[[A' up-line-or-search -#bindkey '^[[B' down-line-or-search -#bindkey '^[^[[C' emacs-forward-word -#bindkey '^[^[[D' emacs-backward-word -# -#bindkey -s '^X^Z' '%-^M' -#bindkey '^[e' expand-cmd-path -#bindkey '^[^I' reverse-menu-complete -#bindkey '^X^N' accept-and-infer-next-history -#bindkey '^W' kill-region -#bindkey '^I' complete-word ## Fix weird sequence that rxvt produces #bindkey -s '^[[Z' '\t' # diff --git a/templates/zshrc.zsh-template b/templates/zshrc.zsh-template index 576d45eaa..6d0c75844 100644 --- a/templates/zshrc.zsh-template +++ b/templates/zshrc.zsh-template @@ -5,7 +5,7 @@ export ZSH=$HOME/.oh-my-zsh # Look in ~/.oh-my-zsh/themes/ # Optionally, if you set this to "random", it'll load a random theme each # time that oh-my-zsh is loaded. -export ZSH_THEME="robbyrussell" +export ZSH_THEME="prose" # Set to this to use case-sensitive completion # export CASE_SENSITIVE="true" diff --git a/themes/prose.zsh-theme b/themes/prose.zsh-theme index 8f7f75943..51c1967d8 100644 --- a/themes/prose.zsh-theme +++ b/themes/prose.zsh-theme @@ -27,3 +27,6 @@ ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}!" ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[green]%}?" ZSH_THEME_GIT_PROMPT_CLEAN="" + +local return_status="%{$fg[red]%}%(?..⏎)%{$reset_color%}" +RPROMPT='${return_status}%{$reset_color%}'