diff options
-rw-r--r-- | plugins/jira/jira.plugin.zsh | 34 | ||||
-rw-r--r-- | plugins/last-working-dir/last-working-dir.plugin.zsh | 1 | ||||
-rwxr-xr-x | plugins/sublime/sublime.plugin.zsh | 5 | ||||
-rw-r--r-- | plugins/urltools/urltools.plugin.zsh | 31 | ||||
-rw-r--r-- | themes/mortalscumbag.zsh-theme | 3 |
5 files changed, 60 insertions, 14 deletions
diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index de8d10529..b91f93c95 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -1,20 +1,36 @@ # To use: add a .jira-url file in the base of your project +# You can also set JIRA_URL in your .zshrc or put .jira-url in your home directory +# .jira-url in the current directory takes precedence +# +# If you use Rapid Board, set: +#JIRA_RAPID_BOARD="yes" +# in you .zshrc +# # Setup: cd to/my/project # echo "https://name.jira.com" >> .jira-url # Usage: jira # opens a new issue # jira ABC-123 # Opens an existing issue open_jira_issue () { - if [ ! -f .jira-url ]; then - echo "There is no .jira-url file in the current directory..." - return 0; + if [ -f .jira-url ]; then + jira_url=$(cat .jira-url) + elif [ -f ~/.jira-url ]; then + jira_url=$(cat ~/.jira-url) + elif [[ "x$JIRA_URL" != "x" ]]; then + jira_url=$JIRA_URL else - jira_url=$(cat .jira-url); - if [ -z "$1" ]; then - echo "Opening new issue"; - `open $jira_url/secure/CreateIssue!default.jspa`; + echo "JIRA url is not specified anywhere." + return 0 + fi + + if [ -z "$1" ]; then + echo "Opening new issue" + `open $jira_url/secure/CreateIssue!default.jspa` + else + echo "Opening issue #$1" + if [[ "x$JIRA_RAPID_BOARD" = "yes" ]]; then + `open $jira_url/issues/$1` else - echo "Opening issue #$1"; - `open $jira_url/browse/$1`; + `open $jira_url/browse/$1` fi fi } diff --git a/plugins/last-working-dir/last-working-dir.plugin.zsh b/plugins/last-working-dir/last-working-dir.plugin.zsh index 5b3121d11..190bc279d 100644 --- a/plugins/last-working-dir/last-working-dir.plugin.zsh +++ b/plugins/last-working-dir/last-working-dir.plugin.zsh @@ -4,6 +4,7 @@ # Flag indicating if we've previously jumped to last directory. typeset -g ZSH_LAST_WORKING_DIRECTORY +mkdir -p "$ZSH/cache" local cache_file="$ZSH/cache/last-working-dir" # Updates the last directory once directory is changed. diff --git a/plugins/sublime/sublime.plugin.zsh b/plugins/sublime/sublime.plugin.zsh index 9af70e7de..1b2cbcdce 100755 --- a/plugins/sublime/sublime.plugin.zsh +++ b/plugins/sublime/sublime.plugin.zsh @@ -5,10 +5,11 @@ local _sublime_darwin_subl=/Applications/Sublime\ Text\ 2.app/Contents/SharedSup if [[ $('uname') == 'Linux' ]]; then if [ -f '/usr/bin/sublime_text' ]; then - alias st='/usr/bin/sublime_text&' + st_run() { nohup /usr/bin/sublime_text $@ > /dev/null & } else - alias st='/usr/bin/sublime-text&' + st_run() { nohup /usr/bin/sublime-text $@ > /dev/null & } fi +alias st=st_run elif [[ $('uname') == 'Darwin' ]]; then # Check if Sublime is installed in user's home application directory if [[ -a $HOME/${_sublime_darwin_subl} ]]; then diff --git a/plugins/urltools/urltools.plugin.zsh b/plugins/urltools/urltools.plugin.zsh index 3de74ae3d..4ddfff8ce 100644 --- a/plugins/urltools/urltools.plugin.zsh +++ b/plugins/urltools/urltools.plugin.zsh @@ -4,6 +4,33 @@ # Taken from: # http://ruslanspivak.com/2010/06/02/urlencode-and-urldecode-from-a-command-line/ -alias urlencode='node -e "console.log(encodeURIComponent(process.argv[1]))"' +if [[ $(whence $URLTOOLS_METHOD) = "" ]]; then + URLTOOLS_METHOD="" +fi -alias urldecode='node -e "console.log(decodeURIComponent(process.argv[1]))"' +if [[ $(whence node) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xnode" ) ]]; then + alias urlencode='node -e "console.log(encodeURIComponent(process.argv[1]))"' + alias urldecode='node -e "console.log(decodeURIComponent(process.argv[1]))"' +elif [[ $(whence python) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xpython" ) ]]; then + alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"' + alias urldecode='python -c "import sys, urllib as ul; print ul.unquote_plus(sys.argv[1])"' +elif [[ $(whence ruby) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xruby" ) ]]; then + alias urlencode='ruby -r cgi -e "puts CGI.escape(ARGV[0])"' + alias urldecode='ruby -r cgi -e "puts CGI.unescape(ARGV[0])"' +elif [[ $(whence php) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xphp" ) ]]; then + alias urlencode='php -r "echo rawurlencode(\$argv[1]); echo \"\n\";"' + alias urldecode='php -r "echo rawurldecode(\$argv[1]); echo \"\\n\";"' +elif [[ $(whence perl) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xperl" ) ]]; then + if perl -MURI::Encode -e 1&> /dev/null; then + alias urlencode='perl -MURI::Encode -ep "uri_encode($ARGV[0]);"' + alias urldecode='perl -MURI::Encode -ep "uri_decode($ARGV[0]);"' + elif perl -MURI::Escape -e 1 &> /dev/null; then + alias urlencode='perl -MURI::Escape -ep "uri_escape($ARGV[0]);"' + alias urldecode='perl -MURI::Escape -ep "uri_unescape($ARGV[0]);"' + else + alias urlencode="perl -e '\$new=\$ARGV[0]; \$new =~ s/([^A-Za-z0-9])/sprintf(\"%%%02X\", ord(\$1))/seg; print \"\$new\n\";'" + alias urldecode="perl -e '\$new=\$ARGV[0]; \$new =~ s/\%([A-Fa-f0-9]{2})/pack(\"C\", hex(\$1))/seg; print \"\$new\n\";'" + fi +fi + +unset URLTOOLS_METHOD
\ No newline at end of file diff --git a/themes/mortalscumbag.zsh-theme b/themes/mortalscumbag.zsh-theme index 7e25b149f..5dbf2e4f6 100644 --- a/themes/mortalscumbag.zsh-theme +++ b/themes/mortalscumbag.zsh-theme @@ -46,7 +46,8 @@ function ssh_connection() { fi } -PROMPT=$'\n$(ssh_connection)%{$fg_bold[green]%}%n@%m%{$reset_color%}$(my_git_prompt) : %~\n%# ' +local ret_status="%(?:%{$fg_bold[green]%}:%{$fg_bold[red]%})%?%{$reset_color%}" +PROMPT=$'\n$(ssh_connection)%{$fg_bold[green]%}%n@%m%{$reset_color%}$(my_git_prompt) : %~\n[${ret_status}] %# ' ZSH_THEME_PROMPT_RETURNCODE_PREFIX="%{$fg_bold[red]%}" ZSH_THEME_GIT_PROMPT_PREFIX=" $fg[white]‹ %{$fg_bold[yellow]%}" |