From 4e513d72b9542b7b5079451e3380b4a98b0b7b56 Mon Sep 17 00:00:00 2001 From: Jim Hester Date: Fri, 2 Nov 2012 11:06:32 -0400 Subject: [PATCH 1/8] Fixes for vi-mode terminal overwriting bugs fixes #387 and https://github.com/robbyrussell/oh-my-zsh/pull/1321#issuecomment-9959540 and other problems of prompt overwriting when people did not realize that it was vi mode causing the problem. Hat tip to sorin ionescu, as I took this code from prezto --- plugins/vi-mode/vi-mode.plugin.zsh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh index d29eb1dda..e23bd3c54 100644 --- a/plugins/vi-mode/vi-mode.plugin.zsh +++ b/plugins/vi-mode/vi-mode.plugin.zsh @@ -1,8 +1,26 @@ -function zle-line-init zle-keymap-select { +# Ensures that $terminfo values are valid and updates editor information when +# the keymap changes. +function zle-keymap-select zle-line-init zle-line-finish { + # The terminal must be in application mode when ZLE is active for $terminfo + # values to be valid. + if (( $+terminfo[smkx] && $+terminfo[rmkx] )); then + case "$0" in + (zle-line-init) + # Enable terminal application mode. + echoti smkx + ;; + (zle-line-finish) + # Disable terminal application mode. + echoti rmkx + ;; + esac + fi zle reset-prompt + zle -R } zle -N zle-line-init +zle -N zle-line-finish zle -N zle-keymap-select #changing mode clobbers the keybinds, so store the keybinds before and execute From 54f199051124cbbbb3e555c681d65f1aa6942856 Mon Sep 17 00:00:00 2001 From: Viktor Gamov Date: Sun, 2 Dec 2012 13:54:24 -0500 Subject: [PATCH 2/8] Update plugins/sublime/sublime.plugin.zsh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updated run sublime on linux with parameters  --- plugins/sublime/sublime.plugin.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/sublime/sublime.plugin.zsh b/plugins/sublime/sublime.plugin.zsh index 171f00ef5..9fee18610 100755 --- a/plugins/sublime/sublime.plugin.zsh +++ b/plugins/sublime/sublime.plugin.zsh @@ -3,10 +3,11 @@ 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 alias st='/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl' fi From b9d5a39098036f4f62b1e88b8c2c045a35582546 Mon Sep 17 00:00:00 2001 From: "J. Randall Hunt" Date: Sun, 2 Dec 2012 16:32:29 -0500 Subject: [PATCH 3/8] use lazy load for virtualenvwrapper Using lazy loading for virtualenvwrapper gives a mariginal speed improvement and doesn't stop workon_cd from working. It has the undesired effect of forcing you to call certain virtualenv commands twice before they work (only once per shell instantiation). --- plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh index a5abb77c3..0ed2565b4 100644 --- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh +++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh @@ -1,4 +1,4 @@ -wrapsource=`which virtualenvwrapper.sh` +wrapsource=`which virtualenvwrapper_lazy.sh` if [[ -f "$wrapsource" ]]; then source $wrapsource @@ -36,5 +36,5 @@ if [[ -f "$wrapsource" ]]; then } fi else - print "zsh virtualenvwrapper plugin: Cannot find virtualenvwrapper.sh. Please install with \`pip install virtualenvwrapper\`." + print "zsh virtualenvwrapper plugin: Cannot find virtualenvwrapper_lazy.sh. Please install with \`pip install virtualenvwrapper\`." fi From 39e5c9a6d7a88feb570f340ca52e87c8ff8cce61 Mon Sep 17 00:00:00 2001 From: Brian Hartvigsen Date: Sun, 2 Dec 2012 22:59:05 -0700 Subject: [PATCH 4/8] Backwards Compatible Jira URLs #1378 Adds support for Rapid Board without breaking backwards compatibility (like #1378) Allows JIRA url to be set in .zshrc, current directory, and/or home directory. --- plugins/jira/jira.plugin.zsh | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 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 } From 80f151e56d7d6d30858acf581141fa84bfd79bc7 Mon Sep 17 00:00:00 2001 From: Brian Hartvigsen Date: Sun, 2 Dec 2012 23:06:11 -0700 Subject: [PATCH 5/8] urltools for Everyone MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #1445 is great, if you use node.  For those that don't this should mean we can find a reasonable fallback. Users can force urltools to use a specific system by setting `URLTOOLS_METHOD` to one of: * `node` * `python` * `ruby` * `php` * `perl` Note that you can't (currently) choose which `perl` sublibrary to use, it will use either `URI::Encode`, `URI::Escape`, or regular expressions in that order of preference. --- plugins/urltools/urltools.plugin.zsh | 31 ++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) 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 From e096e4041f76c70a621df2b02bb67bed88e6bcee Mon Sep 17 00:00:00 2001 From: Andrei Gorgan Date: Mon, 3 Dec 2012 12:03:43 +0200 Subject: [PATCH 6/8] Print last exit status in mortalscumbag prompt --- themes/mortalscumbag.zsh-theme | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/themes/mortalscumbag.zsh-theme b/themes/mortalscumbag.zsh-theme index 7e25b149f..ae3f1c9fc 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[cyan]%}%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]%}" From 98bd19a036c0c702591f456e1081e420ffb17ce0 Mon Sep 17 00:00:00 2001 From: Denis Cornehl Date: Mon, 3 Dec 2012 11:06:31 +0100 Subject: [PATCH 7/8] plugin last-working-dir: create cache-directory if it doesn't exist --- plugins/last-working-dir/last-working-dir.plugin.zsh | 1 + 1 file changed, 1 insertion(+) 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. From 8925cff334f9009a0f27d38922731bbcd82c42cb Mon Sep 17 00:00:00 2001 From: Andrei Gorgan Date: Mon, 3 Dec 2012 12:29:45 +0200 Subject: [PATCH 8/8] Fix prompt color: Change it back to green --- themes/mortalscumbag.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/mortalscumbag.zsh-theme b/themes/mortalscumbag.zsh-theme index ae3f1c9fc..5dbf2e4f6 100644 --- a/themes/mortalscumbag.zsh-theme +++ b/themes/mortalscumbag.zsh-theme @@ -47,7 +47,7 @@ function ssh_connection() { } local ret_status="%(?:%{$fg_bold[green]%}:%{$fg_bold[red]%})%?%{$reset_color%}" -PROMPT=$'\n$(ssh_connection)%{$fg_bold[cyan]%}%n@%m%{$reset_color%}$(my_git_prompt) : %~\n[${ret_status}] %# ' +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]%}"