From 39b46f526c83a5d4704bd25eff03c7678230ec78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20M=C3=BCller?= Date: Mon, 29 Apr 2013 09:51:21 +0200 Subject: [PATCH 1/5] eliminated unnecessary cd and failing substitution Changing the working directory in a sub-subshell does not change the working directory of the executing shell. The substitution was broken for me on _all_ my machines, so I started looking into the business. --- tools/upgrade.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tools/upgrade.sh b/tools/upgrade.sh index 0aeebdebf..3624a88e5 100644 --- a/tools/upgrade.sh +++ b/tools/upgrade.sh @@ -1,8 +1,5 @@ -current_path=`pwd` -current_path=${current_path/ /\\ } printf '\033[0;34m%s\033[0m\n' "Upgrading Oh My Zsh" cd "$ZSH" - if git pull origin master then printf '\033[0;32m%s\033[0m\n' ' __ __ ' @@ -17,4 +14,3 @@ else printf '\033[0;31m%s\033[0m\n' 'There was an error updating. Try again later?' fi -cd "$current_path" From 4ff861ee115fdba24033f945dcf3cacea3120074 Mon Sep 17 00:00:00 2001 From: Christopher Roach Date: Sun, 19 May 2013 12:55:10 -0700 Subject: [PATCH 2/5] Adding a fix for the DISABLE_UNTRACKED_FILES_DIRTY option. --- lib/git.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/git.zsh b/lib/git.zsh index 96598cf5f..c4b5b5d62 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -15,12 +15,12 @@ parse_git_dirty() { if [[ $POST_1_7_2_GIT -gt 0 ]]; then SUBMODULE_SYNTAX="--ignore-submodules=dirty" fi - if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" != "true" ]]; then - GIT_STATUS=$(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null | tail -n1) - else + if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then GIT_STATUS=$(git status -s ${SUBMODULE_SYNTAX} -uno 2> /dev/null | tail -n1) + else + GIT_STATUS=$(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null | tail -n1) fi - if [[ -n $(git status -s ${SUBMODULE_SYNTAX} -uno 2> /dev/null) ]]; then + if [[ -n $GIT_STATUS ]]; then echo "$ZSH_THEME_GIT_PROMPT_DIRTY" else echo "$ZSH_THEME_GIT_PROMPT_CLEAN" From 25313814775c08c64dc541fbadceb38c669c541a Mon Sep 17 00:00:00 2001 From: Hong Xu Date: Mon, 20 May 2013 22:18:07 -0700 Subject: [PATCH 3/5] Add web-search plugin. This plugin adds google, bing and yahoo commands to launch the default web browser to do web search: e.g. google oh-my-zsh bing what is zsh --- plugins/web-search/web-search.plugin.zsh | 43 ++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 plugins/web-search/web-search.plugin.zsh diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh new file mode 100644 index 000000000..6b6de2b15 --- /dev/null +++ b/plugins/web-search/web-search.plugin.zsh @@ -0,0 +1,43 @@ +# web_search from terminal + +function web_search() { + + # get the open command + local open_cmd + if [[ $(uname -s) == 'Darwin' ]]; then + open_cmd='open' + else + open_cmd='xdg-open' + fi + + # check whether the search engine is supported + if [[ ! $1 =~ '(google|bing|yahoo)' ]]; + then + echo "Search engine $1 not supported." + return 1 + fi + + local url="http://www.$1.com" + + # no keyword provided, simply open the search engine homepage + if [[ $# -le 1 ]]; then + $open_cmd "$url" + return + fi + + url="${url}/search?q=" + shift # shift out $1 + + while [[ $# -gt 0 ]]; do + url="${url}$1+" + shift + done + + url="${url%?}" # remove the last '+' + + $open_cmd "$url" +} + +alias bing='web_search bing' +alias google='web_search google' +alias yahoo='web_search yahoo' From 69116fa806f5a7405d33cc1f7c66d4c26ad4253b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20M=2E=20Bravo?= Date: Tue, 21 May 2013 14:20:28 -0400 Subject: [PATCH 4/5] Fixed recursion. Git not needed for it to work. Avoid infinite `cd` loops under certain conditions. Try getting `.venv` from the current directory (not necessarily always using git) --- .../virtualenvwrapper.plugin.zsh | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh index 0ed2565b4..35de50874 100644 --- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh +++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh @@ -8,26 +8,36 @@ if [[ -f "$wrapsource" ]]; then # directory name of the project. Virtual environment name can be overridden # by placing a .venv file in the project root with a virtualenv name in it function workon_cwd { - # Check that this is a Git repo - PROJECT_ROOT=`git rev-parse --show-toplevel 2> /dev/null` - if (( $? == 0 )); then + if [ ! $WORKON_CWD ]; then + WORKON_CWD=1 + # Check if this is a Git repo + PROJECT_ROOT=`git rev-parse --show-toplevel 2> /dev/null` + if (( $? != 0 )); then + PROJECT_ROOT="." + fi # Check for virtualenv name override - ENV_NAME=`basename "$PROJECT_ROOT"` if [[ -f "$PROJECT_ROOT/.venv" ]]; then ENV_NAME=`cat "$PROJECT_ROOT/.venv"` + elif [[ "$PROJECT_ROOT" != "." ]]; then + ENV_NAME=`basename "$PROJECT_ROOT"` + else + ENV_NAME="" fi - # Activate the environment only if it is not already active - if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then - if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then - workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME" + if [[ "$ENV_NAME" != "" ]]; then + # Activate the environment only if it is not already active + if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then + if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then + workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME" + fi fi + elif [ $CD_VIRTUAL_ENV ]; then + # We've just left the repo, deactivate the environment + # Note: this only happens if the virtualenv was activated automatically + deactivate && unset CD_VIRTUAL_ENV fi - elif [ $CD_VIRTUAL_ENV ]; then - # We've just left the repo, deactivate the environment - # Note: this only happens if the virtualenv was activated automatically - deactivate && unset CD_VIRTUAL_ENV + unset PROJECT_ROOT + unset WORKON_CWD fi - unset PROJECT_ROOT } # New cd function that does the virtualenv magic From bd38c50241647a1d0b0e2ca49fb1d6b9a2b88806 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Lemieux Date: Mon, 27 May 2013 09:23:14 -0400 Subject: [PATCH 5/5] fix the open command in linux using xdg-open --- plugins/jira/jira.plugin.zsh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index b91f93c95..bea726a54 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -11,6 +11,13 @@ # Usage: jira # opens a new issue # jira ABC-123 # Opens an existing issue open_jira_issue () { + local open_cmd + if [[ $(uname -s) == 'Darwin' ]]; then + open_cmd='open' + else + open_cmd='xdg-open' + fi + if [ -f .jira-url ]; then jira_url=$(cat .jira-url) elif [ -f ~/.jira-url ]; then @@ -28,9 +35,9 @@ open_jira_issue () { else echo "Opening issue #$1" if [[ "x$JIRA_RAPID_BOARD" = "yes" ]]; then - `open $jira_url/issues/$1` + $open_cmd "$jira_url/issues/$1" else - `open $jira_url/browse/$1` + $open_cmd "$jira_url/browse/$1" fi fi }