Permalink
Browse files

added func dir

  • Loading branch information...
1 parent b97ffea commit 71b672e11bcbcc3b11c138ca81244214497e6ffd @mattfoster committed Oct 7, 2008
Showing with 62 additions and 0 deletions.
  1. +58 −0 func/prompt_git_setup
  2. +4 −0 install
View
@@ -0,0 +1,58 @@
+# Themable prompt with git support.
+# No twiddly crap - just prompty goodness.
+# Requires zshkit: http://github.com/mattfoster/zshkit/tree/master/06_git
+#
+# Instructions:
+# 1) Put this somewhere
+# 2) Make sure that it's in the fpath:
+# fpath=( $HOME/.zsh/func "$fpath[@]" )
+# 3) Load up the prompt theme extension, and set the prompt:
+# autoload promptinit && promptinit && prompt git
+
+# Prompt setup function
+function prompt_git_setup {
+ unset PS1 PS2 PS3 PS4 PROMPT RPROMPT
+ # Colours accepted as arguments
+ local u_col=${1:-'green'}
+ local h_col=${2:-'green'}
+ local d_col=${3:-'blue'}
+ local n_tru=${4:-'blue'}
+ local n_fal=${5:-'yellow'}
+ # looks like: ee1mpf@eepc-tsar16 ~ $
+ ps1=(
+ "%{$fg_bold[$u_col]%}%n@"
+ "%{$fg_bold[$h_col]%}%m "
+ "%{$fg_bold[$d_col]%}%1~"
+ "%{%(?.$fg_bold[$n_tru].$fg_bold[$n_fal])%} "
+ '`git-prompt`'
+ "%{%(?.$fg_bold[$n_tru].$fg_bold[$n_fal])%}$ "
+ "%{$reset_color%}"
+ )
+ ps2=(
+ "%_ %{$fg_bold[$d_col]%}-> "
+ "%{$reset_color%}"
+ )
+ PS2="${(j::)ps2}"
+ PS1="${(j::)ps1}"
+}
+
+# print information when user runs 'prompt -h git'
+prompt_git_help () {
+ cat <<EOH
+ Git prompt: displays git status right in your prompt.
+ The current branch will be shown coloured
+ * magenta: if dirty.
+ * cyan: if clean
+
+ This prompt is color-scheme-able. You can invoke it thus:
+
+ prompt git [colour1 [colour2 [colour3 [colour4 [colour5]]]]]
+
+ Colours correspond to username, hostname, working dir, and \$ sign
+ for true 'exit' status and false 'exit' status. Defaults are
+ green green blue blue yellow - all bold. For best visual
+ effect, switch off bold chars in your terminal.
+EOH
+}
+
+prompt_git_setup "$@"
View
@@ -4,6 +4,10 @@ if [[ $mydir = . ]]; then
mydir=`pwd`
fi
dest=$HOME
+
+mkdir -p $HOME/.zsh/
+ln -s $mydir/func $HOME/.zsh/func
+
echo My Directory: $mydir
cp $HOME/.zshenv $HOME/.zshenv.pre_zshkit
cp $HOME/.zshrc $HOME/.zshrc.pre_zshkit

0 comments on commit 71b672e

Please sign in to comment.