diff --git a/.gitignore b/.gitignore index f84db6dc2..e173dab09 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ locals.zsh log/.zsh_history projects.zsh +custom custom/*.zsh -!custom/example.zsh \ No newline at end of file +!custom/example.zsh + +.DS_Store diff --git a/lib/directories.zsh b/lib/directories.zsh index 56d7a2316..146a5b069 100644 --- a/lib/directories.zsh +++ b/lib/directories.zsh @@ -4,6 +4,9 @@ setopt auto_pushd setopt pushd_ignore_dups alias ..='cd ..' +alias ...='cd ../..' +alias ....='cd ../../..' +alias .....='cd ../../../..' alias cd..='cd ..' alias cd...='cd ../..' alias cd....='cd ../../..' diff --git a/lib/functions.zsh b/lib/functions.zsh index 74b93f00e..aa974e5c2 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -44,7 +44,7 @@ function tab() { end tell application "Terminal" activate - do script with command "cd \"$PWD\"; $*" in window 1 + do script with command "cd \"$PWD\"; clear; $*" in window 1 end tell EOF } diff --git a/lib/git.zsh b/lib/git.zsh index 629a08b0e..a34140d89 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -5,10 +5,18 @@ function git_prompt_info() { } parse_git_dirty () { - if [[ $((git status 2> /dev/null) | tail -n1) != "nothing to commit (working directory clean)" ]]; then - echo "$ZSH_THEME_GIT_PROMPT_DIRTY" - else - echo "$ZSH_THEME_GIT_PROMPT_CLEAN" + 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} | wc -l | tr -d ' ') == 0 ]]; then + echo -n "$ZSH_THEME_GIT_PROMPT_CLEAN" fi } diff --git a/lib/misc.zsh b/lib/misc.zsh index 4c1743657..bf68182e1 100644 --- a/lib/misc.zsh +++ b/lib/misc.zsh @@ -3,6 +3,7 @@ autoload -U url-quote-magic zle -N self-insert url-quote-magic ## file rename magick +autoload -U zmv bindkey "^[m" copy-prev-shell-word ## jobs diff --git a/lib/python.zsh b/lib/python.zsh new file mode 100644 index 000000000..79c8e151e --- /dev/null +++ b/lib/python.zsh @@ -0,0 +1,3 @@ +function wo() { + [ -f './.venv' ] && workon `cat ./.venv` +} diff --git a/themes/prose.zsh-theme b/themes/prose.zsh-theme new file mode 100644 index 000000000..cab930f87 --- /dev/null +++ b/themes/prose.zsh-theme @@ -0,0 +1,33 @@ +function prompt_char { + git branch >/dev/null 2>/dev/null && echo '±' && return + hg root >/dev/null 2>/dev/null && echo '☿' && return + echo '○' +} + +function battery_charge { + echo `$BAT_CHARGE` 2>/dev/null +} + +function virtualenv_info { + [ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') ' +} + +function hg_prompt_info { + hg prompt --angle-brackets "\ +< on %{$fg[magenta]%}%{$reset_color%}>\ +< at %{$fg[yellow]%}%{$reset_color%}>\ +%{$fg[green]%}%{$reset_color%}< +patches: >" 2>/dev/null +} + +PROMPT=' +%{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[green]%}${PWD/#$HOME/~}%{$reset_color%}$(hg_prompt_info)$(git_prompt_info) +$(virtualenv_info)$(prompt_char) ' + +RPROMPT='$(battery_charge)' + +ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}" +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=""