From 60fcdd4d61188b32dee2b4f6ca676f1cd55fa418 Mon Sep 17 00:00:00 2001 From: Nathan Stilwell Date: Fri, 29 Nov 2013 20:47:01 -0500 Subject: [PATCH] adding zsh stuff back --- custom/corrections.zsh | 10 ++++ custom/plugins/gerrit.plugin.zsh | 86 ++++++++++++++++++++++++++++++++ plugins/gerrit/gerrit.plugin.zsh | 86 ++++++++++++++++++++++++++++++++ themes/nathanstilwell.zsh-theme | 50 +++++++++++++++++++ 4 files changed, 232 insertions(+) create mode 100644 custom/corrections.zsh create mode 100644 custom/plugins/gerrit.plugin.zsh create mode 100644 plugins/gerrit/gerrit.plugin.zsh create mode 100644 themes/nathanstilwell.zsh-theme diff --git a/custom/corrections.zsh b/custom/corrections.zsh new file mode 100644 index 000000000..d0eecaa2c --- /dev/null +++ b/custom/corrections.zsh @@ -0,0 +1,10 @@ +alias node='nocorrect node' +alias ack='nocorrect ack' +alias hg='nocorrect hg' +alias npm='nocorrect npm' +alias figlet="nocorrect figlet" +alias ksdiff="nocorrect ksdiff" +alias scala="nocorrect scala" +alias nodo="nocorrect nodo" +alias grunt="nocorrect grunt" +alias start="nocorrect start" diff --git a/custom/plugins/gerrit.plugin.zsh b/custom/plugins/gerrit.plugin.zsh new file mode 100644 index 000000000..be49be371 --- /dev/null +++ b/custom/plugins/gerrit.plugin.zsh @@ -0,0 +1,86 @@ +function gerrit_usage { + echo + echo " usage: gerrit " + echo + echo " try these :"; + echo " push Push changes without going through a review. "; + echo " pull Pull latest changes and rebase ... or something. "; + echo " review Push changes and submit changes for review"; + echo " setup-reviewers Set current repo to automatically have reviewers from your team"; + echo " add-reviewer Add a reviewer to the repo"; + echo " clone Clone a repo from gerrit, requires repo name"; + echo " setup Add gerrit commit hook to a repo"; + echo +} + +function gerrit_push () { + git push origin HEAD:refs/heads/$1; +} + +function gerrit_review () { + git push origin HEAD:refs/for/$1; +} + +function gerrit_pull () { + #git pull --rebase origin $1; + git fetch; + git rebase origin/$1 +} + +function gerrit_clone () { + if [ -z $1 ]; then + echo "$yellow Please supply the name of a repo to clone. $stop" + else + git clone --recursive ssh://gerrit_host/$1 $2 + #echo "git clone ssh://gerrit_host/$1" + fi +} + +function gerrit_set_team_reviewers () { + git config remote.origin.receivepack 'git receive-pack --reviewer kmcgregor@giltcity.com --reviewer nyusaf@gilt.com'; + if [[ $? -eq 0 ]]; then + echo "$green Reviewers Added. $stop"; + else + echo "$red That failed for some reason. I'm not sure what to do now. $stop"; + fi +} + +function gerrit_add_reviewer { + if [ -z $1 ]; then + echo "$yellow Please specify reviewer. $stop"; + else + echo "$red Please finish me. $stop"; + fi +} + +function gerrit_setup () { + cd .git/hooks; + scp gerrit_host:hooks/commit-msg . > /dev/null; + cd - > /dev/null; + + if [[ $? -eq 0 ]]; then + echo "$green Gerrit hook installed. $stop"; + else + echo "$red Couldn't install Gerrit hook. $stop"; + fi +} + +function gerrit () { + + ref=$(git symbolic-ref HEAD 2> /dev/null); + isGitRepo=$? + branch=${ref#refs/heads/}; + + if [ -z $1 ]; then + gerrit_usage; + else + [ $1 = "push" ] && gerrit_push $branch; + [ $1 = "review" ] && gerrit_review $branch; + [ $1 = "pull" ] && gerrit_pull $branch; + [ $1 = "setup-reviewers" ] && gerrit_set_team_reviewers; + [ $1 = "add-reviewer" ] && gerrit_add_reviewer $2; + [ $1 = "clone" ] && gerrit_clone $2; + [ $1 = "setup" ] && gerrit_setup; + fi + +} diff --git a/plugins/gerrit/gerrit.plugin.zsh b/plugins/gerrit/gerrit.plugin.zsh new file mode 100644 index 000000000..be49be371 --- /dev/null +++ b/plugins/gerrit/gerrit.plugin.zsh @@ -0,0 +1,86 @@ +function gerrit_usage { + echo + echo " usage: gerrit " + echo + echo " try these :"; + echo " push Push changes without going through a review. "; + echo " pull Pull latest changes and rebase ... or something. "; + echo " review Push changes and submit changes for review"; + echo " setup-reviewers Set current repo to automatically have reviewers from your team"; + echo " add-reviewer Add a reviewer to the repo"; + echo " clone Clone a repo from gerrit, requires repo name"; + echo " setup Add gerrit commit hook to a repo"; + echo +} + +function gerrit_push () { + git push origin HEAD:refs/heads/$1; +} + +function gerrit_review () { + git push origin HEAD:refs/for/$1; +} + +function gerrit_pull () { + #git pull --rebase origin $1; + git fetch; + git rebase origin/$1 +} + +function gerrit_clone () { + if [ -z $1 ]; then + echo "$yellow Please supply the name of a repo to clone. $stop" + else + git clone --recursive ssh://gerrit_host/$1 $2 + #echo "git clone ssh://gerrit_host/$1" + fi +} + +function gerrit_set_team_reviewers () { + git config remote.origin.receivepack 'git receive-pack --reviewer kmcgregor@giltcity.com --reviewer nyusaf@gilt.com'; + if [[ $? -eq 0 ]]; then + echo "$green Reviewers Added. $stop"; + else + echo "$red That failed for some reason. I'm not sure what to do now. $stop"; + fi +} + +function gerrit_add_reviewer { + if [ -z $1 ]; then + echo "$yellow Please specify reviewer. $stop"; + else + echo "$red Please finish me. $stop"; + fi +} + +function gerrit_setup () { + cd .git/hooks; + scp gerrit_host:hooks/commit-msg . > /dev/null; + cd - > /dev/null; + + if [[ $? -eq 0 ]]; then + echo "$green Gerrit hook installed. $stop"; + else + echo "$red Couldn't install Gerrit hook. $stop"; + fi +} + +function gerrit () { + + ref=$(git symbolic-ref HEAD 2> /dev/null); + isGitRepo=$? + branch=${ref#refs/heads/}; + + if [ -z $1 ]; then + gerrit_usage; + else + [ $1 = "push" ] && gerrit_push $branch; + [ $1 = "review" ] && gerrit_review $branch; + [ $1 = "pull" ] && gerrit_pull $branch; + [ $1 = "setup-reviewers" ] && gerrit_set_team_reviewers; + [ $1 = "add-reviewer" ] && gerrit_add_reviewer $2; + [ $1 = "clone" ] && gerrit_clone $2; + [ $1 = "setup" ] && gerrit_setup; + fi + +} diff --git a/themes/nathanstilwell.zsh-theme b/themes/nathanstilwell.zsh-theme new file mode 100644 index 000000000..0e2ac353b --- /dev/null +++ b/themes/nathanstilwell.zsh-theme @@ -0,0 +1,50 @@ +# +# Available Color Options are : +# +# red, green, blue, cyan, magenta, yellow, white, black +# +# Reference to what stuff in the Prompt is: +# %n = username +# %~ = pwd +# %m = machine name +# + +# $FG[025] - dark blue +# $FG[050] - cyan +# $FG[075] - light blue +# $FG[100] - muddy yellow +# $FG[125] - strawberry +# $FG[145] - white + +PROMPT='%{$fg[green]%}$(collapse_pwd)%{$fg[white]%} $(git_prompt_info)%{$reset_color%} ≫ ' + +ZSH_THEME_GIT_PROMPT_PREFIX="// %{$fg[red]%}" +#ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg[white]%} // %{$reset_color%}" +ZSH_THEME_GIT_PROMPT_SUFFIX="" +ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%} ✼%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%} ⌘" + +# RPROMPT='${return_status}$(git_prompt_status)%{$reset_color%}' + +ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%} +++" +ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[blue]%} ***" +ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%} ---" +ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[magenta]%} ≫≫≫" +ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[yellow]%} ⏀" +ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[magenta]%} ???" + +# +# Convert the home directory to "~" +# (Courtesy of Mr. Steve Losh) +# + +function collapse_pwd { + echo $(pwd | sed -e "s,^$HOME,~,") +} + +# +# Some Special Characters if you want to swap out the prompts +# ----------------------------------------------------------- +# ✰ ✼ ✪ ✙ ♔ ♘ ♜ ♛ ♚ ♞ ♬ ⏀ ⌦ ⌘ ≫ ⇪ ☩ ☀ ☂ ★ ⚓ Ө β δ Σ Ω μ Δ ↪ + +