From 00b21d5ac322178b9b9e397b0b6178a3d7f4e9ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Ho=CC=88ltje?= Date: Wed, 23 Apr 2014 09:41:09 -0400 Subject: [PATCH 1/8] Trust but verify 'scutil' to return ComputerName Apparently, it is possible to set up a Mac such that `scutil --get ComputerName` hasn't been set. This change checks if that fails and falls back to the original mechanism. Closes #2155 Closes #2183 --- oh-my-zsh.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index c217b91bb..8ce29ff38 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -38,9 +38,9 @@ for plugin ($plugins); do done # Figure out the SHORT hostname -if [ -n "$commands[scutil]" ]; then - # OS X - SHORT_HOST=$(scutil --get ComputerName) +if [[ "$OSTYPE" = darwin* ]]; then + # OS X's $HOST changes with dhcp, etc. Use ComputerName if possible. + SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST=${HOST/.*/} else SHORT_HOST=${HOST/.*/} fi From 63bae2aba9c43a70bbb374fc46e287d7bc46cc54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Ho=CC=88ltje?= Date: Wed, 23 Apr 2014 10:13:26 -0400 Subject: [PATCH 2/8] Use $OSTYPE instead of uname to speed things up The $OSTYPE variable is set at ZSH compile time and can be safely used to determine the OS of the system. e.g. darwin (os x) --- plugins/battery/battery.plugin.zsh | 2 +- plugins/bundler/bundler.plugin.zsh | 2 +- plugins/jira/jira.plugin.zsh | 2 +- plugins/node/node.plugin.zsh | 2 +- plugins/rake-fast/rake-fast.plugin.zsh | 2 +- plugins/sublime/sublime.plugin.zsh | 2 +- plugins/web-search/web-search.plugin.zsh | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index 32dd4b624..014bb15dd 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -8,7 +8,7 @@ # Modified to add support for Apple Mac # ########################################### -if [[ $(uname) == "Darwin" ]] ; then +if [[ "$OSTYPE" = darwin* ]] ; then function battery_pct() { local smart_battery_status="$(ioreg -rc "AppleSmartBattery")" diff --git a/plugins/bundler/bundler.plugin.zsh b/plugins/bundler/bundler.plugin.zsh index 617dcde71..ba3d3f623 100644 --- a/plugins/bundler/bundler.plugin.zsh +++ b/plugins/bundler/bundler.plugin.zsh @@ -54,7 +54,7 @@ bundle_install() { if _bundler-installed && _within-bundled-project; then local bundler_version=`bundle version | cut -d' ' -f3` if [[ $bundler_version > '1.4.0' || $bundler_version = '1.4.0' ]]; then - if [[ "$(uname)" == 'Darwin' ]] + if [[ "$OSTYPE" = darwin* ]] then local cores_num="$(sysctl hw.ncpu | awk '{print $2}')" else diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index 3d510e430..e4881151e 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -12,7 +12,7 @@ # jira ABC-123 # Opens an existing issue open_jira_issue () { local open_cmd - if [[ $(uname -s) == 'Darwin' ]]; then + if [[ "$OSTYPE" = darwin* ]]; then open_cmd='open' else open_cmd='xdg-open' diff --git a/plugins/node/node.plugin.zsh b/plugins/node/node.plugin.zsh index 2d78f2b4c..39d8b10d9 100644 --- a/plugins/node/node.plugin.zsh +++ b/plugins/node/node.plugin.zsh @@ -3,7 +3,7 @@ function node-docs { # get the open command local open_cmd - if [[ $(uname -s) == 'Darwin' ]]; then + if [[ "$OSTYPE" = darwin* ]]; then open_cmd='open' else open_cmd='xdg-open' diff --git a/plugins/rake-fast/rake-fast.plugin.zsh b/plugins/rake-fast/rake-fast.plugin.zsh index cb84f69a1..cfc9a079f 100644 --- a/plugins/rake-fast/rake-fast.plugin.zsh +++ b/plugins/rake-fast/rake-fast.plugin.zsh @@ -10,7 +10,7 @@ _rake_refresh () { _rake_does_task_list_need_generating () { if [ ! -f .rake_tasks ]; then return 0; else - if [[ $(uname -s) == 'Darwin' ]]; then + if [[ "$OSTYPE" = darwin* ]]; then accurate=$(stat -f%m .rake_tasks) changed=$(stat -f%m Rakefile) else diff --git a/plugins/sublime/sublime.plugin.zsh b/plugins/sublime/sublime.plugin.zsh index 438f386fb..5acc75cc7 100644 --- a/plugins/sublime/sublime.plugin.zsh +++ b/plugins/sublime/sublime.plugin.zsh @@ -17,7 +17,7 @@ if [[ $('uname') == 'Linux' ]]; then fi done -elif [[ $('uname') == 'Darwin' ]]; then +elif [[ "$OSTYPE" = darwin* ]]; then local _sublime_darwin_paths > /dev/null 2>&1 _sublime_darwin_paths=( "/usr/local/bin/subl" diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh index 8eedb90ee..f056e38e8 100644 --- a/plugins/web-search/web-search.plugin.zsh +++ b/plugins/web-search/web-search.plugin.zsh @@ -4,7 +4,7 @@ function web_search() { # get the open command local open_cmd - if [[ $(uname -s) == 'Darwin' ]]; then + if [[ "$OSTYPE" = darwin* ]]; then open_cmd='open' else open_cmd='xdg-open' From 9c1255d358fa98397ce20370fa3843199c663990 Mon Sep 17 00:00:00 2001 From: Letian Zhang Date: Mon, 1 Sep 2014 09:49:31 +0800 Subject: [PATCH 3/8] fix missing add-zsh-hook in pygmalion.zsh-theme Fix "command not found: add-zsh-hook" since #3053 removes `autoload -U add-zsh-hook` --- themes/pygmalion.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/pygmalion.zsh-theme b/themes/pygmalion.zsh-theme index 654e0fc37..5f5fe7f9a 100644 --- a/themes/pygmalion.zsh-theme +++ b/themes/pygmalion.zsh-theme @@ -12,7 +12,7 @@ prompt_setup_pygmalion(){ base_prompt_nocolor=$(echo "$base_prompt" | perl -pe "s/%\{[^}]+\}//g") post_prompt_nocolor=$(echo "$post_prompt" | perl -pe "s/%\{[^}]+\}//g") - add-zsh-hook precmd prompt_pygmalion_precmd + precmd_functions+=(prompt_pygmalion_precmd) } prompt_pygmalion_precmd(){ From ed6c2c9106cdaf570da6f7a260c41ca1c4b4ed2a Mon Sep 17 00:00:00 2001 From: Philipp Wahala Date: Wed, 3 Sep 2014 11:13:21 +0200 Subject: [PATCH 4/8] Symfony2 plugin use first console found --- plugins/symfony2/symfony2.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/symfony2/symfony2.plugin.zsh b/plugins/symfony2/symfony2.plugin.zsh index c8c102eee..fcb811fa5 100644 --- a/plugins/symfony2/symfony2.plugin.zsh +++ b/plugins/symfony2/symfony2.plugin.zsh @@ -1,7 +1,7 @@ # Symfony2 basic command completion _symfony_console () { - echo "php $(find . -maxdepth 2 -mindepth 1 -name 'console')" + echo "php $(find . -maxdepth 2 -mindepth 1 -name 'console' | head -n 1)" } _symfony2_get_command_list () { From 677d8b1a21c4b1d8cffef4cbfa259797a11f338a Mon Sep 17 00:00:00 2001 From: Philipp Wahala Date: Wed, 3 Sep 2014 11:36:22 +0200 Subject: [PATCH 5/8] Symfony2 plugin look for files only --- plugins/symfony2/symfony2.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/symfony2/symfony2.plugin.zsh b/plugins/symfony2/symfony2.plugin.zsh index fcb811fa5..2783cd387 100644 --- a/plugins/symfony2/symfony2.plugin.zsh +++ b/plugins/symfony2/symfony2.plugin.zsh @@ -1,7 +1,7 @@ # Symfony2 basic command completion _symfony_console () { - echo "php $(find . -maxdepth 2 -mindepth 1 -name 'console' | head -n 1)" + echo "php $(find . -maxdepth 2 -mindepth 1 -name 'console' -type f | head -n 1)" } _symfony2_get_command_list () { From 8d2dd8cc6a530e79ffdf307d444cb15430004efa Mon Sep 17 00:00:00 2001 From: Philipp Wahala Date: Wed, 3 Sep 2014 11:58:52 +0200 Subject: [PATCH 6/8] Symfony2 plugin autocomplete for app/console and bin/console --- plugins/symfony2/symfony2.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/symfony2/symfony2.plugin.zsh b/plugins/symfony2/symfony2.plugin.zsh index 2783cd387..8df22e9ad 100644 --- a/plugins/symfony2/symfony2.plugin.zsh +++ b/plugins/symfony2/symfony2.plugin.zsh @@ -13,6 +13,8 @@ _symfony2 () { } compdef _symfony2 '`_symfony_console`' +compdef _symfony2 'app/console' +compdef _symfony2 'bin/console' compdef _symfony2 sf #Alias From ae901fa0d5163728de3dde787071df0e2fcf47d5 Mon Sep 17 00:00:00 2001 From: Michael Stucki Date: Tue, 11 Jun 2013 13:51:17 +0200 Subject: [PATCH 7/8] Support dynamically defined Vagrant machines --- plugins/vagrant/_vagrant | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/vagrant/_vagrant b/plugins/vagrant/_vagrant index f842b4fbb..0c82acd42 100644 --- a/plugins/vagrant/_vagrant +++ b/plugins/vagrant/_vagrant @@ -57,6 +57,7 @@ __box_list () __vm_list () { _wanted application expl 'command' compadd $(command grep Vagrantfile -oe '^[^#]*\.vm\.define *[:"]\([a-zA-Z0-9_-]\+\)' 2>/dev/null | awk '{print substr($2, 2)}') + _wanted application expl 'command' compadd $(command ls .vagrant/machines/ 2>/dev/null) } __vagrant-box () From 5e2591317810dba5d61f085faaf4e3050f90559c Mon Sep 17 00:00:00 2001 From: Robby Russell Date: Thu, 4 Sep 2014 12:53:43 +0200 Subject: [PATCH 8/8] Revert "Exit early from git plugin if not in git repo." --- plugins/git/git.plugin.zsh | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index bb1978f78..bf7cd1ac9 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -125,14 +125,12 @@ alias gsd='git svn dcommit' # Usage example: git pull origin $(current_branch) # function current_branch() { - if [ ! -d .git ]; then return; fi ref=$(git symbolic-ref HEAD 2> /dev/null) || \ ref=$(git rev-parse --short HEAD 2> /dev/null) || return echo ${ref#refs/heads/} } function current_repository() { - if [ ! -d .git ]; then return; fi ref=$(git symbolic-ref HEAD 2> /dev/null) || \ ref=$(git rev-parse --short HEAD 2> /dev/null) || return echo $(git remote -v | cut -d':' -f 2)