From 1246c3e08bfb7d999bac2ae3e9933084cffbc4eb Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Fri, 20 Feb 2015 02:34:54 -0500 Subject: [PATCH 01/66] install.sh: Replace nonstandard "sed -i" with sed + mv commands. Makes portable to systems whose sed lacks "-i", like OpenBSD. --- tools/install.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index bd4c5574..49619936 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -23,14 +23,16 @@ fi echo "\033[0;34mUsing the Oh My Zsh template file and adding it to ~/.zshrc\033[0m" cp $ZSH/templates/zshrc.zsh-template ~/.zshrc -sed -i -e "/^export ZSH=/ c\\ +sed "/^export ZSH=/ c\\ export ZSH=$ZSH -" ~/.zshrc +" ~/.zshrc > ~/.zshrc-omztemp +mv -f ~/.zshrc-omztemp ~/.zshrc echo "\033[0;34mCopying your current PATH and adding it to the end of ~/.zshrc for you.\033[0m" -sed -i -e "/export PATH=/ c\\ +sed "/export PATH=/ c\\ export PATH=\"$PATH\" -" ~/.zshrc +" ~/.zshrc > ~/.zshrc-omztemp +mv -f ~/.zshrc-omztemp ~/.zshrc if [ "$SHELL" != "$(which zsh)" ]; then echo "\033[0;34mTime to change your default shell to zsh!\033[0m" From 10c92cc083203d757a257f8d13731e2556a99246 Mon Sep 17 00:00:00 2001 From: Eubene Sa Date: Thu, 11 Jun 2015 01:09:44 -0700 Subject: [PATCH 02/66] Updates to ember-cli plugin --- plugins/ember-cli/README.md | 31 ++++++++++++-------------- plugins/ember-cli/ember-cli.plugin.zsh | 7 ++---- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/plugins/ember-cli/README.md b/plugins/ember-cli/README.md index d1dedf88..482c347d 100644 --- a/plugins/ember-cli/README.md +++ b/plugins/ember-cli/README.md @@ -1,22 +1,19 @@ -# Ember-cli +# Ember CLI -**Maintainer:** [BilalBudhani](http://www.github.com/BilalBudhani) +**Maintainers:** [BilalBudhani](http://www.github.com/BilalBudhani), [eubenesa](http://www.github.com/eubenesa) -Ember-cli (http://www.ember-cli.com/) +Ember CLI (http://www.ember-cli.com/) ### List of Aliases -alias es='ember serve' -alias ea='ember addon' -alias eb='ember build' -alias ed='ember destroy' -alias eg='ember generate' -alias eh='ember help' -alias ein='ember init' -alias eia='ember install:addon' -alias eib='ember install:bower' -alias ein='ember install:npm' -alias ei='ember install' -alias et='ember test' -alias eu='ember update' -alias ev='ember version' + alias es='ember serve' + alias ea='ember addon' + alias eb='ember build' + alias ed='ember destroy' + alias eg='ember generate' + alias eh='ember help' + alias ein='ember init' + alias ei='ember install' + alias et='ember test' + alias eu='ember update' + alias ev='ember version' diff --git a/plugins/ember-cli/ember-cli.plugin.zsh b/plugins/ember-cli/ember-cli.plugin.zsh index 044a2c04..a0f34682 100644 --- a/plugins/ember-cli/ember-cli.plugin.zsh +++ b/plugins/ember-cli/ember-cli.plugin.zsh @@ -1,5 +1,5 @@ -# Ember ClI -# visit http://www.ember-cli.com/ to view user guid +# Ember CLI +# Visit http://www.ember-cli.com/ to view user guide alias es='ember serve' alias ea='ember addon' @@ -8,9 +8,6 @@ alias ed='ember destroy' alias eg='ember generate' alias eh='ember help' alias ein='ember init' -alias eia='ember install:addon' -alias eib='ember install:bower' -alias ein='ember install:npm' alias ei='ember install' alias et='ember test' alias eu='ember update' From efb04d66a0bc775dfb95f2bbc648935004212d48 Mon Sep 17 00:00:00 2001 From: Zhiye Li Date: Tue, 30 Jun 2015 17:50:01 -0500 Subject: [PATCH 03/66] add git alias `gcam` - git commit -am add git alias `gcam` - `git commit -am` --- plugins/git/git.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index cc6eb103..ea651d12 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -68,6 +68,7 @@ alias gc!='git commit -v --amend' alias gca='git commit -v -a' alias gca!='git commit -v -a --amend' alias gcan!='git commit -v -a -s --no-edit --amend' +alias gcam='git commit -a -m' alias gcb='git checkout -b' alias gcf='git config --list' alias gcl='git clone --recursive' From 2e92ff8ae5e6ddbac5040bb235518a4337aeb983 Mon Sep 17 00:00:00 2001 From: nextgenthemes Date: Thu, 2 Jul 2015 17:33:30 +0200 Subject: [PATCH 04/66] Adds agar = apt-get autoremove Since #3902 lacks the auto-completion I made a PR for this as well. Also fixes some typos. --- plugins/ubuntu/ubuntu.plugin.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/ubuntu/ubuntu.plugin.zsh b/plugins/ubuntu/ubuntu.plugin.zsh index 0211d337..85db3ce1 100644 --- a/plugins/ubuntu/ubuntu.plugin.zsh +++ b/plugins/ubuntu/ubuntu.plugin.zsh @@ -28,6 +28,7 @@ compdef _ppap ppap='sudo ppa-purge' alias ag='sudo apt-get' # age - but without sudo alias aga='sudo apt-get autoclean' # aac +alias agar='sudo apt-get autoremove' alias agb='sudo apt-get build-dep' # abd alias agc='sudo apt-get clean' # adc alias agd='sudo apt-get dselect-upgrade' # ads @@ -41,6 +42,7 @@ alias aguu='sudo apt-get update && sudo apt-get upgrade' #adg compdef _ag ag='sudo apt-get' compdef _aga aga='sudo apt-get autoclean' +compdef _agar agar='sudo apt-get autoremove' compdef _agb agb='sudo apt-get build-dep' compdef _agc agc='sudo apt-get clean' compdef _agd agd='sudo apt-get dselect-upgrade' @@ -65,7 +67,7 @@ alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc' # apt-add-repository with automatic install/upgrade of the desired package # Usage: aar ppa:xxxxxx/xxxxxx [packagename] -# If packagename is not given as 2nd arument the function will ask for it and guess the defaupt by taking +# If packagename is not given as 2nd argument the function will ask for it and guess the default by taking # the part after the / from the ppa name wich is sometimes the right name for the package you want to install aar() { if [ -n "$2" ]; then From b1da3bbc6f5e26cd0b06cd858e696d4f47f340d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Ma=C5=82ek?= Date: Mon, 6 Jul 2015 22:00:53 +0200 Subject: [PATCH 05/66] Adding ability to add JIRA_PREFIX as an env variable (e.g. in .zshrc) and minor refactor to bash curly variable braces --- plugins/jira/jira.plugin.zsh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index ca540c84..a22e1936 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -1,6 +1,7 @@ # 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 +# .jira-url in the current directory takes precedence. The same goes with .jira-prefix +# and JIRA_PREFIX. # # If you use Rapid Board, set: #JIRA_RAPID_BOARD="true" @@ -22,8 +23,8 @@ open_jira_issue () { 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 + elif [[ "${JIRA_URL}" != "" ]]; then + jira_url=${JIRA_URL} else echo "JIRA url is not specified anywhere." return 1 @@ -33,6 +34,8 @@ open_jira_issue () { jira_prefix=$(cat .jira-prefix) elif [ -f ~/.jira-prefix ]; then jira_prefix=$(cat ~/.jira-prefix) + elif [[ "${JIRA_PREFIX}" != "" ]]; then + jira_prefix=${JIRA_PREFIX} else jira_prefix="" fi @@ -51,7 +54,7 @@ open_jira_issue () { echo "Opening issue #$1" fi - if [[ "x$JIRA_RAPID_BOARD" = "xtrue" ]]; then + if [[ "$JIRA_RAPID_BOARD" = "true" ]]; then $open_cmd "$jira_url/issues/$jira_prefix$1$addcomment" else $open_cmd "$jira_url/browse/$jira_prefix$1$addcomment" @@ -61,7 +64,7 @@ open_jira_issue () { jira_name () { if [[ -z "$1" ]]; then - if [[ "x${JIRA_NAME}" != "x" ]]; then + if [[ "${JIRA_NAME}" != "" ]]; then jira_name=${JIRA_NAME} else echo "JIRA_NAME not specified" From 88a30a3e2f3089556fe40c719f4cbed8426a144e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Ma=C5=82ek?= Date: Tue, 7 Jul 2015 18:50:23 +0200 Subject: [PATCH 06/66] Changing string comparison for more zsh-like --- plugins/jira/jira.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index a22e1936..042fcd7a 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -54,7 +54,7 @@ open_jira_issue () { echo "Opening issue #$1" fi - if [[ "$JIRA_RAPID_BOARD" = "true" ]]; then + if [[ "$JIRA_RAPID_BOARD" == "true" ]]; then $open_cmd "$jira_url/issues/$jira_prefix$1$addcomment" else $open_cmd "$jira_url/browse/$jira_prefix$1$addcomment" From 1e99168627eef4c61114cb0572047473b7cb56be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Ma=C5=82ek?= Date: Tue, 7 Jul 2015 19:56:22 +0200 Subject: [PATCH 07/66] Changing indents to be more consistent (2 spaces) --- plugins/jira/jira.plugin.zsh | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index 042fcd7a..769bf236 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -76,24 +76,24 @@ jira_name () { } jira_query () { - verb="$1" - if [[ "${verb}" = "reported" ]]; then - lookup=reporter - preposition=by - elif [[ "${verb}" = "assigned" ]]; then - lookup=assignee - preposition=to - else - echo "not a valid lookup $verb" - return 1 - fi - shift 1 - jira_name $@ - if [[ $? = 1 ]]; then - return 1 - fi - echo "Browsing issues ${verb} ${preposition} ${jira_name}" - $open_cmd "${jira_url}/secure/IssueNavigator.jspa?reset=true&jqlQuery=${lookup}+%3D+%22${jira_name}%22+AND+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC" + verb="$1" + if [[ "${verb}" = "reported" ]]; then + lookup=reporter + preposition=by + elif [[ "${verb}" = "assigned" ]]; then + lookup=assignee + preposition=to + else + echo "not a valid lookup $verb" + return 1 + fi + shift 1 + jira_name $@ + if [[ $? = 1 ]]; then + return 1 + fi + echo "Browsing issues ${verb} ${preposition} ${jira_name}" + $open_cmd "${jira_url}/secure/IssueNavigator.jspa?reset=true&jqlQuery=${lookup}+%3D+%22${jira_name}%22+AND+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC" } alias jira='open_jira_issue' From 37f45eb621b04a1286ac1667b7474111e6e0b4ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Ma=C5=82ek?= Date: Tue, 7 Jul 2015 20:03:58 +0200 Subject: [PATCH 08/66] Making variables local in jira plugin --- plugins/jira/jira.plugin.zsh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index 769bf236..7839e2a8 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -19,6 +19,7 @@ open_jira_issue () { open_cmd='xdg-open' fi + local jira_url if [ -f .jira-url ]; then jira_url=$(cat .jira-url) elif [ -f ~/.jira-url ]; then @@ -30,6 +31,7 @@ open_jira_issue () { return 1 fi + local jira_prefix if [ -f .jira-prefix ]; then jira_prefix=$(cat .jira-prefix) elif [ -f ~/.jira-prefix ]; then @@ -45,7 +47,7 @@ open_jira_issue () { $open_cmd "${jira_url}/secure/CreateIssue!default.jspa" elif [[ "$1" = "assigned" || "$1" = "reported" ]]; then jira_query $@ - else + else local addcomment='' if [[ "$2" == "m" ]]; then addcomment="#add-comment" @@ -53,11 +55,11 @@ open_jira_issue () { else echo "Opening issue #$1" fi - + if [[ "$JIRA_RAPID_BOARD" == "true" ]]; then - $open_cmd "$jira_url/issues/$jira_prefix$1$addcomment" + $open_cmd "$jira_url/issues/$jira_prefix$1$addcomment" else - $open_cmd "$jira_url/browse/$jira_prefix$1$addcomment" + $open_cmd "$jira_url/browse/$jira_prefix$1$addcomment" fi fi } @@ -76,7 +78,11 @@ jira_name () { } jira_query () { + local jira_name + local verb verb="$1" + local lookup + local preposition if [[ "${verb}" = "reported" ]]; then lookup=reporter preposition=by From b1772c5333fcc43610ade75384d9cf87c8ccde61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Ma=C5=82ek?= Date: Tue, 7 Jul 2015 20:07:13 +0200 Subject: [PATCH 09/66] More consistent curly braces variables --- plugins/jira/jira.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index 7839e2a8..566e1f1f 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -57,9 +57,9 @@ open_jira_issue () { fi if [[ "$JIRA_RAPID_BOARD" == "true" ]]; then - $open_cmd "$jira_url/issues/$jira_prefix$1$addcomment" + $open_cmd "${jira_url}/issues/${jira_prefix}${1}${addcomment}" else - $open_cmd "$jira_url/browse/$jira_prefix$1$addcomment" + $open_cmd "${jira_url}/browse/${jira_prefix}${1}${addcomment}" fi fi } From ad4675cb0a8f732abef7b9a2b3df2141afbf79aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Ma=C5=82ek?= Date: Tue, 7 Jul 2015 20:26:00 +0200 Subject: [PATCH 10/66] Concise local variables declarations --- plugins/jira/jira.plugin.zsh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index 566e1f1f..22984549 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -78,11 +78,8 @@ jira_name () { } jira_query () { - local jira_name - local verb - verb="$1" - local lookup - local preposition + local verb="$1" + local jira_name lookup preposition if [[ "${verb}" = "reported" ]]; then lookup=reporter preposition=by From ffe8e5465cdf6b9c1bad34df3f826f34cfbb59f8 Mon Sep 17 00:00:00 2001 From: Paul Robertson Date: Thu, 9 Jul 2015 23:40:35 -0400 Subject: [PATCH 11/66] add '--help' to heroku commands --- plugins/heroku/_heroku | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/heroku/_heroku b/plugins/heroku/_heroku index bb2f7403..fd72e530 100644 --- a/plugins/heroku/_heroku +++ b/plugins/heroku/_heroku @@ -143,5 +143,6 @@ _arguments \ $_command_args \ '(--app)--app[the app name]' \ '(--remote)--remote[the remote name]' \ + '(--help)--help[help about the current command]' \ && return 0 From afa30572f522969e07b0f85f0cf0fe0e32dd8831 Mon Sep 17 00:00:00 2001 From: Andrew Stuart Date: Mon, 13 Jul 2015 13:08:18 -0700 Subject: [PATCH 12/66] Add jira_url_help --- plugins/jira/jira.plugin.zsh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index ca540c84..f624648a 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -25,7 +25,7 @@ open_jira_issue () { elif [[ "x$JIRA_URL" != "x" ]]; then jira_url=$JIRA_URL else - echo "JIRA url is not specified anywhere." + jira_url_help return 1 fi @@ -59,6 +59,16 @@ open_jira_issue () { fi } +jira_url_help() { + cat << EOF +JIRA url is not specified anywhere. +Valid options, in order of preference: + .jira-url file + $HOME/.jira-url file + JIRA_URL environment variable +EOF +} + jira_name () { if [[ -z "$1" ]]; then if [[ "x${JIRA_NAME}" != "x" ]]; then From 7a13a407e92dc6780355f67018bb03da81a73b8f Mon Sep 17 00:00:00 2001 From: Roland Chernov Date: Sat, 18 Jul 2015 21:10:56 +0900 Subject: [PATCH 13/66] Added thefuck plugin https://github.com/nvbn/thefuck --- plugins/thefuck/thefuck.plugin.zsh | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 plugins/thefuck/thefuck.plugin.zsh diff --git a/plugins/thefuck/thefuck.plugin.zsh b/plugins/thefuck/thefuck.plugin.zsh new file mode 100644 index 00000000..81461d48 --- /dev/null +++ b/plugins/thefuck/thefuck.plugin.zsh @@ -0,0 +1,9 @@ +fuck-command-line() { + FUCK=$(thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null) + [ -z $FUCK ] && echo -n -e "\a" && return + BUFFER=$FUCK + zle end-of-line +} +zle -N fuck-command-line +# Defined shortcut keys: [Esc] [Esc] +bindkey "\e\e" fuck-command-line From cd2213a0304e7f0b8fdfbb02be96f57042e2744a Mon Sep 17 00:00:00 2001 From: Roland Chernov Date: Sat, 18 Jul 2015 21:17:51 +0900 Subject: [PATCH 14/66] Thefuck plugin README --- plugins/thefuck/README.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 plugins/thefuck/README.md diff --git a/plugins/thefuck/README.md b/plugins/thefuck/README.md new file mode 100644 index 00000000..981b5513 --- /dev/null +++ b/plugins/thefuck/README.md @@ -0,0 +1,6 @@ +# The Fuck + +[The Fuck](https://github.com/nvbn/thefuck) plugin — magnificent app which corrects your previous console command. + +## Usage +Press `ESC` twice to correct previous console command. From f838b56591691ad999c8ad1202f04f88350e2d73 Mon Sep 17 00:00:00 2001 From: linux_china Date: Sun, 19 Jul 2015 11:44:42 +0800 Subject: [PATCH 15/66] spring boot plugin readme --- plugins/spring/README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 plugins/spring/README.md diff --git a/plugins/spring/README.md b/plugins/spring/README.md new file mode 100644 index 00000000..62bfd801 --- /dev/null +++ b/plugins/spring/README.md @@ -0,0 +1,25 @@ +# Spring Boot oh-my-zsh plugin +oh-my-zsh Spring Boot plugin + +## Spring Boot autocomplete plugin + +- Adds autocomplete options for all spring boot commands. + +## Manual Install + + $ cd ~/.oh-my-zsh/plugins + $ git clone git@github.com:linux-china/oh-my-zsh-spring-boot-plugin.git spring + +Adjust your .zshrc file and add spring to plugins=(...) + +## Tips + +* Install Spring Cloud plugin: spring install org.springframework.cloud:spring-cloud-cli:1.0.2.RELEASE + +## Reference + +* Spring Boot: http://projects.spring.io/spring-boot/ +* Spring Boot CLI: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#cli + +Maintainer : linux_china ([@linux_china](https://twitter.com/linux_china)) + From b4a8cbf6a589a57572832714f0284e487719004a Mon Sep 17 00:00:00 2001 From: linux_china Date: Sun, 19 Jul 2015 11:44:51 +0800 Subject: [PATCH 16/66] spring boot plugin --- plugins/spring/_spring | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 plugins/spring/_spring diff --git a/plugins/spring/_spring b/plugins/spring/_spring new file mode 100644 index 00000000..93f19517 --- /dev/null +++ b/plugins/spring/_spring @@ -0,0 +1,29 @@ +#compdef spring 'spring' +#autoload + +_spring() { + + local cword + let cword=CURRENT-1 + + local hints + hints=() + + local reply + while read -r line; do + reply=`echo "$line" | awk '{printf $1 ":"; for (i=2; i Date: Sun, 19 Jul 2015 12:57:50 +0900 Subject: [PATCH 17/66] Added conflict note (thefuck plugin) --- plugins/thefuck/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/thefuck/README.md b/plugins/thefuck/README.md index 981b5513..a9b7550d 100644 --- a/plugins/thefuck/README.md +++ b/plugins/thefuck/README.md @@ -4,3 +4,6 @@ ## Usage Press `ESC` twice to correct previous console command. + +## Notes +`Esc`-`Esc` key binding conflicts with [sudo](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/sudo) plugin. From 0da9a4be25d0feb968b21645a0654ea499f0cc9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20M=C4=83gheru=C8=99an-Stanciu?= Date: Wed, 6 May 2015 18:40:03 +0200 Subject: [PATCH 18/66] fuck: added a basic plugin for https://github.com/nvbn/thefuck --- plugins/fuck/fuck.plugin.zsh | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 plugins/fuck/fuck.plugin.zsh diff --git a/plugins/fuck/fuck.plugin.zsh b/plugins/fuck/fuck.plugin.zsh new file mode 100644 index 00000000..1a3b474f --- /dev/null +++ b/plugins/fuck/fuck.plugin.zsh @@ -0,0 +1,6 @@ +if [ $commands[thefuck] ]; then + alias fuck='eval $(thefuck $(fc -ln -1 | tail -n 1)); fc -R' + alias FUCK='fuck' +else + echo 'thefuck is not installed, you should "pip install thefuck" first' +fi From 803e5dbb8464088a8d84509077bf6dce9ac26688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20M=C4=83gheru=C8=99an-Stanciu?= Date: Thu, 9 Jul 2015 17:41:43 +0200 Subject: [PATCH 19/66] improved the check for availability --- plugins/fuck/fuck.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/fuck/fuck.plugin.zsh b/plugins/fuck/fuck.plugin.zsh index 1a3b474f..cbf8c09c 100644 --- a/plugins/fuck/fuck.plugin.zsh +++ b/plugins/fuck/fuck.plugin.zsh @@ -1,4 +1,4 @@ -if [ $commands[thefuck] ]; then +if [[ -n $commands[thefuck] ]]; then alias fuck='eval $(thefuck $(fc -ln -1 | tail -n 1)); fc -R' alias FUCK='fuck' else From 8e8a13398e71b969dc39189c0fedcc4733a911df Mon Sep 17 00:00:00 2001 From: Black Roland Date: Wed, 22 Jul 2015 17:20:52 +0900 Subject: [PATCH 20/66] Thefuck: combined with @cristim plugin. Code formating --- plugins/fuck/fuck.plugin.zsh | 6 ------ plugins/thefuck/thefuck.plugin.zsh | 12 ++++++++++-- 2 files changed, 10 insertions(+), 8 deletions(-) delete mode 100644 plugins/fuck/fuck.plugin.zsh diff --git a/plugins/fuck/fuck.plugin.zsh b/plugins/fuck/fuck.plugin.zsh deleted file mode 100644 index cbf8c09c..00000000 --- a/plugins/fuck/fuck.plugin.zsh +++ /dev/null @@ -1,6 +0,0 @@ -if [[ -n $commands[thefuck] ]]; then - alias fuck='eval $(thefuck $(fc -ln -1 | tail -n 1)); fc -R' - alias FUCK='fuck' -else - echo 'thefuck is not installed, you should "pip install thefuck" first' -fi diff --git a/plugins/thefuck/thefuck.plugin.zsh b/plugins/thefuck/thefuck.plugin.zsh index 81461d48..86ec9901 100644 --- a/plugins/thefuck/thefuck.plugin.zsh +++ b/plugins/thefuck/thefuck.plugin.zsh @@ -1,6 +1,14 @@ +if [[ -z $commands[thefuck] ]]; then + echo 'thefuck is not installed, you should "pip install thefuck" first' + return -1 +fi + +alias fuck='eval $(thefuck $(fc -ln -1 | tail -n 1)); fc -R' +alias FUCK='fuck' + fuck-command-line() { - FUCK=$(thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null) - [ -z $FUCK ] && echo -n -e "\a" && return + FUCK="$(thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)" + [[ -z $FUCK ]] && echo -n -e "\a" && return BUFFER=$FUCK zle end-of-line } From 54e27406dcc2fea55432595f9ec01502da8e4468 Mon Sep 17 00:00:00 2001 From: Roland Chernov Date: Thu, 23 Jul 2015 20:10:31 +0900 Subject: [PATCH 21/66] Thefuck: replaced static alias with `eval "$(thefuck-alias)"` --- plugins/thefuck/thefuck.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/thefuck/thefuck.plugin.zsh b/plugins/thefuck/thefuck.plugin.zsh index 86ec9901..10467d33 100644 --- a/plugins/thefuck/thefuck.plugin.zsh +++ b/plugins/thefuck/thefuck.plugin.zsh @@ -3,8 +3,8 @@ if [[ -z $commands[thefuck] ]]; then return -1 fi -alias fuck='eval $(thefuck $(fc -ln -1 | tail -n 1)); fc -R' -alias FUCK='fuck' +# Register alias +eval "$(thefuck-alias)" fuck-command-line() { FUCK="$(thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)" From f534b4b321d5db4b3d42d3e2cf1f2b2af5bd3c64 Mon Sep 17 00:00:00 2001 From: Roland Chernov Date: Thu, 23 Jul 2015 20:54:51 +0900 Subject: [PATCH 22/66] Thefuck: fixed compability with latest version --- plugins/thefuck/thefuck.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/thefuck/thefuck.plugin.zsh b/plugins/thefuck/thefuck.plugin.zsh index 10467d33..739bb0b9 100644 --- a/plugins/thefuck/thefuck.plugin.zsh +++ b/plugins/thefuck/thefuck.plugin.zsh @@ -7,7 +7,7 @@ fi eval "$(thefuck-alias)" fuck-command-line() { - FUCK="$(thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)" + FUCK="$(THEFUCK_REQUIRE_CONFIRMATION=0 thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)" [[ -z $FUCK ]] && echo -n -e "\a" && return BUFFER=$FUCK zle end-of-line From c83575da3fb103af55215835c9e4add2665fbc86 Mon Sep 17 00:00:00 2001 From: Jerry Ling Date: Wed, 29 Jul 2015 20:05:44 +0800 Subject: [PATCH 23/66] Add 'man' plugin. Inspired by sudo. But we have man-preview! --- plugins/man/man.zsh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 plugins/man/man.zsh diff --git a/plugins/man/man.zsh b/plugins/man/man.zsh new file mode 100644 index 00000000..3490b0b6 --- /dev/null +++ b/plugins/man/man.zsh @@ -0,0 +1,27 @@ +# ------------------------------------------------------------------------------ +# Author +# ------ +# +# * Jerry Ling +# +# ------------------------------------------------------------------------------ +# Usgae +# ----- +# +# man will be inserted before the command +# +# ------------------------------------------------------------------------------ + +man-command-line() { + [[ -z $BUFFER ]] && zle up-history + [[ $BUFFER != man\ * ]] && LBUFFER="man $LBUFFER" +} +zle -N man-command-line +# Defined shortcut keys: [Esc]man +bindkey "\e"man man-command-line + + +# ------------------------------------------------------------------------------ +# Also, you might want to use man-preview included in 'osx' plugin +# just substitute "man" in the function with "man-preview" after you included OS X in +# the .zshrc \ No newline at end of file From 2120b2e079dbcc887a13aaf976c04edaf10fb626 Mon Sep 17 00:00:00 2001 From: Andrew Stuart Date: Wed, 29 Jul 2015 13:58:22 -0700 Subject: [PATCH 24/66] Add escaped home --- plugins/jira/jira.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index f624648a..ed1a1f47 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -62,9 +62,9 @@ open_jira_issue () { jira_url_help() { cat << EOF JIRA url is not specified anywhere. -Valid options, in order of preference: +Valid options, in order of precedence: .jira-url file - $HOME/.jira-url file + \$HOME/.jira-url file JIRA_URL environment variable EOF } From a2b574bc9edc4f548ca7eb3a8116004be7252092 Mon Sep 17 00:00:00 2001 From: Matteo Giaccone Date: Thu, 30 Jul 2015 12:32:41 +0100 Subject: [PATCH 25/66] git plugin: make gclean safer, introduce gpristine --- plugins/git/git.plugin.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index cc6eb103..52f8f751 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -71,7 +71,8 @@ alias gcan!='git commit -v -a -s --no-edit --amend' alias gcb='git checkout -b' alias gcf='git config --list' alias gcl='git clone --recursive' -alias gclean='git reset --hard && git clean -dfx' +alias gclean='git clean -fd' +alias gpristine='git reset --hard && git clean -dfx' alias gcm='git checkout master' alias gcmsg='git commit -m' alias gco='git checkout' From fb8c446ea4317c391321a29dc97677bc6fdeb0cf Mon Sep 17 00:00:00 2001 From: Roland Chernov Date: Thu, 30 Jul 2015 21:04:58 +0900 Subject: [PATCH 26/66] Thefuck: fix global variable assignment --- plugins/thefuck/thefuck.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/thefuck/thefuck.plugin.zsh b/plugins/thefuck/thefuck.plugin.zsh index 739bb0b9..8b1746e8 100644 --- a/plugins/thefuck/thefuck.plugin.zsh +++ b/plugins/thefuck/thefuck.plugin.zsh @@ -7,7 +7,7 @@ fi eval "$(thefuck-alias)" fuck-command-line() { - FUCK="$(THEFUCK_REQUIRE_CONFIRMATION=0 thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)" + local FUCK="$(THEFUCK_REQUIRE_CONFIRMATION=0 thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)" [[ -z $FUCK ]] && echo -n -e "\a" && return BUFFER=$FUCK zle end-of-line From c3fbe4d121d9edb8b34bfbe1aad45a1d81e9899e Mon Sep 17 00:00:00 2001 From: Andrew Robertson Date: Wed, 5 Aug 2015 19:51:05 +0100 Subject: [PATCH 27/66] Add support for Docker images from custom registries --- plugins/docker/_docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/docker/_docker b/plugins/docker/_docker index 25f55bec..a82a31ad 100644 --- a/plugins/docker/_docker +++ b/plugins/docker/_docker @@ -27,7 +27,7 @@ __docker_all_containers() { # output a selectable list of all docker images __docker_images() { declare -a img_cmd - img_cmd=($(docker images | awk 'NR>1{print $1}')) + img_cmd=($(docker images | awk 'NR>1{print $1}'| sed 's/:/\\:/g')) _describe 'images' img_cmd } From 58d2f9335d21a30a85d47c820203e00c1f3d5be7 Mon Sep 17 00:00:00 2001 From: Chang Hyun Park Date: Wed, 12 Aug 2015 16:47:37 +0900 Subject: [PATCH 28/66] Check if Zsh is installed prior to installing Oh My Zsh Check if Zsh is installed before installing anything else. New-commers, or people who don't read the disclaimers(ex. me) will go straight to stack overflow if chsh -s returns an error. --- tools/install.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/install.sh b/tools/install.sh index c83a6f23..95173775 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -1,5 +1,12 @@ set -e +CHECK_ZSH_INSTALLED=$(grep /zsh$ /etc/shells | wc -l) +if [ ! $CHECK_ZSH_INSTALLED -ge 1 ]; then + echo "\033[0;33m Zsh is not installed!\033[0m Please install zsh first!" + exit +fi +unset CHECK_ZSH_INSTALLED + if [ ! -n "$ZSH" ]; then ZSH=~/.oh-my-zsh fi From 02383017268004c4873797c16a667389bead1b83 Mon Sep 17 00:00:00 2001 From: LE Manh Cuong Date: Fri, 14 Aug 2015 09:55:46 +0700 Subject: [PATCH 29/66] Emoji plugin - Fix wrong string comparison --- plugins/emoji/emoji-char-definitions.zsh | 9 +++++++++ plugins/emoji/update_emoji.pl | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/emoji/emoji-char-definitions.zsh b/plugins/emoji/emoji-char-definitions.zsh index 7d110603..04693da0 100644 --- a/plugins/emoji/emoji-char-definitions.zsh +++ b/plugins/emoji/emoji-char-definitions.zsh @@ -7,8 +7,12 @@ # $emoji - which maps character names to Unicode characters # $emoji_flags - maps country names to Unicode flag characters using region indicators +# Main emoji typeset -gAH emoji +# National flags typeset -gAH emoji_flags +# Combining modifiers +typeset -gAH emoji_mod emoji[copyright_sign]=$'\U00A9' emoji[registered_sign]=$'\U00AE' @@ -448,10 +452,15 @@ emoji[badminton_racquet_and_shuttlecock]=$'\U1F3F8' emoji[bow_and_arrow]=$'\U1F3F9' emoji[amphora]=$'\U1F3FA' emoji[emoji_modifier_fitzpatrick_type_1_2]=$'\U1F3FB' +emoji_mod[emoji_modifier_fitzpatrick_type_1_2]=$'\U1F3FB' emoji[emoji_modifier_fitzpatrick_type_3]=$'\U1F3FC' +emoji_mod[emoji_modifier_fitzpatrick_type_3]=$'\U1F3FC' emoji[emoji_modifier_fitzpatrick_type_4]=$'\U1F3FD' +emoji_mod[emoji_modifier_fitzpatrick_type_4]=$'\U1F3FD' emoji[emoji_modifier_fitzpatrick_type_5]=$'\U1F3FE' +emoji_mod[emoji_modifier_fitzpatrick_type_5]=$'\U1F3FE' emoji[emoji_modifier_fitzpatrick_type_6]=$'\U1F3FF' +emoji_mod[emoji_modifier_fitzpatrick_type_6]=$'\U1F3FF' emoji[rat]=$'\U1F400' emoji[mouse]=$'\U1F401' emoji[ox]=$'\U1F402' diff --git a/plugins/emoji/update_emoji.pl b/plugins/emoji/update_emoji.pl index d90c6e31..04f3ce8e 100644 --- a/plugins/emoji/update_emoji.pl +++ b/plugins/emoji/update_emoji.pl @@ -88,7 +88,7 @@ typeset -gAH emoji_mod } # Modifiers are included in both the main set and their separate map, # because they have a standalone representation as a color swatch. - if ( $modifier_status == "modifier" ) { + if ( $modifier_status eq "modifier" ) { $outfh->print("emoji_mod[$omz_name]=\$'$zsh_code'\n"); } } else { From d20c111d78f52dfe81bc632532774d3715feb4e3 Mon Sep 17 00:00:00 2001 From: Chayoung You Date: Sat, 15 Aug 2015 15:19:02 +0900 Subject: [PATCH 30/66] rvm plugin: Fix `gems` to work with GNU sed Fix #1579. --- plugins/rvm/rvm.plugin.zsh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/rvm/rvm.plugin.zsh b/plugins/rvm/rvm.plugin.zsh index 234ac164..53e809aa 100644 --- a/plugins/rvm/rvm.plugin.zsh +++ b/plugins/rvm/rvm.plugin.zsh @@ -61,11 +61,11 @@ function gems { local current_ruby=`rvm-prompt i v p` local current_gemset=`rvm-prompt g` - gem list $@ | sed \ - -Ee "s/\([0-9, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \ - -Ee "s|$(echo $rvm_path)|$fg[magenta]\$rvm_path$reset_color|g" \ - -Ee "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \ - -Ee "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g" + gem list $@ | sed -E \ + -e "s/\([0-9, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \ + -e "s|$(echo $rvm_path)|$fg[magenta]\$rvm_path$reset_color|g" \ + -e "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \ + -e "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g" } function _rvm_completion { From daedfcab510b01d566a2dff6bc94a9e91a563a18 Mon Sep 17 00:00:00 2001 From: Gabe Martin-Dempesy Date: Sat, 15 Aug 2015 12:54:46 -0700 Subject: [PATCH 31/66] reduce rbenv plugin load time by 150ms by removing additional brew call --- plugins/rbenv/rbenv.plugin.zsh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/plugins/rbenv/rbenv.plugin.zsh b/plugins/rbenv/rbenv.plugin.zsh index 213e1beb..ef5106f2 100644 --- a/plugins/rbenv/rbenv.plugin.zsh +++ b/plugins/rbenv/rbenv.plugin.zsh @@ -2,14 +2,11 @@ _homebrew-installed() { type brew &> /dev/null } -_rbenv-from-homebrew-installed() { - brew --prefix rbenv &> /dev/null -} - FOUND_RBENV=0 rbenvdirs=("$HOME/.rbenv" "/usr/local/rbenv" "/opt/rbenv" "/usr/local/opt/rbenv") -if _homebrew-installed && _rbenv-from-homebrew-installed ; then - rbenvdirs=($(brew --prefix rbenv) "${rbenvdirs[@]}") +if _homebrew-installed && rbenv_homebrew_path=$(brew --prefix rbenv 2>/dev/null); then + rbenvdirs=($rbenv_homebrew_path "${rbenvdirs[@]}") + unset rbenv_homebrew_path fi for rbenvdir in "${rbenvdirs[@]}" ; do From de47e2df69fd4ac29fd887f5ab593f2f738f982a Mon Sep 17 00:00:00 2001 From: Felix Krause Date: Sun, 16 Aug 2015 19:29:58 +0200 Subject: [PATCH 32/66] Use https instead of http --- tools/upgrade.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/upgrade.sh b/tools/upgrade.sh index 5f0a81f1..e06e4f33 100644 --- a/tools/upgrade.sh +++ b/tools/upgrade.sh @@ -9,7 +9,7 @@ then printf '\033[0;32m%s\033[0m\n' '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ ' printf '\033[0;32m%s\033[0m\n' ' /____/ ' printf '\033[0;34m%s\033[0m\n' 'Hooray! Oh My Zsh has been updated and/or is at the current version.' - printf '\033[0;34m%s\033[1m%s\033[0m\n' 'To keep up on the latest news and updates, follow us on twitter: ' 'http://twitter.com/ohmyzsh' + printf '\033[0;34m%s\033[1m%s\033[0m\n' 'To keep up on the latest news and updates, follow us on twitter: ' 'https://twitter.com/ohmyzsh' printf '\033[0;34m%s\033[1m%s\033[0m\n' 'Get your Oh My Zsh swag at: ' 'http://shop.planetargon.com/' else printf '\033[0;31m%s\033[0m\n' 'There was an error updating. Try again later?' From 88243b846adc61c3e34a60f4c0ae53e3eb8b9e93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sun, 16 Aug 2015 22:26:33 +0200 Subject: [PATCH 33/66] Use right variable name to avoid zero-length array This fixes the typographic error that always assigned an undefined array to `$names`, which made `$list_size` = 0 and triggered a divide by zero error on the next line. --- plugins/emoji/emoji.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/emoji/emoji.plugin.zsh b/plugins/emoji/emoji.plugin.zsh index a98d0b71..adb11bb5 100644 --- a/plugins/emoji/emoji.plugin.zsh +++ b/plugins/emoji/emoji.plugin.zsh @@ -255,7 +255,7 @@ function random_emoji() { if [[ -z "$group" || "$group" == "all" ]]; then names=(${(k)emoji}) else - names=(${=emoji_groups[$group_name]}) + names=(${=emoji_groups[$group]}) fi local list_size=$#names local random_index=$(( ( RANDOM % $list_size ) + 1 )) From c6a5f6efb434fa64f31b40f366e7fecae80758e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sun, 16 Aug 2015 22:30:56 +0200 Subject: [PATCH 34/66] Check that list_size value is not zero before division --- plugins/emoji/emoji.plugin.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/emoji/emoji.plugin.zsh b/plugins/emoji/emoji.plugin.zsh index adb11bb5..f2d169bf 100644 --- a/plugins/emoji/emoji.plugin.zsh +++ b/plugins/emoji/emoji.plugin.zsh @@ -257,7 +257,8 @@ function random_emoji() { else names=(${=emoji_groups[$group]}) fi - local list_size=$#names + local list_size=${#names} + [[ $list_size -eq 0 ]] && return 1 local random_index=$(( ( RANDOM % $list_size ) + 1 )) local name=${names[$random_index]} echo ${emoji[$name]} From 6443626a6beedc1135402e0fdd4646ba1e7ae35a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sat, 1 Aug 2015 18:06:36 +0200 Subject: [PATCH 35/66] Pull in latest version from olivierverdier/zsh-git-prompt --- plugins/git-prompt/git-prompt.plugin.zsh | 95 +++++++++++++---- plugins/git-prompt/gitstatus.py | 125 ++++++++++------------- 2 files changed, 127 insertions(+), 93 deletions(-) diff --git a/plugins/git-prompt/git-prompt.plugin.zsh b/plugins/git-prompt/git-prompt.plugin.zsh index d868a5fe..ccba22dc 100644 --- a/plugins/git-prompt/git-prompt.plugin.zsh +++ b/plugins/git-prompt/git-prompt.plugin.zsh @@ -1,32 +1,34 @@ # ZSH Git Prompt Plugin from: # http://github.com/olivierverdier/zsh-git-prompt -# -export __GIT_PROMPT_DIR=$ZSH/plugins/git-prompt + +export __GIT_PROMPT_DIR=${0:A:h} + +export GIT_PROMPT_EXECUTABLE=${GIT_PROMPT_USE_PYTHON:-"python"} + +# Initialize colors. +autoload -U colors +colors # Allow for functions in the prompt. setopt PROMPT_SUBST -## Enable auto-execution of functions. -typeset -ga preexec_functions -typeset -ga precmd_functions -typeset -ga chpwd_functions +autoload -U add-zsh-hook -# Append git functions needed for prompt. -preexec_functions+='preexec_update_git_vars' -precmd_functions+='precmd_update_git_vars' -chpwd_functions+='chpwd_update_git_vars' +add-zsh-hook chpwd chpwd_update_git_vars +add-zsh-hook preexec preexec_update_git_vars +add-zsh-hook precmd precmd_update_git_vars ## Function definitions function preexec_update_git_vars() { case "$2" in - git*) + git*|hub*|gh*|stg*) __EXECUTED_GIT_COMMAND=1 ;; esac } function precmd_update_git_vars() { - if [ -n "$__EXECUTED_GIT_COMMAND" ]; then + if [ -n "$__EXECUTED_GIT_COMMAND" ] || [ ! -n "$ZSH_THEME_GIT_PROMPT_CACHE" ]; then update_current_git_vars unset __EXECUTED_GIT_COMMAND fi @@ -39,19 +41,68 @@ function chpwd_update_git_vars() { function update_current_git_vars() { unset __CURRENT_GIT_STATUS - local gitstatus="$__GIT_PROMPT_DIR/gitstatus.py" - _GIT_STATUS=`python ${gitstatus}` - __CURRENT_GIT_STATUS=("${(f)_GIT_STATUS}") + if [[ "$GIT_PROMPT_EXECUTABLE" == "python" ]]; then + local gitstatus="$__GIT_PROMPT_DIR/gitstatus.py" + _GIT_STATUS=`python ${gitstatus} 2>/dev/null` + fi + if [[ "$GIT_PROMPT_EXECUTABLE" == "haskell" ]]; then + local gitstatus="$__GIT_PROMPT_DIR/dist/build/gitstatus/gitstatus" + _GIT_STATUS=`${gitstatus}` + fi + __CURRENT_GIT_STATUS=("${(@s: :)_GIT_STATUS}") + GIT_BRANCH=$__CURRENT_GIT_STATUS[1] + GIT_AHEAD=$__CURRENT_GIT_STATUS[2] + GIT_BEHIND=$__CURRENT_GIT_STATUS[3] + GIT_STAGED=$__CURRENT_GIT_STATUS[4] + GIT_CONFLICTS=$__CURRENT_GIT_STATUS[5] + GIT_CHANGED=$__CURRENT_GIT_STATUS[6] + GIT_UNTRACKED=$__CURRENT_GIT_STATUS[7] } -function prompt_git_info() { + +git_super_status() { + precmd_update_git_vars if [ -n "$__CURRENT_GIT_STATUS" ]; then - echo "(%{${fg[red]}%}$__CURRENT_GIT_STATUS[1]%{${fg[default]}%}$__CURRENT_GIT_STATUS[2]%{${fg[magenta]}%}$__CURRENT_GIT_STATUS[3]%{${fg[default]}%})" - fi + STATUS="$ZSH_THEME_GIT_PROMPT_PREFIX$ZSH_THEME_GIT_PROMPT_BRANCH$GIT_BRANCH%{${reset_color}%}" + if [ "$GIT_BEHIND" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_BEHIND$GIT_BEHIND%{${reset_color}%}" + fi + if [ "$GIT_AHEAD" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_AHEAD$GIT_AHEAD%{${reset_color}%}" + fi + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_SEPARATOR" + if [ "$GIT_STAGED" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_STAGED$GIT_STAGED%{${reset_color}%}" + fi + if [ "$GIT_CONFLICTS" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CONFLICTS$GIT_CONFLICTS%{${reset_color}%}" + fi + if [ "$GIT_CHANGED" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CHANGED$GIT_CHANGED%{${reset_color}%}" + fi + if [ "$GIT_UNTRACKED" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED%{${reset_color}%}" + fi + if [ "$GIT_CHANGED" -eq "0" ] && [ "$GIT_CONFLICTS" -eq "0" ] && [ "$GIT_STAGED" -eq "0" ] && [ "$GIT_UNTRACKED" -eq "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CLEAN" + fi + STATUS="$STATUS%{${reset_color}%}$ZSH_THEME_GIT_PROMPT_SUFFIX" + echo "$STATUS" + fi } +# Default values for the appearance of the prompt. Configure at will. +ZSH_THEME_GIT_PROMPT_PREFIX="(" +ZSH_THEME_GIT_PROMPT_SUFFIX=")" +ZSH_THEME_GIT_PROMPT_SEPARATOR="|" +ZSH_THEME_GIT_PROMPT_BRANCH="%{$fg_bold[magenta]%}" +ZSH_THEME_GIT_PROMPT_STAGED="%{$fg[red]%}%{●%G%}" +ZSH_THEME_GIT_PROMPT_CONFLICTS="%{$fg[red]%}%{✖%G%}" +ZSH_THEME_GIT_PROMPT_CHANGED="%{$fg[blue]%}%{✚%G%}" +ZSH_THEME_GIT_PROMPT_BEHIND="%{↓%G%}" +ZSH_THEME_GIT_PROMPT_AHEAD="%{↑%G%}" +ZSH_THEME_GIT_PROMPT_UNTRACKED="%{…%G%}" +ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}%{✔%G%}" + # Set the prompt. -#PROMPT='%B%m%~%b$(prompt_git_info) %# ' -# for a right prompt: -#RPROMPT='%b$(prompt_git_info)' -RPROMPT='$(prompt_git_info)' +RPROMPT='$(git_super_status)' diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py index 25684143..d944fd4e 100644 --- a/plugins/git-prompt/gitstatus.py +++ b/plugins/git-prompt/gitstatus.py @@ -1,82 +1,65 @@ #!/usr/bin/env python -# -*- coding: UTF-8 -*- +from __future__ import print_function + +# change this symbol to whatever you prefer +prehash = ':' + from subprocess import Popen, PIPE -import re -# change those symbols to whatever you prefer -symbols = { - 'ahead of': '↑', - 'behind': '↓', - 'staged': '♦', - 'changed': '‣', - 'untracked': '…', - 'clean': '⚡', - 'unmerged': '≠', - 'sha1': ':' -} +import sys +gitsym = Popen(['git', 'symbolic-ref', 'HEAD'], stdout=PIPE, stderr=PIPE) +branch, error = gitsym.communicate() -output, error = Popen( - ['git', 'status'], stdout=PIPE, stderr=PIPE, universal_newlines=True).communicate() +error_string = error.decode('utf-8') -if error: - import sys - sys.exit(0) -lines = output.splitlines() +if 'fatal: Not a git repository' in error_string: + sys.exit(0) -behead_re = re.compile( - r"^# Your branch is (ahead of|behind) '(.*)' by (\d+) commit") -diverge_re = re.compile(r"^# and have (\d+) and (\d+) different") +branch = branch.decode("utf-8").strip()[11:] -status = '' -staged = re.compile(r'^# Changes to be committed:$', re.MULTILINE) -changed = re.compile(r'^# Changed but not updated:$', re.MULTILINE) -untracked = re.compile(r'^# Untracked files:$', re.MULTILINE) -unmerged = re.compile(r'^# Unmerged paths:$', re.MULTILINE) +res, err = Popen(['git','diff','--name-status'], stdout=PIPE, stderr=PIPE).communicate() +err_string = err.decode('utf-8') +if 'fatal' in err_string: + sys.exit(0) +changed_files = [namestat[0] for namestat in res.decode("utf-8").splitlines()] +staged_files = [namestat[0] for namestat in Popen(['git','diff', '--staged','--name-status'], stdout=PIPE).communicate()[0].splitlines()] +nb_changed = len(changed_files) - changed_files.count('U') +nb_U = staged_files.count('U') +nb_staged = len(staged_files) - nb_U +staged = str(nb_staged) +conflicts = str(nb_U) +changed = str(nb_changed) +nb_untracked = len([0 for status in Popen(['git','status','--porcelain',],stdout=PIPE).communicate()[0].decode("utf-8").splitlines() if status.startswith('??')]) +untracked = str(nb_untracked) +ahead, behind = 0,0 -def execute(*command): - out, err = Popen(stdout=PIPE, stderr=PIPE, *command).communicate() - if not err: - nb = len(out.splitlines()) - else: - nb = '?' - return nb - -if staged.search(output): - nb = execute( - ['git', 'diff', '--staged', '--name-only', '--diff-filter=ACDMRT']) - status += '%s%s' % (symbols['staged'], nb) -if unmerged.search(output): - nb = execute(['git', 'diff', '--staged', '--name-only', '--diff-filter=U']) - status += '%s%s' % (symbols['unmerged'], nb) -if changed.search(output): - nb = execute(['git', 'diff', '--name-only', '--diff-filter=ACDMRT']) - status += '%s%s' % (symbols['changed'], nb) -if untracked.search(output): - status += symbols['untracked'] -if status == '': - status = symbols['clean'] - -remote = '' - -bline = lines[0] -if bline.find('Not currently on any branch') != -1: - branch = symbols['sha1'] + Popen([ - 'git', - 'rev-parse', - '--short', - 'HEAD'], stdout=PIPE).communicate()[0][:-1] +if not branch: # not on any branch + branch = prehash + Popen(['git','rev-parse','--short','HEAD'], stdout=PIPE).communicate()[0].decode("utf-8")[:-1] else: - branch = bline.split(' ')[-1] - bstatusline = lines[1] - match = behead_re.match(bstatusline) - if match: - remote = symbols[match.groups()[0]] - remote += match.groups()[2] - elif lines[2:]: - div_match = diverge_re.match(lines[2]) - if div_match: - remote = "{behind}{1}{ahead of}{0}".format( - *div_match.groups(), **symbols) + remote_name = Popen(['git','config','branch.%s.remote' % branch], stdout=PIPE).communicate()[0].decode("utf-8").strip() + if remote_name: + merge_name = Popen(['git','config','branch.%s.merge' % branch], stdout=PIPE).communicate()[0].decode("utf-8").strip() + if remote_name == '.': # local + remote_ref = merge_name + else: + remote_ref = 'refs/remotes/%s/%s' % (remote_name, merge_name[11:]) + revgit = Popen(['git', 'rev-list', '--left-right', '%s...HEAD' % remote_ref],stdout=PIPE, stderr=PIPE) + revlist = revgit.communicate()[0] + if revgit.poll(): # fallback to local + revlist = Popen(['git', 'rev-list', '--left-right', '%s...HEAD' % merge_name],stdout=PIPE, stderr=PIPE).communicate()[0] + behead = revlist.decode("utf-8").splitlines() + ahead = len([x for x in behead if x[0]=='>']) + behind = len(behead) - ahead + +out = ' '.join([ + branch, + str(ahead), + str(behind), + staged, + conflicts, + changed, + untracked, + ]) +print(out, end='') -print('\n'.join([branch, remote, status])) From 5642014ff1b718df04d803b7b0457b9872b2b4f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sat, 1 Aug 2015 18:13:46 +0200 Subject: [PATCH 36/66] Pull in simplified version from @wkentaro This version uses `git status --porcelain` instead of making multiple calls to `git status`. --- plugins/git-prompt/gitstatus.py | 80 +++++++++++++++++---------------- 1 file changed, 42 insertions(+), 38 deletions(-) diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py index d944fd4e..1065b3cb 100644 --- a/plugins/git-prompt/gitstatus.py +++ b/plugins/git-prompt/gitstatus.py @@ -4,6 +4,7 @@ from __future__ import print_function # change this symbol to whatever you prefer prehash = ':' +import subprocess from subprocess import Popen, PIPE import sys @@ -13,53 +14,56 @@ branch, error = gitsym.communicate() error_string = error.decode('utf-8') if 'fatal: Not a git repository' in error_string: - sys.exit(0) + sys.exit(0) branch = branch.decode("utf-8").strip()[11:] -res, err = Popen(['git','diff','--name-status'], stdout=PIPE, stderr=PIPE).communicate() -err_string = err.decode('utf-8') -if 'fatal' in err_string: - sys.exit(0) -changed_files = [namestat[0] for namestat in res.decode("utf-8").splitlines()] -staged_files = [namestat[0] for namestat in Popen(['git','diff', '--staged','--name-status'], stdout=PIPE).communicate()[0].splitlines()] -nb_changed = len(changed_files) - changed_files.count('U') -nb_U = staged_files.count('U') -nb_staged = len(staged_files) - nb_U -staged = str(nb_staged) -conflicts = str(nb_U) -changed = str(nb_changed) -nb_untracked = len([0 for status in Popen(['git','status','--porcelain',],stdout=PIPE).communicate()[0].decode("utf-8").splitlines() if status.startswith('??')]) -untracked = str(nb_untracked) +# Get git status (staged, change, conflicts and untracked) +try: + res = subprocess.check_output(['git', 'status', '--porcelain']) +except subprocess.CalledProcessError: + sys.exit(0) +status = [(st[0], st[1], st[2:]) for st in res.splitlines()] +untracked, staged, changed, conflicts = [], [], [], [] +for st in status: + if st[0] == '?' and st[1] == '?': + untracked.append(st) + else: + if st[1] == 'M': + changed.append(st) + if st[0] == 'U': + conflicts.append(st) + elif st[0] != ' ': + staged.append(st) ahead, behind = 0,0 if not branch: # not on any branch - branch = prehash + Popen(['git','rev-parse','--short','HEAD'], stdout=PIPE).communicate()[0].decode("utf-8")[:-1] + branch = prehash + Popen(['git','rev-parse','--short','HEAD'], stdout=PIPE).communicate()[0].decode("utf-8")[:-1] else: - remote_name = Popen(['git','config','branch.%s.remote' % branch], stdout=PIPE).communicate()[0].decode("utf-8").strip() - if remote_name: - merge_name = Popen(['git','config','branch.%s.merge' % branch], stdout=PIPE).communicate()[0].decode("utf-8").strip() - if remote_name == '.': # local - remote_ref = merge_name - else: - remote_ref = 'refs/remotes/%s/%s' % (remote_name, merge_name[11:]) - revgit = Popen(['git', 'rev-list', '--left-right', '%s...HEAD' % remote_ref],stdout=PIPE, stderr=PIPE) - revlist = revgit.communicate()[0] - if revgit.poll(): # fallback to local - revlist = Popen(['git', 'rev-list', '--left-right', '%s...HEAD' % merge_name],stdout=PIPE, stderr=PIPE).communicate()[0] - behead = revlist.decode("utf-8").splitlines() - ahead = len([x for x in behead if x[0]=='>']) - behind = len(behead) - ahead + remote_name = Popen(['git','config','branch.%s.remote' % branch], stdout=PIPE).communicate()[0].decode("utf-8").strip() + if remote_name: + merge_name = Popen(['git','config','branch.%s.merge' % branch], stdout=PIPE).communicate()[0].decode("utf-8").strip() + if remote_name == '.': # local + remote_ref = merge_name + else: + remote_ref = 'refs/remotes/%s/%s' % (remote_name, merge_name[11:]) + revgit = Popen(['git', 'rev-list', '--left-right', '%s...HEAD' % remote_ref],stdout=PIPE, stderr=PIPE) + revlist = revgit.communicate()[0] + if revgit.poll(): # fallback to local + revlist = Popen(['git', 'rev-list', '--left-right', '%s...HEAD' % merge_name],stdout=PIPE, stderr=PIPE).communicate()[0] + behead = revlist.decode("utf-8").splitlines() + ahead = len([x for x in behead if x[0]=='>']) + behind = len(behead) - ahead out = ' '.join([ - branch, - str(ahead), - str(behind), - staged, - conflicts, - changed, - untracked, - ]) + branch, + str(ahead), + str(behind), + str(len(staged)), + str(len(conflicts)), + str(len(changed)), + str(len(untracked)), +]) print(out, end='') From 1d133ff11fe187ee7255637d51165013b4e6a738 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sat, 1 Aug 2015 18:26:18 +0200 Subject: [PATCH 37/66] Cleanup the rest of gitstatus.py --- plugins/git-prompt/gitstatus.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py index 1065b3cb..903ad474 100644 --- a/plugins/git-prompt/gitstatus.py +++ b/plugins/git-prompt/gitstatus.py @@ -4,16 +4,13 @@ from __future__ import print_function # change this symbol to whatever you prefer prehash = ':' +import sys import subprocess from subprocess import Popen, PIPE -import sys -gitsym = Popen(['git', 'symbolic-ref', 'HEAD'], stdout=PIPE, stderr=PIPE) -branch, error = gitsym.communicate() +branch, error = Popen(['git', 'symbolic-ref', 'HEAD'], stdout=PIPE, stderr=PIPE).communicate() -error_string = error.decode('utf-8') - -if 'fatal: Not a git repository' in error_string: +if 'fatal: Not a git repository' in error.decode('utf-8'): sys.exit(0) branch = branch.decode("utf-8").strip()[11:] From 6ff53d173b374e5ebbdff141059c71e4e14aa62e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sat, 1 Aug 2015 18:09:20 +0200 Subject: [PATCH 38/66] Cleanup of git-prompt plugin file --- plugins/git-prompt/git-prompt.plugin.zsh | 110 ++++++++++------------- 1 file changed, 47 insertions(+), 63 deletions(-) diff --git a/plugins/git-prompt/git-prompt.plugin.zsh b/plugins/git-prompt/git-prompt.plugin.zsh index ccba22dc..5175bf70 100644 --- a/plugins/git-prompt/git-prompt.plugin.zsh +++ b/plugins/git-prompt/git-prompt.plugin.zsh @@ -1,24 +1,13 @@ # ZSH Git Prompt Plugin from: # http://github.com/olivierverdier/zsh-git-prompt -export __GIT_PROMPT_DIR=${0:A:h} +__GIT_PROMPT_DIR="${0:A:h}" -export GIT_PROMPT_EXECUTABLE=${GIT_PROMPT_USE_PYTHON:-"python"} +## Hook function definitions +function chpwd_update_git_vars() { + update_current_git_vars +} -# Initialize colors. -autoload -U colors -colors - -# Allow for functions in the prompt. -setopt PROMPT_SUBST - -autoload -U add-zsh-hook - -add-zsh-hook chpwd chpwd_update_git_vars -add-zsh-hook preexec preexec_update_git_vars -add-zsh-hook precmd precmd_update_git_vars - -## Function definitions function preexec_update_git_vars() { case "$2" in git*|hub*|gh*|stg*) @@ -34,64 +23,59 @@ function precmd_update_git_vars() { fi } -function chpwd_update_git_vars() { - update_current_git_vars -} +chpwd_functions+=(chpwd_update_git_vars) +precmd_functions+=(precmd_update_git_vars) +preexec_functions+=(preexec_update_git_vars) + +## Function definitions function update_current_git_vars() { unset __CURRENT_GIT_STATUS - if [[ "$GIT_PROMPT_EXECUTABLE" == "python" ]]; then - local gitstatus="$__GIT_PROMPT_DIR/gitstatus.py" - _GIT_STATUS=`python ${gitstatus} 2>/dev/null` - fi - if [[ "$GIT_PROMPT_EXECUTABLE" == "haskell" ]]; then - local gitstatus="$__GIT_PROMPT_DIR/dist/build/gitstatus/gitstatus" - _GIT_STATUS=`${gitstatus}` - fi + local gitstatus="$__GIT_PROMPT_DIR/gitstatus.py" + _GIT_STATUS=$(python ${gitstatus} 2>/dev/null) __CURRENT_GIT_STATUS=("${(@s: :)_GIT_STATUS}") - GIT_BRANCH=$__CURRENT_GIT_STATUS[1] - GIT_AHEAD=$__CURRENT_GIT_STATUS[2] - GIT_BEHIND=$__CURRENT_GIT_STATUS[3] - GIT_STAGED=$__CURRENT_GIT_STATUS[4] - GIT_CONFLICTS=$__CURRENT_GIT_STATUS[5] - GIT_CHANGED=$__CURRENT_GIT_STATUS[6] - GIT_UNTRACKED=$__CURRENT_GIT_STATUS[7] + GIT_BRANCH=$__CURRENT_GIT_STATUS[1] + GIT_AHEAD=$__CURRENT_GIT_STATUS[2] + GIT_BEHIND=$__CURRENT_GIT_STATUS[3] + GIT_STAGED=$__CURRENT_GIT_STATUS[4] + GIT_CONFLICTS=$__CURRENT_GIT_STATUS[5] + GIT_CHANGED=$__CURRENT_GIT_STATUS[6] + GIT_UNTRACKED=$__CURRENT_GIT_STATUS[7] } - git_super_status() { - precmd_update_git_vars + precmd_update_git_vars if [ -n "$__CURRENT_GIT_STATUS" ]; then - STATUS="$ZSH_THEME_GIT_PROMPT_PREFIX$ZSH_THEME_GIT_PROMPT_BRANCH$GIT_BRANCH%{${reset_color}%}" - if [ "$GIT_BEHIND" -ne "0" ]; then - STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_BEHIND$GIT_BEHIND%{${reset_color}%}" - fi - if [ "$GIT_AHEAD" -ne "0" ]; then - STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_AHEAD$GIT_AHEAD%{${reset_color}%}" - fi - STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_SEPARATOR" - if [ "$GIT_STAGED" -ne "0" ]; then - STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_STAGED$GIT_STAGED%{${reset_color}%}" - fi - if [ "$GIT_CONFLICTS" -ne "0" ]; then - STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CONFLICTS$GIT_CONFLICTS%{${reset_color}%}" - fi - if [ "$GIT_CHANGED" -ne "0" ]; then - STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CHANGED$GIT_CHANGED%{${reset_color}%}" - fi - if [ "$GIT_UNTRACKED" -ne "0" ]; then - STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED%{${reset_color}%}" - fi - if [ "$GIT_CHANGED" -eq "0" ] && [ "$GIT_CONFLICTS" -eq "0" ] && [ "$GIT_STAGED" -eq "0" ] && [ "$GIT_UNTRACKED" -eq "0" ]; then - STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CLEAN" - fi - STATUS="$STATUS%{${reset_color}%}$ZSH_THEME_GIT_PROMPT_SUFFIX" - echo "$STATUS" - fi + STATUS="$ZSH_THEME_GIT_PROMPT_PREFIX$ZSH_THEME_GIT_PROMPT_BRANCH$GIT_BRANCH%{${reset_color}%}" + if [ "$GIT_BEHIND" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_BEHIND$GIT_BEHIND%{${reset_color}%}" + fi + if [ "$GIT_AHEAD" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_AHEAD$GIT_AHEAD%{${reset_color}%}" + fi + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_SEPARATOR" + if [ "$GIT_STAGED" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_STAGED$GIT_STAGED%{${reset_color}%}" + fi + if [ "$GIT_CONFLICTS" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CONFLICTS$GIT_CONFLICTS%{${reset_color}%}" + fi + if [ "$GIT_CHANGED" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CHANGED$GIT_CHANGED%{${reset_color}%}" + fi + if [ "$GIT_UNTRACKED" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED%{${reset_color}%}" + fi + if [ "$GIT_CHANGED" -eq "0" ] && [ "$GIT_CONFLICTS" -eq "0" ] && [ "$GIT_STAGED" -eq "0" ] && [ "$GIT_UNTRACKED" -eq "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CLEAN" + fi + STATUS="$STATUS%{${reset_color}%}$ZSH_THEME_GIT_PROMPT_SUFFIX" + echo "$STATUS" + fi } -# Default values for the appearance of the prompt. Configure at will. +# Default values for the appearance of the prompt. ZSH_THEME_GIT_PROMPT_PREFIX="(" ZSH_THEME_GIT_PROMPT_SUFFIX=")" ZSH_THEME_GIT_PROMPT_SEPARATOR="|" From 94007f7db2d47f3e13e4aac878f0e780a479f628 Mon Sep 17 00:00:00 2001 From: Kentaro Wada Date: Sun, 2 Aug 2015 08:50:56 +0900 Subject: [PATCH 39/66] git-prompt: collect all git status information by one cmd This commit uses the `git status --porcelain -b` format to gather the number of ahead and behind commits related to the remote branch. --- plugins/git-prompt/gitstatus.py | 61 +++++++++++++++------------------ 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py index 903ad474..2f02e5fc 100644 --- a/plugins/git-prompt/gitstatus.py +++ b/plugins/git-prompt/gitstatus.py @@ -5,25 +5,40 @@ from __future__ import print_function prehash = ':' import sys -import subprocess from subprocess import Popen, PIPE -branch, error = Popen(['git', 'symbolic-ref', 'HEAD'], stdout=PIPE, stderr=PIPE).communicate() -if 'fatal: Not a git repository' in error.decode('utf-8'): - sys.exit(0) +# `git status --porcelain -b` can collect all information +# branch, remote_branch, untracked, staged, changed, conflicts, ahead, behind +po = Popen(['git', 'status', '--porcelain', '-b'], stdout=PIPE, stderr=PIPE) +stdout, sterr = po.communicate() +if po.returncode != 0: + sys.exit(0) # Not a git repository -branch = branch.decode("utf-8").strip()[11:] - -# Get git status (staged, change, conflicts and untracked) -try: - res = subprocess.check_output(['git', 'status', '--porcelain']) -except subprocess.CalledProcessError: - sys.exit(0) -status = [(st[0], st[1], st[2:]) for st in res.splitlines()] +# collect git status information untracked, staged, changed, conflicts = [], [], [], [] +ahead, behind = 0, 0 +status = [(line[0], line[1], line[2:]) for line in stdout.splitlines()] for st in status: - if st[0] == '?' and st[1] == '?': + if st[0] == '#' and st[1] == '#': + if len(st[2].strip().split('...')) == 1: + branch = st[2].strip() + else: + # current and remote branch info + branch, rest = st[2].strip().split('...') + if len(rest.split(' ')) == 1: + # remote_branch = rest.split(' ')[0] + pass + else: + # ahead or behind + divergence = ' '.join(rest.split(' ')[1:]) + divergence = divergence.lstrip('[').rstrip(']') + for div in divergence.split(', '): + if 'ahead' in div: + ahead = int(div[len('ahead '):].strip()) + elif 'behind' in div: + behind = int(div[len('behind '):].strip()) + elif st[0] == '?' and st[1] == '?': untracked.append(st) else: if st[1] == 'M': @@ -33,26 +48,6 @@ for st in status: elif st[0] != ' ': staged.append(st) -ahead, behind = 0,0 - -if not branch: # not on any branch - branch = prehash + Popen(['git','rev-parse','--short','HEAD'], stdout=PIPE).communicate()[0].decode("utf-8")[:-1] -else: - remote_name = Popen(['git','config','branch.%s.remote' % branch], stdout=PIPE).communicate()[0].decode("utf-8").strip() - if remote_name: - merge_name = Popen(['git','config','branch.%s.merge' % branch], stdout=PIPE).communicate()[0].decode("utf-8").strip() - if remote_name == '.': # local - remote_ref = merge_name - else: - remote_ref = 'refs/remotes/%s/%s' % (remote_name, merge_name[11:]) - revgit = Popen(['git', 'rev-list', '--left-right', '%s...HEAD' % remote_ref],stdout=PIPE, stderr=PIPE) - revlist = revgit.communicate()[0] - if revgit.poll(): # fallback to local - revlist = Popen(['git', 'rev-list', '--left-right', '%s...HEAD' % merge_name],stdout=PIPE, stderr=PIPE).communicate()[0] - behead = revlist.decode("utf-8").splitlines() - ahead = len([x for x in behead if x[0]=='>']) - behind = len(behead) - ahead - out = ' '.join([ branch, str(ahead), From 30bed07e9c9480d1e563d29da5747ce427f58d8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 4 Aug 2015 16:34:03 +0200 Subject: [PATCH 40/66] Parse UTF-8 output from git status --- plugins/git-prompt/gitstatus.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py index 2f02e5fc..8790f3a3 100644 --- a/plugins/git-prompt/gitstatus.py +++ b/plugins/git-prompt/gitstatus.py @@ -18,7 +18,7 @@ if po.returncode != 0: # collect git status information untracked, staged, changed, conflicts = [], [], [], [] ahead, behind = 0, 0 -status = [(line[0], line[1], line[2:]) for line in stdout.splitlines()] +status = [(line[0], line[1], line[2:]) for line in stdout.decode('utf-8').splitlines()] for st in status: if st[0] == '#' and st[1] == '#': if len(st[2].strip().split('...')) == 1: @@ -58,4 +58,3 @@ out = ' '.join([ str(len(untracked)), ]) print(out, end='') - From 45473c3a81410735dac7fe0a1df33ad95fd3f2e5 Mon Sep 17 00:00:00 2001 From: Kentaro Wada Date: Tue, 11 Aug 2015 12:04:51 +0900 Subject: [PATCH 41/66] Fix for initial or detached status branch info --- plugins/git-prompt/gitstatus.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py index 8790f3a3..59feadc3 100644 --- a/plugins/git-prompt/gitstatus.py +++ b/plugins/git-prompt/gitstatus.py @@ -5,6 +5,8 @@ from __future__ import print_function prehash = ':' import sys +import re +import subprocess from subprocess import Popen, PIPE @@ -21,8 +23,13 @@ ahead, behind = 0, 0 status = [(line[0], line[1], line[2:]) for line in stdout.decode('utf-8').splitlines()] for st in status: if st[0] == '#' and st[1] == '#': - if len(st[2].strip().split('...')) == 1: + if re.search('Initial commit on', st[2]): + branch = st[2].split(' ')[-1] + elif len(st[2].strip().split('...')) == 1: branch = st[2].strip() + if branch == 'HEAD (no branch)': + cmd = ['git', 'log', '-1', '--format="%h"'] + branch = subprocess.check_output(cmd).strip().strip('"') else: # current and remote branch info branch, rest = st[2].strip().split('...') From 3c698743fa4265ab2b70b880e12f957792669438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 11 Aug 2015 11:29:05 +0200 Subject: [PATCH 42/66] Clean up gitstatus.py --- plugins/git-prompt/gitstatus.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py index 59feadc3..1beae541 100644 --- a/plugins/git-prompt/gitstatus.py +++ b/plugins/git-prompt/gitstatus.py @@ -1,18 +1,14 @@ #!/usr/bin/env python from __future__ import print_function -# change this symbol to whatever you prefer -prehash = ':' - import sys import re -import subprocess -from subprocess import Popen, PIPE +from subprocess import Popen, PIPE, check_output -# `git status --porcelain -b` can collect all information +# `git status --porcelain --branch` can collect all information # branch, remote_branch, untracked, staged, changed, conflicts, ahead, behind -po = Popen(['git', 'status', '--porcelain', '-b'], stdout=PIPE, stderr=PIPE) +po = Popen(['git', 'status', '--porcelain', '--branch'], stdout=PIPE, stderr=PIPE) stdout, sterr = po.communicate() if po.returncode != 0: sys.exit(0) # Not a git repository @@ -25,11 +21,10 @@ for st in status: if st[0] == '#' and st[1] == '#': if re.search('Initial commit on', st[2]): branch = st[2].split(' ')[-1] + elif re.search('no branch', st[2]): + branch = check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('utf-8').strip() elif len(st[2].strip().split('...')) == 1: branch = st[2].strip() - if branch == 'HEAD (no branch)': - cmd = ['git', 'log', '-1', '--format="%h"'] - branch = subprocess.check_output(cmd).strip().strip('"') else: # current and remote branch info branch, rest = st[2].strip().split('...') From be667a24b0dc6a42a3e5368727366449b09633d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Mon, 17 Aug 2015 01:05:37 +0200 Subject: [PATCH 43/66] Remove obsolete comment --- plugins/emoji/emoji.plugin.zsh | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/emoji/emoji.plugin.zsh b/plugins/emoji/emoji.plugin.zsh index f2d169bf..7876f1c8 100644 --- a/plugins/emoji/emoji.plugin.zsh +++ b/plugins/emoji/emoji.plugin.zsh @@ -76,8 +76,6 @@ emoji_skintone[6]=$'\U1F3FF' # These are stored in a single associative array, $emoji_groups, to avoid cluttering up the global # namespace, and to allow adding additional group definitions at run time. # The keys are the group names, and the values are whitespace-separated lists of emoji character names. -# -# These extra local arrays are used to allow more convenient formatting of the source code. emoji_groups[fruits]=" tomato From c4ba3065a1e9beb76f2f0ac64f3436b5448576b2 Mon Sep 17 00:00:00 2001 From: Kentaro Wada Date: Mon, 17 Aug 2015 18:22:27 +0900 Subject: [PATCH 44/66] Show tag name when detached status if possible --- plugins/git-prompt/gitstatus.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py index 1beae541..a8eb8284 100644 --- a/plugins/git-prompt/gitstatus.py +++ b/plugins/git-prompt/gitstatus.py @@ -3,9 +3,31 @@ from __future__ import print_function import sys import re +import shlex from subprocess import Popen, PIPE, check_output +def get_tagname_or_hash(): + """return tagname if exists else hash""" + cmd = 'git log -1 --format="%h%d"' + output = check_output(shlex.split(cmd)).decode('utf-8').strip() + hash_, tagname = None, None + # get hash + m = re.search('\(.*\)$', output) + if m: + hash_ = output[:m.start()-1] + # get tagname + m = re.search('tag: .*[,\)]', output) + if m: + tagname = 'tags/' + output[m.start()+len('tag: '): m.end()-1] + + if tagname: + return tagname + elif hash_: + return hash_ + return None + + # `git status --porcelain --branch` can collect all information # branch, remote_branch, untracked, staged, changed, conflicts, ahead, behind po = Popen(['git', 'status', '--porcelain', '--branch'], stdout=PIPE, stderr=PIPE) @@ -21,8 +43,8 @@ for st in status: if st[0] == '#' and st[1] == '#': if re.search('Initial commit on', st[2]): branch = st[2].split(' ')[-1] - elif re.search('no branch', st[2]): - branch = check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('utf-8').strip() + elif re.search('no branch', st[2]): # detached status + branch = get_tagname_or_hash() elif len(st[2].strip().split('...')) == 1: branch = st[2].strip() else: From 7cf892ecaa86f064aa3f78b9d5bee3b7db208ca4 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Tue, 18 Aug 2015 04:46:52 -0400 Subject: [PATCH 45/66] Add dashboard support and default-action configuration. Some refactoring. --- plugins/jira/jira.plugin.zsh | 118 ++++++++++++++++++++--------------- 1 file changed, 66 insertions(+), 52 deletions(-) diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index 842dff5c..a10feec3 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -1,61 +1,88 @@ -# 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. The same goes with .jira-prefix -# and JIRA_PREFIX. +# CLI support for JIRA interaction # -# If you use Rapid Board, set: -#JIRA_RAPID_BOARD="true" -# in you .zshrc +# Setup: +# 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 +# A .jira-url in the current directory takes precedence. +# The same goes with .jira-prefix and $JIRA_PREFIX. # -# 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 +# For example: +# cd to/my/project +# echo "https://name.jira.com" >> .jira-url +# +# Variables: +# $JIRA_RAPID_BOARD - set to "true" if you use Rapid Board +# $JIRA_DEFAULT_ACTION - action to do when `jira` is called witn no args +# defaults to "new" +# $JIRA_NAME - Your JIRA username. Used as default for assigned/reported +# $JIRA_PREFIX - Prefix added to issue ID arguments +# +# +# Usage: +# jira # Performs the default action +# jira new # opens a new issue +# jira reported [username] +# jira assigned [username] +# jira dashboard +# jira ABC-123 # Opens an existing issue +# jira ABC-123 m # Opens an existing issue for adding a comment + +: ${JIRA_DEFAULT_ACTION:=new} + +function jira() { + local action=${1:=$JIRA_DEFAULT_ACTION} + + local jira_url jira_prefix + if [[ -f .jira-url ]]; then jira_url=$(cat .jira-url) - elif [ -f ~/.jira-url ]; then + elif [[ -f ~/.jira-url ]]; then jira_url=$(cat ~/.jira-url) - elif [[ "${JIRA_URL}" != "" ]]; then + elif [[ -n "${JIRA_URL}" ]]; then jira_url=${JIRA_URL} else jira_url_help return 1 fi - local jira_prefix - if [ -f .jira-prefix ]; then + if [[ -f .jira-prefix ]]; then jira_prefix=$(cat .jira-prefix) - elif [ -f ~/.jira-prefix ]; then + elif [[ -f ~/.jira-prefix ]]; then jira_prefix=$(cat ~/.jira-prefix) - elif [[ "${JIRA_PREFIX}" != "" ]]; then + elif [[ -n "${JIRA_PREFIX}" ]]; then jira_prefix=${JIRA_PREFIX} else jira_prefix="" fi - if [ -z "$1" ]; then + + if [[ $action == "new" ]]; then echo "Opening new issue" open_command "${jira_url}/secure/CreateIssue!default.jspa" - elif [[ "$1" = "assigned" || "$1" = "reported" ]]; then + elif [[ "$action" == "assigned" || "$action" == "reported" ]]; then jira_query $@ + elif [[ "$action" == "dashboard" ]]; then + echo "Opening dashboard" + open_command "${jira_url}/secure/Dashboard.jspa" else - local addcomment='' + # Anything that doesn't match a special action is considered an issue name + local issue_arg=$action + local issue="${jira_prefix}${issue_arg}" + local url_fragment='' if [[ "$2" == "m" ]]; then - addcomment="#add-comment" - echo "Add comment to issue #$1" + url_fragment="#add-comment" + echo "Add comment to issue #$issue" else - echo "Opening issue #$1" + echo "Opening issue #$issue" fi if [[ "$JIRA_RAPID_BOARD" == "true" ]]; then - open_command "${jira_url}/issues/${jira_prefix}${1}${addcomment}" + open_command "${jira_url}/issues/${issue}${url_fragment}" else - open_command "${jira_url}/browse/${jira_prefix}${1}${addcomment}" + open_command "${jira_url}/browse/${issue}${url_fragment}" fi fi } -jira_url_help() { +function jira_url_help() { cat << EOF JIRA url is not specified anywhere. Valid options, in order of precedence: @@ -65,40 +92,27 @@ Valid options, in order of precedence: EOF } -jira_name () { - if [[ -z "$1" ]]; then - if [[ "${JIRA_NAME}" != "" ]]; then - jira_name=${JIRA_NAME} - else - echo "JIRA_NAME not specified" - return 1 - fi - else - jira_name=$@ - fi -} - -jira_query () { +function jira_query() { local verb="$1" - local jira_name lookup preposition - if [[ "${verb}" = "reported" ]]; then + local jira_name lookup preposition query + if [[ "${verb}" == "reported" ]]; then lookup=reporter preposition=by - elif [[ "${verb}" = "assigned" ]]; then + elif [[ "${verb}" == "assigned" ]]; then lookup=assignee preposition=to else - echo "not a valid lookup $verb" + echo "not a valid lookup: $verb" >&2 return 1 fi - shift 1 - jira_name $@ - if [[ $? = 1 ]]; then + jira_name=${2:=$JIRA_NAME} + if [[ -z $jira_name ]]; then + echo "JIRA_NAME not specified" >&2 return 1 fi + echo "Browsing issues ${verb} ${preposition} ${jira_name}" - open_command "${jira_url}/secure/IssueNavigator.jspa?reset=true&jqlQuery=${lookup}+%3D+%22${jira_name}%22+AND+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC" + query="${lookup}+%3D+%22${jira_name}%22+AND+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC" + open_command "${jira_url}/secure/IssueNavigator.jspa?reset=true&jqlQuery=${query}" } -alias jira='open_jira_issue' - From dc42e8d488d7b7b5285e71947940c7d6fb19355b Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Tue, 18 Aug 2015 05:05:54 -0400 Subject: [PATCH 46/66] jira: add completion --- plugins/jira/_jira | 21 +++++++++++++++++++++ plugins/jira/jira.plugin.zsh | 8 ++++---- 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 plugins/jira/_jira diff --git a/plugins/jira/_jira b/plugins/jira/_jira new file mode 100644 index 00000000..b0ea658e --- /dev/null +++ b/plugins/jira/_jira @@ -0,0 +1,21 @@ +#compdef jira +#autoload + +local -a _1st_arguments +_1st_arguments=( + 'new:create a new issue' + 'dashboard:open the dashboard' + 'reported:search for issues reported by a user' + 'assigned:search for issues assigned to a user' +) + +_arguments -C \ + ':command:->command' \ + '*::options:->options' + +case $state in + (command) + _describe -t commands "jira subcommand" _1st_arguments + return + ;; +esac diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index a10feec3..89559767 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -40,7 +40,7 @@ function jira() { elif [[ -n "${JIRA_URL}" ]]; then jira_url=${JIRA_URL} else - jira_url_help + _jira_url_help return 1 fi @@ -59,7 +59,7 @@ function jira() { echo "Opening new issue" open_command "${jira_url}/secure/CreateIssue!default.jspa" elif [[ "$action" == "assigned" || "$action" == "reported" ]]; then - jira_query $@ + _jira_query $@ elif [[ "$action" == "dashboard" ]]; then echo "Opening dashboard" open_command "${jira_url}/secure/Dashboard.jspa" @@ -82,7 +82,7 @@ function jira() { fi } -function jira_url_help() { +function _jira_url_help() { cat << EOF JIRA url is not specified anywhere. Valid options, in order of precedence: @@ -92,7 +92,7 @@ Valid options, in order of precedence: EOF } -function jira_query() { +function _jira_query() { local verb="$1" local jira_name lookup preposition query if [[ "${verb}" == "reported" ]]; then From a9daea17d89ae2b7d30dc6e184566ca8104e63d2 Mon Sep 17 00:00:00 2001 From: fgibaux Date: Tue, 18 Aug 2015 14:19:40 +0200 Subject: [PATCH 47/66] plugin symfony2 sf2.7 compatibility fix with symfony 2.7 command group titles are listed as commands. this commit prevents it. --- 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 e94280ed..98a2321d 100644 --- a/plugins/symfony2/symfony2.plugin.zsh +++ b/plugins/symfony2/symfony2.plugin.zsh @@ -5,7 +5,7 @@ _symfony_console () { } _symfony2_get_command_list () { - `_symfony_console` --no-ansi | sed "1,/Available commands/d" | awk '/^ ?[a-z]+/ { print $1 }' + `_symfony_console` --no-ansi | sed "1,/Available commands/d" | awk '/^ ?[^ ]+ / { print $1 }' } _symfony2 () { From 1aeebf60a0dd09ba13a08ae0b81d1d44cad7d15c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AB=A0=E6=AD=A3=E4=B8=AD?= Date: Fri, 21 Aug 2015 14:28:03 +0800 Subject: [PATCH 48/66] Update link --- plugins/vundle/vundle.plugin.zsh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/vundle/vundle.plugin.zsh b/plugins/vundle/vundle.plugin.zsh index fa191147..0f071597 100644 --- a/plugins/vundle/vundle.plugin.zsh +++ b/plugins/vundle/vundle.plugin.zsh @@ -1,13 +1,13 @@ function vundle-init () { - if [ ! -d ~/.vim/bundle/vundle/ ] + if [ ! -d ~/.vim/bundle/Vundle.vim/ ] then - mkdir -p ~/.vim/bundle/vundle/ + mkdir -p ~/.vim/bundle/Vundle.vim/ fi - if [ ! -d ~/.vim/bundle/vundle/.git ] && [ ! -f ~/.vim/bundle/vundle/.git ] + if [ ! -d ~/.vim/bundle/Vundle.vim/.git ] && [ ! -f ~/.vim/bundle/Vundle.vim/.git ] then - git clone http://github.com/gmarik/vundle.git ~/.vim/bundle/vundle - echo "\n\tRead about vim configuration for vundle at https://github.com/gmarik/vundle\n" + git clone git://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim + echo "\n\tRead about vim configuration for vundle at https://github.com/VundleVim/Vundle.vim\n" fi } From aaf5c8f43f6eee141b9ea4b85b4e1097db4a1770 Mon Sep 17 00:00:00 2001 From: Philippe Loctaux Date: Fri, 21 Aug 2015 16:05:54 +0200 Subject: [PATCH 49/66] added apt-get autoremove in ubuntu plugin I use that command a lot of times, and there's no shortcut for that. Now it does :) --- plugins/ubuntu/ubuntu.plugin.zsh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/ubuntu/ubuntu.plugin.zsh b/plugins/ubuntu/ubuntu.plugin.zsh index 0211d337..a1a5016c 100644 --- a/plugins/ubuntu/ubuntu.plugin.zsh +++ b/plugins/ubuntu/ubuntu.plugin.zsh @@ -3,6 +3,7 @@ # https://github.com/dbb # https://github.com/Mappleconfusers # Nicolas Jonas nextgenthemes.com +# https://github.com/loctauxphilippe # # Debian, Ubuntu and friends related zsh aliases and functions for zsh @@ -38,6 +39,7 @@ alias agu='sudo apt-get update' # ad alias agud='sudo apt-get update && sudo apt-get dist-upgrade' #adu alias agug='sudo apt-get upgrade' # ag alias aguu='sudo apt-get update && sudo apt-get upgrade' #adg +alias agar='sudo apt-get autoremove' compdef _ag ag='sudo apt-get' compdef _aga aga='sudo apt-get autoclean' @@ -51,6 +53,7 @@ compdef _agu agu='sudo apt-get update' compdef _agud agud='sudo apt-get update && sudo apt-get dist-upgrade' compdef _agug agug='sudo apt-get upgrade' compdef _aguu aguu='sudo apt-get update && sudo apt-get upgrade' +compdef _agar agar='sudo apt-get autoremove' # Remove ALL kernel images and headers EXCEPT the one in use alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) \ From 1bf5c587a5183f111538bf0879fbc75892988b8e Mon Sep 17 00:00:00 2001 From: Hans Chen Date: Tue, 25 Aug 2015 17:05:28 -0400 Subject: [PATCH 50/66] Update autojump plugin for latest brew installation --- plugins/autojump/autojump.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh index 4cf03640..c05c699e 100644 --- a/plugins/autojump/autojump.plugin.zsh +++ b/plugins/autojump/autojump.plugin.zsh @@ -15,7 +15,7 @@ if [ $commands[autojump] ]; then # check if autojump is installed . /usr/local/share/autojump/autojump.zsh elif [ -f /opt/local/etc/profile.d/autojump.zsh ]; then # mac os x with ports . /opt/local/etc/profile.d/autojump.zsh - elif [ $commands[brew] -a -f `brew --prefix`/etc/autojump.zsh ]; then # mac os x with brew - . `brew --prefix`/etc/autojump.zsh + elif [ $commands[brew] -a -f `brew --prefix`/etc/autojump.sh ]; then # mac os x with brew + . `brew --prefix`/etc/autojump.sh fi fi From 8ab1b6d0fd94d150735d170bb246bccd563937ad Mon Sep 17 00:00:00 2001 From: "G. Kay Lee" Date: Wed, 26 Aug 2015 12:04:28 +0800 Subject: [PATCH 51/66] Update README.markdown Fix typo --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index d4d3fdba..183e6774 100644 --- a/README.markdown +++ b/README.markdown @@ -65,7 +65,7 @@ Once you find a theme that you want to use, you will need to edit the `~/.zshrc` ZSH_THEME="robbyrussell" ``` -To use a different theme, simple change the value to match the name of your desired theme. For example: +To use a different theme, simply change the value to match the name of your desired theme. For example: ```shell ZSH_THEME="agnoster" # (this is one of the fancy ones) From a127c4f88e9807c9d5ac58f5424dfc479370c227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Maggioni?= Date: Wed, 26 Aug 2015 10:48:01 +0200 Subject: [PATCH 52/66] 'ip' command compatibility and much quicker external IP detection --- plugins/systemadmin/systemadmin.plugin.zsh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh index 4ae70dfa..f6641b27 100644 --- a/plugins/systemadmin/systemadmin.plugin.zsh +++ b/plugins/systemadmin/systemadmin.plugin.zsh @@ -140,12 +140,16 @@ d0() { # gather external ip address geteip() { - curl http://ifconfig.me + echo "$(curl -s -S http://ipecho.net/plain)" } # determine local IP address getip() { - ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}' + if [ "$(which ip)" != "" ]; then + ip addr | grep "inet " | grep -v '127.0.0.1' | awk '{print $2}' + else + ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}' + fi } # Clear zombie processes From 058bbe4f02be67102871d82de6aa194e6b865cf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Maggioni?= Date: Wed, 26 Aug 2015 10:54:08 +0200 Subject: [PATCH 53/66] General compatibility --- plugins/systemadmin/systemadmin.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh index f6641b27..5618ba8f 100644 --- a/plugins/systemadmin/systemadmin.plugin.zsh +++ b/plugins/systemadmin/systemadmin.plugin.zsh @@ -145,7 +145,7 @@ geteip() { # determine local IP address getip() { - if [ "$(which ip)" != "" ]; then + if [ $(hash | grep '^ip=') ]; then ip addr | grep "inet " | grep -v '127.0.0.1' | awk '{print $2}' else ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}' From 241be2d28b41293f163c4be75bb122975c2eacd9 Mon Sep 17 00:00:00 2001 From: Robin Daugherty Date: Wed, 26 Aug 2015 13:24:59 -0400 Subject: [PATCH 54/66] Fix rand-quote failure when site is unreachable This plugin was designed so that if there is any failure, it will simply call itself recursively. Which means that if you were working offline, if `quote` was called in your `.zshrc`, you would be unable to open a new terminal session. I fixed this by allowing the plugin to output nothing if a quote could not be fetched. --- plugins/rand-quote/rand-quote.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/rand-quote/rand-quote.plugin.zsh b/plugins/rand-quote/rand-quote.plugin.zsh index c3bf6234..3c9722a7 100644 --- a/plugins/rand-quote/rand-quote.plugin.zsh +++ b/plugins/rand-quote/rand-quote.plugin.zsh @@ -18,8 +18,8 @@ if [[ -x `which curl` ]]; then W=$(echo "$Q" | sed -e 's/.*\/quotes\///g' -e 's/<.*//g' -e 's/.*">//g') if [ "$W" -a "$TXT" ]; then echo "${WHO_COLOR}${W}${COLON_COLOR}: ${TEXT_COLOR}“${TXT}”${END_COLOR}" - else - quote + # else + # quote fi } #quote From 96aefd2b98e5a646573a0ad6394f6ca0276facf1 Mon Sep 17 00:00:00 2001 From: Robin Daugherty Date: Wed, 26 Aug 2015 14:12:38 -0400 Subject: [PATCH 55/66] Remove code, not comment it out Gaaah. --- plugins/rand-quote/rand-quote.plugin.zsh | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/rand-quote/rand-quote.plugin.zsh b/plugins/rand-quote/rand-quote.plugin.zsh index 3c9722a7..8f345d9a 100644 --- a/plugins/rand-quote/rand-quote.plugin.zsh +++ b/plugins/rand-quote/rand-quote.plugin.zsh @@ -18,8 +18,6 @@ if [[ -x `which curl` ]]; then W=$(echo "$Q" | sed -e 's/.*\/quotes\///g' -e 's/<.*//g' -e 's/.*">//g') if [ "$W" -a "$TXT" ]; then echo "${WHO_COLOR}${W}${COLON_COLOR}: ${TEXT_COLOR}“${TXT}”${END_COLOR}" - # else - # quote fi } #quote From d923cebdb34c373597d6f11a0e57e4b73f9f53f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Maggioni?= Date: Thu, 27 Aug 2015 11:34:53 +0200 Subject: [PATCH 56/66] Updated with @mcornella suggestions --- plugins/systemadmin/systemadmin.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh index 5618ba8f..8c263335 100644 --- a/plugins/systemadmin/systemadmin.plugin.zsh +++ b/plugins/systemadmin/systemadmin.plugin.zsh @@ -140,12 +140,12 @@ d0() { # gather external ip address geteip() { - echo "$(curl -s -S http://ipecho.net/plain)" + curl -s -S https://icanhazip.com } # determine local IP address getip() { - if [ $(hash | grep '^ip=') ]; then + if (( ${+commands[ip]} )); then ip addr | grep "inet " | grep -v '127.0.0.1' | awk '{print $2}' else ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}' From 0a2c31fb60ab9870f3a2090eba10d0bdbcc9a3b9 Mon Sep 17 00:00:00 2001 From: MoonFruit Date: Fri, 28 Aug 2015 10:46:45 +0800 Subject: [PATCH 57/66] Remove redundant semicolon Remove redundant semicolon to make tab() works better in ITerm 2. --- plugins/osx/osx.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index a6e3a83e..390960fd 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -6,7 +6,7 @@ # ------------------------------------------------------------------------------ function tab() { - local command="cd \\\"$PWD\\\"; clear; " + local command="cd \\\"$PWD\\\"; clear" (( $# > 0 )) && command="${command}; $*" the_app=$( From acf6039ff391cd868814d5df714fb26339f1009b Mon Sep 17 00:00:00 2001 From: cxbig Date: Sat, 29 Aug 2015 01:35:41 +0200 Subject: [PATCH 58/66] improved alias conflict between git flow & git fetch --- plugins/git-flow/git-flow.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/git-flow/git-flow.plugin.zsh b/plugins/git-flow/git-flow.plugin.zsh index 4357c089..444440bc 100644 --- a/plugins/git-flow/git-flow.plugin.zsh +++ b/plugins/git-flow/git-flow.plugin.zsh @@ -21,7 +21,7 @@ # #Alias -alias gf='git flow' +alias gfl='git flow' alias gcd='git checkout develop' alias gch='git checkout hotfix' alias gcr='git checkout release' From 0a80889848ccb3ada94dd2fdb793a01a268f7a16 Mon Sep 17 00:00:00 2001 From: Will Mendes Date: Sat, 29 Aug 2015 11:48:28 -0300 Subject: [PATCH 59/66] Frontend-search: add search in npm website --- plugins/frontend-search/README.md | 2 ++ plugins/frontend-search/_frontend-search.sh | 4 ++++ plugins/frontend-search/frontend-search.plugin.zsh | 7 ++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/frontend-search/README.md b/plugins/frontend-search/README.md index 801d450f..b8e96ea4 100644 --- a/plugins/frontend-search/README.md +++ b/plugins/frontend-search/README.md @@ -43,6 +43,7 @@ The search content are * `reactjs &as_sitesearch=facebook.github.io/react>` * `emberjs ` * `stackoverflow ` +* `npmjs ` ## Aliases ## @@ -69,6 +70,7 @@ There are a few aliases presented as well: * `reactjs` A shorthand for `frontend reactjs` * `emberjs` A shorthand for `frontend emberjs` * `stackoverflow` A shorthand for `frontend stackoverflow` +* `npmjs` A shorthand for `frontend npmjs` ## Author diff --git a/plugins/frontend-search/_frontend-search.sh b/plugins/frontend-search/_frontend-search.sh index 252f2157..b12f829a 100644 --- a/plugins/frontend-search/_frontend-search.sh +++ b/plugins/frontend-search/_frontend-search.sh @@ -37,6 +37,7 @@ function _frontend() { 'reactjs: Search in React website' 'emberjs: Search in Ember website' 'stackoverflow: Search in StackOverflow website' + 'npmjs: Search in NPMJS website' ) _arguments -C \ @@ -110,6 +111,9 @@ function _frontend() { stackoverflow) _describe -t points "Warp points" frontend_points && ret=0 ;; + npmjs) + _describe -t points "Warp points" frontend_points && ret=0 + ;; esac ;; esac diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh index f7485621..e47735a6 100644 --- a/plugins/frontend-search/frontend-search.plugin.zsh +++ b/plugins/frontend-search/frontend-search.plugin.zsh @@ -9,7 +9,7 @@ function frontend() { fi # check whether the search engine is supported - if [[ ! $1 =~ '(jquery|mdn|compass|html5please|caniuse|aurajs|dartlang|qunit|fontello|bootsnipp|cssflow|codepen|unheap|bem|smacss|angularjs|reactjs|emberjs|stackoverflow)' ]]; + if [[ ! $1 =~ '(jquery|mdn|compass|html5please|caniuse|aurajs|dartlang|qunit|fontello|bootsnipp|cssflow|codepen|unheap|bem|smacss|angularjs|reactjs|emberjs|stackoverflow|npmjs)' ]]; then echo "Search valid search content $1 not supported." echo "Valid contents: (formats 'frontend ' or '')" @@ -33,6 +33,7 @@ function frontend() { echo "* reactjs" echo "* emberjs" echo "* stackoverflow" + echo "* npmjs" echo "" return 1 @@ -99,6 +100,9 @@ function frontend() { "stackoverflow") url="${url}stackoverflow.com" url="${url}/search?q=$2" ;; + "npmjs") + url="${url}www.npmjs.com" + url="${url}/search?q=$2" ;; *) echo "INVALID PARAM!" return ;; esac @@ -148,3 +152,4 @@ alias emberjs='frontend emberjs' # search websites alias stackoverflow='frontend stackoverflow' +alias npmjs='frontend npmjs' From 69f098a63cf32fa13556de328971254addaae309 Mon Sep 17 00:00:00 2001 From: Robby Russell Date: Sun, 30 Aug 2015 21:58:52 -0700 Subject: [PATCH 60/66] Mentioning that you can set the theme to 'random' and it'll possibly bake you a pie. --- README.markdown | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.markdown b/README.markdown index 183e6774..a29df81a 100644 --- a/README.markdown +++ b/README.markdown @@ -77,6 +77,14 @@ Open up a new terminal window and your prompt should look something like... In case you did not find a suitable theme for your needs, please have a look at the wiki for [more of them](https://github.com/robbyrussell/oh-my-zsh/wiki/External-themes). +If you're feeling feisty, you can let the computer select one randomly for you each time you open a new terminal window. + + +```shell +ZSH_THEME="random" # (...please let it be pie... please be some pie..) +``` + + ## Advanced Topics If you're the type that likes to get their hands dirty, these sections might resonate. From 022a060ec754f3ed54cb62acc3370310bfe71a50 Mon Sep 17 00:00:00 2001 From: kyleheyne Date: Mon, 31 Aug 2015 17:36:41 -0400 Subject: [PATCH 61/66] thefuck-alias -> thefuck --alias Per warning message. --- plugins/thefuck/thefuck.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/thefuck/thefuck.plugin.zsh b/plugins/thefuck/thefuck.plugin.zsh index 8b1746e8..765e2b9a 100644 --- a/plugins/thefuck/thefuck.plugin.zsh +++ b/plugins/thefuck/thefuck.plugin.zsh @@ -4,7 +4,7 @@ if [[ -z $commands[thefuck] ]]; then fi # Register alias -eval "$(thefuck-alias)" +eval "$(thefuck --alias)" fuck-command-line() { local FUCK="$(THEFUCK_REQUIRE_CONFIRMATION=0 thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)" From f1472f1f6462d391a14ec80157365500f7a11b3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sun, 30 Aug 2015 00:09:15 +0200 Subject: [PATCH 62/66] Simplify frontend-search function with assoc array Also adds the lodash URL (which was missing) and uses https on those websites that support it. --- .../frontend-search.plugin.zsh | 100 ++++++------------ 1 file changed, 32 insertions(+), 68 deletions(-) diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh index e47735a6..3afc3336 100644 --- a/plugins/frontend-search/frontend-search.plugin.zsh +++ b/plugins/frontend-search/frontend-search.plugin.zsh @@ -1,6 +1,33 @@ # frontend from terminal function frontend() { + emulate -L zsh + + # define search content URLS + typeset -A urls + urls=( + angularjs 'https://google.com/search?as_sitesearch=angularjs.org&as_q=' + aurajs 'http://aurajs.com/api/#stq=' + bem 'https://google.com/search?as_sitesearch=bem.info&as_q=' + bootsnipp 'http://bootsnipp.com/search?q=' + caniuse 'http://caniuse.com/#search=' + codepen 'http://codepen.io/search?q=' + compass 'http://compass-style.org/search?q=' + cssflow 'http://www.cssflow.com/search?q=' + dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:' + emberjs 'http://emberjs.com/api/#stp=1&stq=' + fontello 'http://fontello.com/#search=' + html5please 'http://html5please.com/#' + jquery 'https://api.jquery.com/?s=' + lodash 'https://devdocs.io/lodash/index#' + mdn 'https://developer.mozilla.org/search?q=' + npmjs 'https://www.npmjs.com/search?q=' + qunit 'https://api.qunitjs.com/?s=' + reactjs 'https://google.com/search?as_sitesearch=facebook.github.io/react&as_q=' + smacss 'https://google.com/search?as_sitesearch=smacss.com&as_q=' + stackoverflow 'http://stackoverflow.com/search?q=' + unheap 'http://www.unheap.com/?s=' + ) # no keyword provided, simply show how call methods if [[ $# -le 1 ]]; then @@ -9,7 +36,7 @@ function frontend() { fi # check whether the search engine is supported - if [[ ! $1 =~ '(jquery|mdn|compass|html5please|caniuse|aurajs|dartlang|qunit|fontello|bootsnipp|cssflow|codepen|unheap|bem|smacss|angularjs|reactjs|emberjs|stackoverflow|npmjs)' ]]; + if [[ -z "$urls[$1]" ]]; then then echo "Search valid search content $1 not supported." echo "Valid contents: (formats 'frontend ' or '')" @@ -39,73 +66,10 @@ function frontend() { return 1 fi - local url="http://" - local query="" - - case "$1" in - "jquery") - url="${url}api.jquery.com" - url="${url}/?s=$2" ;; - "mdn") - url="${url}developer.mozilla.org" - url="${url}/search?q=$2" ;; - "compass") - url="${url}compass-style.org" - url="${url}/search?q=$2" ;; - "html5please") - url="${url}html5please.com" - url="${url}/#$2" ;; - "caniuse") - url="${url}caniuse.com" - url="${url}/#search=$2" ;; - "aurajs") - url="${url}aurajs.com" - url="${url}/api/#stq=$2" ;; - "dartlang") - url="${url}api.dartlang.org/apidocs/channels/stable/dartdoc-viewer" - url="${url}/dart-$2" ;; - "qunit") - url="${url}api.qunitjs.com" - url="${url}/?s=$2" ;; - "fontello") - url="${url}fontello.com" - url="${url}/#search=$2" ;; - "bootsnipp") - url="${url}bootsnipp.com" - url="${url}/search?q=$2" ;; - "cssflow") - url="${url}cssflow.com" - url="${url}/search?q=$2" ;; - "codepen") - url="${url}codepen.io" - url="${url}/search?q=$2" ;; - "unheap") - url="${url}www.unheap.com" - url="${url}/?s=$2" ;; - "bem") - url="${url}google.com" - url="${url}/search?as_q=$2&as_sitesearch=bem.info" ;; - "smacss") - url="${url}google.com" - url="${url}/search?as_q=$2&as_sitesearch=smacss.com" ;; - "angularjs") - url="${url}google.com" - url="${url}/search?as_q=$2&as_sitesearch=angularjs.org" ;; - "reactjs") - url="${url}google.com" - url="${url}/search?as_q=$2&as_sitesearch=facebook.github.io/react" ;; - "emberjs") - url="${url}emberjs.com" - url="${url}/api/#stq=$2&stp=1" ;; - "stackoverflow") - url="${url}stackoverflow.com" - url="${url}/search?q=$2" ;; - "npmjs") - url="${url}www.npmjs.com" - url="${url}/search?q=$2" ;; - *) echo "INVALID PARAM!" - return ;; - esac + # build search url: + # join arguments passed with '+', then append to search engine URL + # TODO substitute for proper urlencode method + url="${urls[$1]}${(j:+:)@[2,-1]}" echo "$url" From ff706f3ef8fd632d93e2c347d32c62f15b17c25c Mon Sep 17 00:00:00 2001 From: willmendesneto Date: Thu, 3 Jul 2014 22:53:00 -0300 Subject: [PATCH 63/66] Add "help" method in "frontend-search" plugin --- plugins/frontend-search/README.md | 9 ++++++- .../frontend-search.plugin.zsh | 26 +++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/plugins/frontend-search/README.md b/plugins/frontend-search/README.md index b8e96ea4..bf8a4bc0 100644 --- a/plugins/frontend-search/README.md +++ b/plugins/frontend-search/README.md @@ -17,9 +17,16 @@ plugins=( ... frontend-search) ## Commands ## -All command searches are accept only in format +All command searches are accept only in formats * `frontend ` +* ` ` + +For more informations, please run help command (are similars) + +* `frontend -h` +* `frontend --help` +* `frontend help` The search content are diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh index 3afc3336..08930ddc 100644 --- a/plugins/frontend-search/frontend-search.plugin.zsh +++ b/plugins/frontend-search/frontend-search.plugin.zsh @@ -29,14 +29,36 @@ function frontend() { unheap 'http://www.unheap.com/?s=' ) + # show help for commands list + if [[ $1 =~ '(help|--help|-h)' ]] + then + echo "Usage:" + echo "\n\tfrontend \n\t\n\tfrontend " + echo "" + echo "Where is one of:" + echo "jquery, mdn, compass, html5please, caniuse, aurajs, dartlang, qunit, fontello," + echo "bootsnipp, cssflow, codepen, unheap, bem, smacss, angularjs, reactjs, emberjs" + echo "help" + echo "" + echo "Where is a term to search in allowed repositories" + echo "" + echo "frontend --help show plugin help" + echo "frontend -h show plugin help" + echo "" + echo "It is allowed to directly access all search contents." + echo "" + return 1 + fi + # no keyword provided, simply show how call methods - if [[ $# -le 1 ]]; then + if [[ $# -le 1 ]] + then echo "Please provide a search-content and a search-term for app.\nEx:\nfrontend \n" return 1 fi # check whether the search engine is supported - if [[ -z "$urls[$1]" ]]; then + if [[ -z "$urls[$1]" ]] then echo "Search valid search content $1 not supported." echo "Valid contents: (formats 'frontend ' or '')" From 663ac56d54d252b9de7c76346bd64a14340a51f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Mon, 31 Aug 2015 18:49:05 +0200 Subject: [PATCH 64/66] Prettify frontend help output and clean up logic --- .../frontend-search.plugin.zsh | 79 ++++++------------- 1 file changed, 24 insertions(+), 55 deletions(-) diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh index 08930ddc..6eb1fed2 100644 --- a/plugins/frontend-search/frontend-search.plugin.zsh +++ b/plugins/frontend-search/frontend-search.plugin.zsh @@ -1,9 +1,7 @@ -# frontend from terminal - function frontend() { emulate -L zsh - # define search content URLS + # define search context URLS typeset -A urls urls=( angularjs 'https://google.com/search?as_sitesearch=angularjs.org&as_q=' @@ -29,74 +27,45 @@ function frontend() { unheap 'http://www.unheap.com/?s=' ) - # show help for commands list - if [[ $1 =~ '(help|--help|-h)' ]] + # show help for command list + if [[ $# -lt 2 ]] then - echo "Usage:" - echo "\n\tfrontend \n\t\n\tfrontend " - echo "" - echo "Where is one of:" - echo "jquery, mdn, compass, html5please, caniuse, aurajs, dartlang, qunit, fontello," - echo "bootsnipp, cssflow, codepen, unheap, bem, smacss, angularjs, reactjs, emberjs" - echo "help" - echo "" - echo "Where is a term to search in allowed repositories" - echo "" - echo "frontend --help show plugin help" - echo "frontend -h show plugin help" - echo "" - echo "It is allowed to directly access all search contents." - echo "" + print -P "Usage: frontend %Ucontext%u %Uterm%u [...%Umore%u] (or just: %Ucontext%u %Uterm%u [...%Umore%u])" + print -P "" + print -P "%Uterm%u and what follows is what will be searched for in the %Ucontext%u website," + print -P "and %Ucontext%u is one of the following:" + print -P "" + print -P " angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compass, cssflow," + print -P " dartlang, emberjs, fontello, html5please, jquery, lodash, mdn, npmjs," + print -P " qunit, reactjs, smacss, stackoverflow, unheap" + print -P "" + print -P "For example: frontend npmjs mocha (or just: npmjs mocha)." + print -P "" return 1 fi - # no keyword provided, simply show how call methods - if [[ $# -le 1 ]] - then - echo "Please provide a search-content and a search-term for app.\nEx:\nfrontend \n" - return 1 - fi - - # check whether the search engine is supported + # check whether the search context is supported if [[ -z "$urls[$1]" ]] then - echo "Search valid search content $1 not supported." - echo "Valid contents: (formats 'frontend ' or '')" - echo "* jquery" - echo "* mdn" - echo "* compass" - echo "* html5please" - echo "* caniuse" - echo "* aurajs" - echo "* dartlang" - echo "* lodash" - echo "* qunit" - echo "* fontello" - echo "* bootsnipp" - echo "* cssflow" - echo "* codepen" - echo "* unheap" - echo "* bem" - echo "* smacss" - echo "* angularjs" - echo "* reactjs" - echo "* emberjs" - echo "* stackoverflow" - echo "* npmjs" + echo "Search context \"$1\" currently not supported." + echo "" + echo "Valid contexts are:" + echo "" + echo " angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compass, cssflow, " + echo " dartlang, emberjs, fontello, html5please, jquery, lodash, mdn, npmjs, " + echo " qunit, reactjs, smacss, stackoverflow, unheap" echo "" - return 1 fi # build search url: - # join arguments passed with '+', then append to search engine URL + # join arguments passed with '+', then append to search context URL # TODO substitute for proper urlencode method url="${urls[$1]}${(j:+:)@[2,-1]}" - echo "$url" + echo "Opening $url ..." open_command "$url" - } # javascript From d982e1200f1f14fa4487a45c8af4e18834092ebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Mon, 31 Aug 2015 19:12:05 +0200 Subject: [PATCH 65/66] Reorder alias definitions --- .../frontend-search.plugin.zsh | 63 +++++++------------ 1 file changed, 22 insertions(+), 41 deletions(-) diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh index 6eb1fed2..2fd5416b 100644 --- a/plugins/frontend-search/frontend-search.plugin.zsh +++ b/plugins/frontend-search/frontend-search.plugin.zsh @@ -1,3 +1,25 @@ +alias angularjs='frontend angularjs' +alias aurajs='frontend aurajs' +alias bem='frontend bem' +alias bootsnipp='frontend bootsnipp' +alias caniuse='frontend caniuse' +alias codepen='frontend codepen' +alias compass='frontend compass' +alias cssflow='frontend cssflow' +alias dartlang='frontend dartlang' +alias emberjs='frontend emberjs' +alias fontello='frontend fontello' +alias html5please='frontend html5please' +alias jquery='frontend jquery' +alias lodash='frontend lodash' +alias mdn='frontend mdn' +alias npmjs='frontend npmjs' +alias qunit='frontend qunit' +alias reactjs='frontend reactjs' +alias smacss='frontend smacss' +alias stackoverflow='frontend stackoverflow' +alias unheap='frontend unheap' + function frontend() { emulate -L zsh @@ -67,44 +89,3 @@ function frontend() { open_command "$url" } - -# javascript -alias jquery='frontend jquery' -alias mdn='frontend mdn' - -# pre processors frameworks -alias compassdoc='frontend compass' - -# important links -alias html5please='frontend html5please' -alias caniuse='frontend caniuse' - -# components and libraries -alias aurajs='frontend aurajs' -alias dartlang='frontend dartlang' -alias lodash='frontend lodash' - -#tests -alias qunit='frontend qunit' - -#fonts -alias fontello='frontend fontello' - -# snippets -alias bootsnipp='frontend bootsnipp' -alias cssflow='frontend cssflow' -alias codepen='frontend codepen' -alias unheap='frontend unheap' - -# css architecture -alias bem='frontend bem' -alias smacss='frontend smacss' - -# frameworks -alias angularjs='frontend angularjs' -alias reactjs='frontend reactjs' -alias emberjs='frontend emberjs' - -# search websites -alias stackoverflow='frontend stackoverflow' -alias npmjs='frontend npmjs' From c481c62bc996cfe22417621dfd96c4267eb1e740 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Mon, 31 Aug 2015 19:17:16 +0200 Subject: [PATCH 66/66] Refactor and clear up README file --- plugins/frontend-search/README.md | 107 ++++++++++++------------------ 1 file changed, 41 insertions(+), 66 deletions(-) diff --git a/plugins/frontend-search/README.md b/plugins/frontend-search/README.md index bf8a4bc0..d0bc5589 100644 --- a/plugins/frontend-search/README.md +++ b/plugins/frontend-search/README.md @@ -1,83 +1,60 @@ -## Rationale ## +## Introduction ## -> Searches for your Frontend contents more easier +> Searches for your frontend web development made easier -## Instalation ## +## Installation ## +Open your `~/.zshrc` file and enable the `frontend-search` plugin: -Open your `.zshrc` file and load `frontend-search` plugin +```zsh + +plugins=( ... frontend-search) -```bash -... -plugins=( ... frontend-search) -... ``` -## Commands ## +## Usage ## -All command searches are accept only in formats +You can use the frontend-search plugin in these two forms: -* `frontend ` -* ` ` +* `frontend [more terms if you want]` +* ` [more terms if you want]` -For more informations, please run help command (are similars) +For example, these two are equivalent: -* `frontend -h` -* `frontend --help` -* `frontend help` +```zsh +$ frontend angularjs dependency injection +$ angularjs dependency injection +``` -The search content are +Available search contexts are: -* `jquery ` -* `mdn ` -* `compass ` -* `html5please ` -* `caniuse ` -* `aurajs ` -* `dartlang ` -* `lodash ` -* `qunit ` -* `fontello ` -* `bootsnipp ` -* `cssflow ` -* `codepen ` -* `unheap ` -* `bem &as_sitesearch=bem.info>` -* `smacss &as_sitesearch=smacss.com>` -* `angularjs &as_sitesearch=angularjs.org>` -* `reactjs &as_sitesearch=facebook.github.io/react>` -* `emberjs ` -* `stackoverflow ` -* `npmjs ` +| context | URL | +|---------------|--------------------------------------------------------------------------| +| angularjs | `https://google.com/search?as_sitesearch=angularjs.org&as_q=` | +| aurajs | `http://aurajs.com/api/#stq=` | +| bem | `https://google.com/search?as_sitesearch=bem.info&as_q=` | +| bootsnipp | `http://bootsnipp.com/search?q=` | +| caniuse | `http://caniuse.com/#search=` | +| codepen | `http://codepen.io/search?q=` | +| compass | `http://compass-style.org/search?q=` | +| cssflow | `http://www.cssflow.com/search?q=` | +| dartlang | `https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:` | +| emberjs | `http://emberjs.com/api/#stp=1&stq=` | +| fontello | `http://fontello.com/#search=` | +| html5please | `http://html5please.com/#` | +| jquery | `https://api.jquery.com/?s=` | +| lodash | `https://devdocs.io/lodash/index#` | +| mdn | `https://developer.mozilla.org/search?q=` | +| npmjs | `https://www.npmjs.com/search?q=` | +| qunit | `https://api.qunitjs.com/?s=` | +| reactjs | `https://google.com/search?as_sitesearch=facebook.github.io/react&as_q=` | +| smacss | `https://google.com/search?as_sitesearch=smacss.com&as_q=` | +| stackoverflow | `http://stackoverflow.com/search?q=` | +| unheap | `http://www.unheap.com/?s=` | - -## Aliases ## - -There are a few aliases presented as well: - -* `jquery` A shorthand for `frontend jquery` -* `mdn` A shorthand for `frontend mdn` -* `compass` A shorthand for `frontend compass` -* `html5please` A shorthand for `frontend html5please` -* `caniuse` A shorthand for `frontend caniuse` -* `aurajs` A shorthand for `frontend aurajs` -* `dartlang` A shorthand for `frontend dartlang` -* `lodash` A shorthand for `frontend lodash` -* `qunit` A shorthand for `frontend qunit` -* `fontello` A shorthand for `frontend fontello` -* `bootsnipp` A shorthand for `frontend bootsnipp` -* `cssflow` A shorthand for `frontend cssflow` -* `codepen` A shorthand for `frontend codepen` -* `unheap` A shorthand for `frontend unheap` -* `bem` A shorthand for `frontend bem` -* `smacss` A shorthand for `frontend smacss` -* `angularjs` A shorthand for `frontend angularjs` -* `reactjs` A shorthand for `frontend reactjs` -* `emberjs` A shorthand for `frontend emberjs` -* `stackoverflow` A shorthand for `frontend stackoverflow` -* `npmjs` A shorthand for `frontend npmjs` +If you want to have another context, open an Issue and tell us! ## Author @@ -86,5 +63,3 @@ There are a few aliases presented as well: + + + - -New features comming soon.