From fa3c694522bfe1d0ed4e1368951fdefbf25f5ed6 Mon Sep 17 00:00:00 2001 From: Chris Kimpton Date: Mon, 17 Jun 2013 12:20:07 +0200 Subject: [PATCH 001/216] Updated path for vcprompt source https://github.com/xvzf/vcprompt is not valid --- template/bash_profile.template.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/bash_profile.template.bash b/template/bash_profile.template.bash index 60cac9ea..af37a5e1 100644 --- a/template/bash_profile.template.bash +++ b/template/bash_profile.template.bash @@ -36,7 +36,7 @@ export IRC_CLIENT='irssi' export TODO="t" # Set vcprompt executable path for scm advance info in prompt (demula theme) -# https://github.com/xvzf/vcprompt +# https://github.com/djl/vcprompt #export VCPROMPT_EXECUTABLE=~/.vcprompt/bin/vcprompt # Load Bash It From 16933b7d4fe7b4ebe47c798ff162273dbe6f179c Mon Sep 17 00:00:00 2001 From: Frank Becker Date: Sat, 10 Jan 2015 14:26:51 +0100 Subject: [PATCH 002/216] added gvm completion and plugin --- completion/available/gvm.completion.bash | 62 ++++++++++++++++++++++++ plugins/available/gvm.plugin.bash | 6 +++ 2 files changed, 68 insertions(+) create mode 100644 completion/available/gvm.completion.bash create mode 100644 plugins/available/gvm.plugin.bash diff --git a/completion/available/gvm.completion.bash b/completion/available/gvm.completion.bash new file mode 100644 index 00000000..c2158747 --- /dev/null +++ b/completion/available/gvm.completion.bash @@ -0,0 +1,62 @@ +_gvm_complete() +{ + local CANDIDATES + local CANDIDATE_VERSIONS + + COMPREPLY=() + + if [ $COMP_CWORD -eq 1 ]; then + COMPREPLY=( $(compgen -W "install uninstall rm list ls use current version default selfupdate broadcast offline help flush" -- ${COMP_WORDS[COMP_CWORD]}) ) + elif [ $COMP_CWORD -eq 2 ]; then + case "${COMP_WORDS[COMP_CWORD-1]}" in + "install" | "uninstall" | "rm" | "list" | "ls" | "use" | "current" ) + CANDIDATES=$(echo "${GVM_CANDIDATES_CSV}" | tr ',' ' ') + COMPREPLY=( $(compgen -W "$CANDIDATES" -- ${COMP_WORDS[COMP_CWORD]}) ) + ;; + "offline" ) + COMPREPLY=( $(compgen -W "enable disable" -- ${COMP_WORDS[COMP_CWORD]}) ) + ;; + "selfupdate" ) + COMPREPLY=( $(compgen -W "force" -P "[" -S "]" -- ${COMP_WORDS[COMP_CWORD]}) ) + ;; + "flush" ) + COMPREPLY=( $(compgen -W "candidates broadcast archives temp" -- ${COMP_WORDS[COMP_CWORD]}) ) + ;; + *) + ;; + esac + elif [ $COMP_CWORD -eq 3 ]; then + case "${COMP_WORDS[COMP_CWORD-2]}" in + "install" | "uninstall" | "rm" | "use" | "default" ) + _gvm_candidate_versions ${COMP_WORDS[COMP_CWORD-1]} + COMPREPLY=( $(compgen -W "$CANDIDATE_VERSIONS" -- ${COMP_WORDS[COMP_CWORD]}) ) + ;; + *) + ;; + esac + fi + + return 0 +} + +_gvm_candidate_versions(){ + + if _gvm_offline; then + __gvmtool_build_version_csv $1 + CANDIDATE_VERSIONS="$(echo $CSV | tr ',' ' ')" + else + CANDIDATE_VERSIONS="$(curl -s "${GVM_SERVICE}/candidates/$1" | tr ',' ' ')" + fi + +} + +_gvm_offline() +{ + if [ "$GVM_ONLINE" = "true" ]; then + return 1 + else + return 0 + fi +} + +complete -F _gvm_complete gvm diff --git a/plugins/available/gvm.plugin.bash b/plugins/available/gvm.plugin.bash new file mode 100644 index 00000000..596c0276 --- /dev/null +++ b/plugins/available/gvm.plugin.bash @@ -0,0 +1,6 @@ +cite about-plugin +about-plugin 'load gvm environment' + +GVM_DIR="$HOME/.gvm" + +[[ -s "${GVM_DIR}/bin/gvm-init.sh" ]] && source "${GVM_DIR}/bin/gvm-init.sh" From 5d0ba9550fca341d19df7cc8a09c09e8af348d15 Mon Sep 17 00:00:00 2001 From: Frank Becker Date: Mon, 12 Jan 2015 10:27:38 +0100 Subject: [PATCH 003/216] rename gvm completion and plugin to gvmtool to avoid confusion with go version manager --- .../available/{gvm.completion.bash => gvmtool.completion.bash} | 0 plugins/available/{gvm.plugin.bash => gvmtool.plugin.bash} | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename completion/available/{gvm.completion.bash => gvmtool.completion.bash} (100%) rename plugins/available/{gvm.plugin.bash => gvmtool.plugin.bash} (71%) diff --git a/completion/available/gvm.completion.bash b/completion/available/gvmtool.completion.bash similarity index 100% rename from completion/available/gvm.completion.bash rename to completion/available/gvmtool.completion.bash diff --git a/plugins/available/gvm.plugin.bash b/plugins/available/gvmtool.plugin.bash similarity index 71% rename from plugins/available/gvm.plugin.bash rename to plugins/available/gvmtool.plugin.bash index 596c0276..ee69a669 100644 --- a/plugins/available/gvm.plugin.bash +++ b/plugins/available/gvmtool.plugin.bash @@ -1,5 +1,5 @@ cite about-plugin -about-plugin 'load gvm environment' +about-plugin 'load groovy environment manager' GVM_DIR="$HOME/.gvm" From 2195d3aa76638d6d7be35f6cb3897be920c8f170 Mon Sep 17 00:00:00 2001 From: Timo Webler Date: Thu, 19 Feb 2015 13:26:23 +0100 Subject: [PATCH 004/216] Add the compatibility for capistrano gem version 3 Use all tasks for completion --- completion/available/capistrano.completion.bash | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) mode change 100644 => 100755 completion/available/capistrano.completion.bash diff --git a/completion/available/capistrano.completion.bash b/completion/available/capistrano.completion.bash old mode 100644 new mode 100755 index a48bd4d6..d5fda06f --- a/completion/available/capistrano.completion.bash +++ b/completion/available/capistrano.completion.bash @@ -7,7 +7,14 @@ _capcomplete() { if [ -f Capfile ]; then recent=`ls -t .cap_tasks~ Capfile **/*.cap 2> /dev/null | head -n 1` if [[ $recent != '.cap_tasks~' ]]; then - cap --tool --tasks | cut -d " " -f 2 > .cap_tasks~ + cap --version | grep 'Capistrano v2.' > /dev/null + if [ $? -eq 0 ]; then + # Capistrano 2.x + cap --tool --verbose --tasks | cut -d " " -f 2 > .cap_tasks~ + else + # Capistrano 3.x + cap --all --tasks | cut -d " " -f 2 > .cap_tasks~ + fi fi COMPREPLY=($(compgen -W "`cat .cap_tasks~`" -- ${COMP_WORDS[COMP_CWORD]})) return 0 From 237816b7828b79aceb5afd3c324d05066c13a86c Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Thu, 6 Aug 2015 09:19:20 +0200 Subject: [PATCH 005/216] Updated install script Removed Jekyll template option - it does not really belong in Bash-it. Removed the all/some/none options. Most people selected `all` and then complained about things not working, or error messages being shown. This was mostly due to missing dependencies. The installer now uses a 'sane' default - it just enables completion for the 'bash-it' command and nothing else. At the end of the installation, it prints a message explaining the ways to see the available plugins and how to enable them. Updated readme with install options --- README.md | 15 +--- install.sh | 117 ++++++---------------------- template/jekyllconfig.template.bash | 21 ----- 3 files changed, 28 insertions(+), 125 deletions(-) delete mode 100644 template/jekyllconfig.template.bash diff --git a/README.md b/README.md index ab63b9bb..9f12f5a6 100644 --- a/README.md +++ b/README.md @@ -12,19 +12,10 @@ Bash it provides a solid framework for using, developing and maintaining shell s 1. Check a clone of this repo: `git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it` 2. Run `~/.bash_it/install.sh` (it automatically backs up your `~/.bash_profile` or `~/.bashrc`, depends on your OS) -3. Edit your modified config (`~/.bash_profile` or `~/.bashrc`) file in order to customize bash it. +3. Edit your modified config (`~/.bash_profile` or `~/.bashrc`) file in order to customize Bash it. +4. Check out available aliases, completions and plugins and enable the ones you want to use (see the next section for more details). -**NOTE:** -The install script will also prompt you asking if you use [Jekyll](https://github.com/mojombo/jekyll). -This is to set up the `.jekyllconfig` file, which stores info necessary to use the Jekyll plugin. - -**INSTALL OPTIONS:** -The install script can take the following options: - -* `--all`: Enable all aliases, plugins and completions. -* `--none`: Don't enable any aliases, plugins or completions. - -If none of these parameters is provided, the install script will ask the user. +Bash it only enables a sane default set of functionality to keep your shell lean and to avoid issues with missing dependencies. Feel free to enable the tools you want to use after the installation. ## Help Screens diff --git a/install.sh b/install.sh index bbd01411..1777e177 100755 --- a/install.sh +++ b/install.sh @@ -13,7 +13,7 @@ esac BACKUP_FILE=$CONFIG_FILE.bak if [ -e "$HOME/$BACKUP_FILE" ]; then - echo "Backup file already exists. Make sure to backup your .bashrc before running this installation." >&2 + echo -e "\033[0;33mBackup file already exists. Make sure to backup your .bashrc before running this installation.\033[0m" >&2 while true do read -e -n 1 -r -p "Would you like to overwrite the existing backup? This will delete your existing backup file ($HOME/$BACKUP_FILE) [y/N] " RESP @@ -34,104 +34,37 @@ fi test -w "$HOME/$CONFIG_FILE" && cp -a "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" && - echo "Your original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak" + echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m" cp "$HOME/.bash_it/template/bash_profile.template.bash" "$HOME/$CONFIG_FILE" -echo "Copied the template $CONFIG_FILE into ~/$CONFIG_FILE, edit this file to customize bash-it" +echo -e "\033[0;32mCopied the template $CONFIG_FILE into ~/$CONFIG_FILE, edit this file to customize bash-it\033[0m" -function load_all() { +function load_one() { file_type=$1 + file_to_enable=$2 [ ! -d "$BASH_IT/$file_type/enabled" ] && mkdir "$BASH_IT/${file_type}/enabled" - for src in $BASH_IT/${file_type}/available/*; do - filename="$(basename ${src})" - [ ${filename:0:1} = "_" ] && continue - dest="${BASH_IT}/${file_type}/enabled/${filename}" - if [ ! -e "${dest}" ]; then - ln -s "../available/${filename}" "${dest}" - else - echo "File ${dest} exists, skipping" - fi - done + + dest="${BASH_IT}/${file_type}/enabled/${file_to_enable}" + if [ ! -e "${dest}" ]; then + ln -s "../available/${file_to_enable}" "${dest}" + else + echo "File ${dest} exists, skipping" + fi } -function load_some() { - file_type=$1 - [ -d "$BASH_IT/$file_type/enabled" ] || mkdir "$BASH_IT/$file_type/enabled" - for path in `ls $BASH_IT/${file_type}/available/[^_]*` - do - file_name=$(basename "$path") - while true - do - read -e -n 1 -p "Would you like to enable the ${file_name%%.*} $file_type? [y/N] " RESP - case $RESP in - [yY]) - ln -s "../available/${file_name}" "$BASH_IT/$file_type/enabled" - break - ;; - [nN]|"") - break - ;; - *) - echo -e "\033[91mPlease choose y or n.\033[m" - ;; - esac - done - done -} +echo "" +echo "Enabling sane defaults" +load_one completion bash-it.completion.bash -if [[ "$1" == "--none" ]] -then - echo "Not enabling any aliases, plugins or completions" -elif [[ "$1" == "--all" ]] -then - echo "Enabling all aliases, plugins and completions." - load_all aliases - load_all plugins - load_all completion -else - while true - do - read -e -n 1 -p "Do you use Jekyll? (If you don't know what Jekyll is, answer 'n') [y/N] " RESP - case $RESP in - [yY]) - cp "$HOME/.bash_it/template/jekyllconfig.template.bash" "$HOME/.jekyllconfig" - echo "Copied the template .jekyllconfig into your home directory. Edit this file to customize bash-it for using the Jekyll plugins" - break - ;; - [nN]|"") - break - ;; - *) - echo -e "\033[91mPlease choose y or n.\033[m" - ;; - esac - done - - for type in "aliases" "plugins" "completion" - do - while true - do - read -p "Would you like to enable all, some, or no $type? Some of these may make bash slower to start up (especially completion). (all/some/none) " RESP - case $RESP - in - some) - load_some $type - break - ;; - all) - load_all $type - break - ;; - none) - break - ;; - *) - echo "Unknown choice. Please enter some, all, or none" - continue - ;; - esac - done - done +echo "" echo -e "\033[0;32mInstallation finished successfully! Enjoy bash-it!\033[0m" -fi +echo -e "\033[0;32mTo start using it, open a new tab or 'source "$HOME/$CONFIG_FILE"'.\033[0m" +echo "" +echo "To show the available aliases/completions/plugins, type one of the following:" +echo " bash-it show aliases" +echo " bash-it show completions" +echo " bash-it show plugins" +echo "" +echo "To avoid issues and to keep your shell lean, please enable only features you really want to use." +echo "Enabling everything can lead to issues." diff --git a/template/jekyllconfig.template.bash b/template/jekyllconfig.template.bash deleted file mode 100644 index 291bf85e..00000000 --- a/template/jekyllconfig.template.bash +++ /dev/null @@ -1,21 +0,0 @@ -# This is a space-delimited list of your Jekyll project paths - -SITES="$HOME/sites/project_1 $HOME/sites/project_2" - -# This is another space-delimited list. -# This one is of the remote user@host:path location of your jekyll site -# NOTE: The locations of these must correspond to the locations -# of the sites in the first list -# For instance, the host for the first Jekyll site -# must be first in this list, the second second, etc. - -REMOTES="user@host_1:path user@host_2:path" - -# list of markup syntaxes to use for the sites, -# Same rules as above. Can be HTML, textile, or markdown - -MARKUPS="markdown textile" - -# If you want to use a different editor for Jekyll, change the value of this variable - -JEKYLL_EDITOR="$EDITOR" From 63add1f86a9a7ae2dfa01659c468d350b758ce60 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Thu, 6 Aug 2015 16:18:25 +0200 Subject: [PATCH 006/216] Added load_some function again It can be called by providing the `--interactive` switch to the install script. --- README.md | 9 +++++++-- install.sh | 40 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9f12f5a6..d3ed2c9c 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,16 @@ Bash it provides a solid framework for using, developing and maintaining shell s ## Install 1. Check a clone of this repo: `git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it` -2. Run `~/.bash_it/install.sh` (it automatically backs up your `~/.bash_profile` or `~/.bashrc`, depends on your OS) +2. Run `~/.bash_it/install.sh` (it automatically backs up your `~/.bash_profile` or `~/.bashrc`, depending on your OS) 3. Edit your modified config (`~/.bash_profile` or `~/.bashrc`) file in order to customize Bash it. 4. Check out available aliases, completions and plugins and enable the ones you want to use (see the next section for more details). -Bash it only enables a sane default set of functionality to keep your shell lean and to avoid issues with missing dependencies. Feel free to enable the tools you want to use after the installation. +**INSTALL OPTIONS:** +The install script can take the following options: + +* `--interactive`: Asks the user which aliases, completions and plugins to enable. + +When run without the `--interactive` switch, Bash it only enables a sane default set of functionality to keep your shell lean and to avoid issues with missing dependencies. Feel free to enable the tools you want to use after the installation. ## Help Screens diff --git a/install.sh b/install.sh index 1777e177..3baa1d58 100755 --- a/install.sh +++ b/install.sh @@ -53,9 +53,43 @@ function load_one() { fi } -echo "" -echo "Enabling sane defaults" -load_one completion bash-it.completion.bash +function load_some() { + file_type=$1 + [ -d "$BASH_IT/$file_type/enabled" ] || mkdir "$BASH_IT/$file_type/enabled" + for path in `ls $BASH_IT/${file_type}/available/[^_]*` + do + file_name=$(basename "$path") + while true + do + read -e -n 1 -p "Would you like to enable the ${file_name%%.*} $file_type? [y/N] " RESP + case $RESP in + [yY]) + ln -s "../available/${file_name}" "$BASH_IT/$file_type/enabled" + break + ;; + [nN]|"") + break + ;; + *) + echo -e "\033[91mPlease choose y or n.\033[m" + ;; + esac + done + done +} + +if [[ "$1" == "--interactive" ]] +then + for type in "aliases" "plugins" "completion" + do + echo -e "\033[0;32mEnabling $type\033[0m" + load_some $type + done +else + echo "" + echo -e "\033[0;32mEnabling sane defaults\033[0m" + load_one completion bash-it.completion.bash +fi echo "" echo -e "\033[0;32mInstallation finished successfully! Enjoy bash-it!\033[0m" From 39b5d0b042d3f82ab375e0af4b09db8ba0486024 Mon Sep 17 00:00:00 2001 From: goromlagche Date: Wed, 12 Aug 2015 00:20:50 +0530 Subject: [PATCH 007/216] adding time to bobby --- themes/base.theme.bash | 6 ++++++ themes/bobby/bobby.theme.bash | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 989e7cbc..853505e9 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -13,6 +13,8 @@ SCM_THEME_TAG_PREFIX='tag:' SCM_THEME_COMMIT_PREFIX='commit:' SCM_THEME_REMOTE_PREFIX='' +CLOCK_CHAR='☆' + SCM_GIT_SHOW_DETAILS=${SCM_GIT_SHOW_DETAILS:=true} SCM_GIT='git' @@ -291,6 +293,10 @@ function prompt_char { scm_char } +function clock_char { + echo -e "$CLOCK_CHAR" +} + if [ ! -e $BASH_IT/plugins/enabled/battery.plugin.bash ]; then # if user has installed battery plugin, skip this... function battery_charge (){ diff --git a/themes/bobby/bobby.theme.bash b/themes/bobby/bobby.theme.bash index 308b412b..eab8a0ec 100644 --- a/themes/bobby/bobby.theme.bash +++ b/themes/bobby/bobby.theme.bash @@ -14,7 +14,7 @@ RVM_THEME_PROMPT_SUFFIX="|" function prompt_command() { #PS1="${bold_cyan}$(scm_char)${green}$(scm_prompt_info)${purple}$(ruby_version_prompt) ${yellow}\h ${reset_color}in ${green}\w ${reset_color}\n${green}→${reset_color} " - PS1="\n${yellow}$(ruby_version_prompt) ${purple}\h ${reset_color}in ${green}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}→${reset_color} " + PS1="\n${bold_cyan}\T ${red}$(clock_char) ${yellow}$(ruby_version_prompt) ${purple}\h ${reset_color}in ${green}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}→${reset_color} " } PROMPT_COMMAND=prompt_command; From 2360790ee3566e2300cd156b90a286fdaba2e60a Mon Sep 17 00:00:00 2001 From: Hector Rivas Gandara Date: Wed, 12 Aug 2015 12:00:14 +0100 Subject: [PATCH 008/216] Fix infinite loop when $PS4 calls external command When using `set -x` with a `$PS4` variable which calls a external command (e.g. `PS4='+ $(true)'`) the color functions end in a infite loop. The solution is `shift` the arguments unconditionally in the color funtions. This fixes #546 --- themes/colors.theme.bash | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/themes/colors.theme.bash b/themes/colors.theme.bash index 2feb3e9a..4374039e 100644 --- a/themes/colors.theme.bash +++ b/themes/colors.theme.bash @@ -5,54 +5,54 @@ function __ { } function __make_ansi { - next=$1 && shift + next=$1; shift echo "\[\e[$(__$next $@)m\]" } function __make_echo { - next=$1 && shift + next=$1; shift echo "\033[$(__$next $@)m" } function __reset { - next=$1 && shift + next=$1; shift out="$(__$next $@)" echo "0${out:+;${out}}" } function __bold { - next=$1 && shift + next=$1; shift out="$(__$next $@)" echo "${out:+${out};}1" } function __faint { - next=$1 && shift + next=$1; shift out="$(__$next $@)" echo "${out:+${out};}2" } function __italic { - next=$1 && shift + next=$1; shift out="$(__$next $@)" echo "${out:+${out};}3" } function __underline { - next=$1 && shift + next=$1; shift out="$(__$next $@)" echo "${out:+${out};}4" } function __negative { - next=$1 && shift + next=$1; shift out="$(__$next $@)" echo "${out:+${out};}7" } function __crossed { - next=$1 && shift + next=$1; shift out="$(__$next $@)" echo "${out:+${out};}8" } @@ -114,18 +114,18 @@ function __color_rgb { } function __color { - color=$1 && shift + color=$1; shift case "$1" in - fg|bg) side="$1" && shift ;; + fg|bg) side="$1"; shift ;; *) side=fg;; esac case "$1" in - normal|bright) mode="$1" && shift;; + normal|bright) mode="$1"; shift;; *) mode=normal;; esac - [[ $color == "rgb" ]] && rgb="$1 $2 $3" && shift 3 + [[ $color == "rgb" ]] && rgb="$1 $2 $3"; shift 3 - next=$1 && shift + next=$1; shift out="$(__$next $@)" echo "$(__color_${mode}_${side} $(__color_${color} $rgb))${out:+;${out}}" } @@ -169,7 +169,7 @@ function __rgb { function __color_parse { - next=$1 && shift + next=$1; shift echo "$(__$next $@)" } From e525ea1fbea7eff3d1a42ebe8e507f46b09d459c Mon Sep 17 00:00:00 2001 From: goromlagche Date: Wed, 12 Aug 2015 22:59:18 +0530 Subject: [PATCH 009/216] clock_check added, datetime added instaed of clock, also battery_percentage added --- themes/base.theme.bash | 24 ++++++++++++++++++++---- themes/bobby/bobby.theme.bash | 2 +- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 853505e9..283dd1d3 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -14,6 +14,8 @@ SCM_THEME_COMMIT_PREFIX='commit:' SCM_THEME_REMOTE_PREFIX='' CLOCK_CHAR='☆' +CLOCK_CHECK=${CLOCK_CHECK:=true} +BATTER_PERCENTAGE_CHECK=${BATTER_PERCENTAGE_CHECK:=true} SCM_GIT_SHOW_DETAILS=${SCM_GIT_SHOW_DETAILS:=true} @@ -294,14 +296,28 @@ function prompt_char { } function clock_char { - echo -e "$CLOCK_CHAR" + if [[ "${CLOCK_CHECK}" = true ]]; then + DATE_STRING=$(date +"%Y-%m-%d %H:%M:%S") + echo -e "${bold_cyan}$DATE_STRING ${red}$CLOCK_CHAR" + fi +} + +function battery_char { + if [[ "${BATTER_PERCENTAGE_CHECK}" = true ]]; then + echo -e "${bold_red}$(battery_percentage)%" + fi } if [ ! -e $BASH_IT/plugins/enabled/battery.plugin.bash ]; then -# if user has installed battery plugin, skip this... + # if user has installed battery plugin, skip this... function battery_charge (){ - # no op - echo -n + # no op + echo -n + } + + function battery_char (){ + # no op + echo -n } fi diff --git a/themes/bobby/bobby.theme.bash b/themes/bobby/bobby.theme.bash index eab8a0ec..e0011759 100644 --- a/themes/bobby/bobby.theme.bash +++ b/themes/bobby/bobby.theme.bash @@ -14,7 +14,7 @@ RVM_THEME_PROMPT_SUFFIX="|" function prompt_command() { #PS1="${bold_cyan}$(scm_char)${green}$(scm_prompt_info)${purple}$(ruby_version_prompt) ${yellow}\h ${reset_color}in ${green}\w ${reset_color}\n${green}→${reset_color} " - PS1="\n${bold_cyan}\T ${red}$(clock_char) ${yellow}$(ruby_version_prompt) ${purple}\h ${reset_color}in ${green}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}→${reset_color} " + PS1="\n$(battery_char) $(clock_char) ${yellow}$(ruby_version_prompt) ${purple}\h ${reset_color}in ${green}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}→${reset_color} " } PROMPT_COMMAND=prompt_command; From 6c82269121631123e86d5d4d663acdf5c94d8ba1 Mon Sep 17 00:00:00 2001 From: Simon Fiddaman Date: Thu, 20 Aug 2015 17:37:46 +0200 Subject: [PATCH 010/216] Skip ssh hashed hosts --- completion/available/ssh.completion.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/completion/available/ssh.completion.bash b/completion/available/ssh.completion.bash index 396be8f2..19a52991 100644 --- a/completion/available/ssh.completion.bash +++ b/completion/available/ssh.completion.bash @@ -20,7 +20,7 @@ _sshcomplete() { # parse all hosts found in .ssh/known_hosts if [ -r "$HOME/.ssh/known_hosts" ]; then if grep -v -q -e '^ ssh-rsa' "$HOME/.ssh/known_hosts" ; then - COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$( awk '{print $1}' "$HOME/.ssh/known_hosts" | cut -d, -f 1 | sed -e 's/\[//g' | sed -e 's/\]//g' | cut -d: -f1 | grep -v ssh-rsa)" ${OPTIONS}) ) + COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$( awk '{print $1}' "$HOME/.ssh/known_hosts" | grep -v ^\| | cut -d, -f 1 | sed -e 's/\[//g' | sed -e 's/\]//g' | cut -d: -f1 | grep -v ssh-rsa)" ${OPTIONS}) ) fi fi From bdf1ede7ef69ef6590a0c5e35d764905055c353d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E4=BF=A1=E5=BC=BA?= Date: Fri, 21 Aug 2015 17:23:12 +0800 Subject: [PATCH 011/216] a new theme:axin,based on 'sexy' --- themes/axin/axin.theme.bash | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 themes/axin/axin.theme.bash diff --git a/themes/axin/axin.theme.bash b/themes/axin/axin.theme.bash new file mode 100644 index 00000000..a0410efe --- /dev/null +++ b/themes/axin/axin.theme.bash @@ -0,0 +1,46 @@ +# Sexy Bash Prompt, inspired by "Extravagant Zsh Prompt" +# Screenshot: http://cloud.gf3.ca/M5rG +# A big thanks to \amethyst on Freenode + +if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then export TERM=gnome-256color +elif [[ $TERM != dumb ]] && infocmp xterm-256color >/dev/null 2>&1; then export TERM=xterm-256color +fi + +if tput setaf 1 &> /dev/null; then + if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then + MAGENTA=$(tput setaf 9) + ORANGE=$(tput setaf 172) + GREEN=$(tput setaf 190) + PURPLE=$(tput setaf 141) + WHITE=$(tput setaf 0) + else + MAGENTA=$(tput setaf 5) + ORANGE=$(tput setaf 4) + GREEN=$(tput setaf 2) + PURPLE=$(tput setaf 1) + WHITE=$(tput setaf 7) + fi + BOLD=$(tput bold) + RESET=$(tput sgr0) +else + MAGENTA="\033[1;31m" + ORANGE="\033[1;33m" + GREEN="\033[1;32m" + PURPLE="\033[1;35m" + WHITE="\033[1;37m" + BOLD="" + RESET="\033[m" +fi + +parse_git_dirty () { + [[ $(git status 2> /dev/null | tail -n1 | cut -c 1-17) != "nothing to commit" ]] && echo "*" +} +parse_git_branch () { + git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" +} + +function prompt_command() { + PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]@ \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$PURPLE\]\$(scm_prompt_info) ${white}\t\n\$ \[$RESET\]" +} + +PROMPT_COMMAND=prompt_command From 5d6a68b201ecf40219f58ece8db1a892adab4e6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E4=BF=A1=E5=BC=BA?= Date: Mon, 24 Aug 2015 09:10:09 +0800 Subject: [PATCH 012/216] Delete the execss function, modify the note and the shown style --- themes/axin/axin.theme.bash | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/themes/axin/axin.theme.bash b/themes/axin/axin.theme.bash index a0410efe..0b95b531 100644 --- a/themes/axin/axin.theme.bash +++ b/themes/axin/axin.theme.bash @@ -1,6 +1,5 @@ -# Sexy Bash Prompt, inspired by "Extravagant Zsh Prompt" -# Screenshot: http://cloud.gf3.ca/M5rG -# A big thanks to \amethyst on Freenode +# Axin Bash Prompt, inspired by theme "Sexy" and "Bobby" +# thanks to them if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then export TERM=gnome-256color elif [[ $TERM != dumb ]] && infocmp xterm-256color >/dev/null 2>&1; then export TERM=xterm-256color @@ -32,15 +31,8 @@ else RESET="\033[m" fi -parse_git_dirty () { - [[ $(git status 2> /dev/null | tail -n1 | cut -c 1-17) != "nothing to commit" ]] && echo "*" -} -parse_git_branch () { - git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" -} - function prompt_command() { - PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]@ \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$PURPLE\]\$(scm_prompt_info) ${white}\t\n\$ \[$RESET\]" + PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]@ \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\[$SCM_THEME_PROMPT_PREFIX\]${white}\t \[$PURPLE\]\$(scm_prompt_info) \n\$ \[$RESET\]" } PROMPT_COMMAND=prompt_command From 03e311028c4437afef57bc2dcd0fa8cd3e1fc7cc Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Sun, 16 Aug 2015 12:35:22 +0200 Subject: [PATCH 013/216] Added plugin for OS X Time Machine A set of functions to simplify listing OS X Time Machine backups, and deleting old ones. Pulled from various script solutions found on Stack Overflow, adapted to the Bash-it framework. The functions allow to show which backups can be found on the connected Time Machine volume. The 'delete' function allows to safely remove all backups except for the latest one - this can be used to free up space on the Time Machine volume. The 'delete' function uses functionality of the OS to safely remove the old backups, no information is lost. The 'delete' function will only ask for the password once, then keep the credentials. Source: http://stackoverflow.com/a/30547074/1228454 --- plugins/available/osx-timemachine.plugin.bash | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 plugins/available/osx-timemachine.plugin.bash diff --git a/plugins/available/osx-timemachine.plugin.bash b/plugins/available/osx-timemachine.plugin.bash new file mode 100644 index 00000000..f29d6ece --- /dev/null +++ b/plugins/available/osx-timemachine.plugin.bash @@ -0,0 +1,84 @@ +cite about-plugin +about-plugin 'OS X Time Machine functions' + +function time-machine-destination() { + group "osx-timemachine" + about "Shows the OS X Time Machine destination/mount point" + + echo $(tmutil destinationinfo | grep "Mount Point" | sed -e 's/Mount Point : \(.*\)/\1/g') +} + +function time-machine-list-machines() { + group "osx-timemachine" + about "Lists the OS X Time Machine machines on the backup volume" + + local tmdest="$(time-machine-destination)/Backups.backupdb" + + find "$tmdest" -maxdepth 1 -mindepth 1 -type d | grep -v "/\." | while read line ; do + echo "$(basename "$line")" + done +} + +function time-machine-list-all-backups() { + group "osx-timemachine" + about "Shows all of the backups for the specified machine" + param "1: Machine name (optional)" + example "time-machine-list-all-backups my-laptop" + + # Use the local hostname if none provided + local COMPUTERNAME=${1:-$(scutil --get ComputerName)} + local BACKUP_LOCATION="$(time-machine-destination)/Backups.backupdb/$COMPUTERNAME" + + find "$BACKUP_LOCATION" -maxdepth 1 -mindepth 1 -type d | while read line ; do + echo "$line" + done +} + +function time-machine-list-old-backups() { + group "osx-timemachine" + about "Shows all of the backups for the specified machine, except for the most recent backup" + param "1: Machine name (optional)" + example "time-machine-list-old-backups my-laptop" + + # Use the local hostname if none provided + local COMPUTERNAME=${1:-$(scutil --get ComputerName)} + local BACKUP_LOCATION="$(time-machine-destination)/Backups.backupdb/$COMPUTERNAME" + + # List all but the most recent one + find "$BACKUP_LOCATION" -maxdepth 1 -mindepth 1 -type d -name 2\* | sed \$d | while read line ; do + echo "$line" + done +} + +# Taken from here: http://stackoverflow.com/a/30547074/1228454 +function _tm_startsudo() { + sudo -v + ( while true; do sudo -v; sleep 50; done; ) & + SUDO_PID="$!" + trap _tm_stopsudo SIGINT SIGTERM +} +function _tm_stopsudo() { + kill "$SUDO_PID" + trap - SIGINT SIGTERM + sudo -k +} + +function time-machine-delete-old-backups() { + group "osx-timemachine" + about "Deletes all of the backups for the specified machine, with the exception of the most recent one" + param "1: Machine name (optional)" + example "time-machine-delete-old-backups my-laptop" + + # Use the local hostname if none provided + local COMPUTERNAME=${1:-$(scutil --get ComputerName)} + + # Ask for sudo credentials only once + _tm_startsudo + + echo "$(time-machine-list-old-backups "$COMPUTERNAME")" | while read i ; do + # Delete the backup + sudo tmutil delete "$i" + done + + _tm_stopsudo +} From f7877a1ef8e8be45167b34fb2b5b8c1056c254c4 Mon Sep 17 00:00:00 2001 From: goromlagche Date: Thu, 27 Aug 2015 19:00:18 +0530 Subject: [PATCH 014/216] prefixing THEME to BATTERY_CHECK and CLOCK_CHECK --- themes/base.theme.bash | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 283dd1d3..c199146d 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -14,8 +14,8 @@ SCM_THEME_COMMIT_PREFIX='commit:' SCM_THEME_REMOTE_PREFIX='' CLOCK_CHAR='☆' -CLOCK_CHECK=${CLOCK_CHECK:=true} -BATTER_PERCENTAGE_CHECK=${BATTER_PERCENTAGE_CHECK:=true} +THEME_CLOCK_CHECK=${THEME_CLOCK_CHECK:=true} +THEME_BATTERY_PERCENTAGE_CHECK=${THEME_BATTERY_PERCENTAGE_CHECK:=true} SCM_GIT_SHOW_DETAILS=${SCM_GIT_SHOW_DETAILS:=true} @@ -296,14 +296,14 @@ function prompt_char { } function clock_char { - if [[ "${CLOCK_CHECK}" = true ]]; then + if [[ "${THEME_CLOCK_CHECK}" = true ]]; then DATE_STRING=$(date +"%Y-%m-%d %H:%M:%S") echo -e "${bold_cyan}$DATE_STRING ${red}$CLOCK_CHAR" fi } function battery_char { - if [[ "${BATTER_PERCENTAGE_CHECK}" = true ]]; then + if [[ "${THEME_BATTERY_PERCENTAGE_CHECK}" = true ]]; then echo -e "${bold_red}$(battery_percentage)%" fi } @@ -320,4 +320,3 @@ if [ ! -e $BASH_IT/plugins/enabled/battery.plugin.bash ]; then echo -n } fi - From 79727c84f475ad1f1877aa2fda0ededc00c1a6d5 Mon Sep 17 00:00:00 2001 From: Miguel Morales Date: Sat, 29 Aug 2015 18:41:18 -0500 Subject: [PATCH 015/216] Add mkdir and cd into directory function --- plugins/available/mkcd.plugin.bash | 1 + 1 file changed, 1 insertion(+) create mode 100644 plugins/available/mkcd.plugin.bash diff --git a/plugins/available/mkcd.plugin.bash b/plugins/available/mkcd.plugin.bash new file mode 100644 index 00000000..9fd82b25 --- /dev/null +++ b/plugins/available/mkcd.plugin.bash @@ -0,0 +1 @@ +function mkcd () { mkdir -p "$@" && eval cd "\"\$$#\""; } From 2bb8e900ea2d3beb47785f5c5ab75f4bfa04bda7 Mon Sep 17 00:00:00 2001 From: Miguel Morales Date: Sat, 29 Aug 2015 18:42:17 -0500 Subject: [PATCH 016/216] Add plugin mv into tmp trash folder that gets clear on reboot (as tmp does) --- plugins/available/del.plugin.bash | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 plugins/available/del.plugin.bash diff --git a/plugins/available/del.plugin.bash b/plugins/available/del.plugin.bash new file mode 100644 index 00000000..c6686cbc --- /dev/null +++ b/plugins/available/del.plugin.bash @@ -0,0 +1,2 @@ +function del() { mkdir -p /tmp/.trash && mv "$@" /tmp/.trash; } + From a88729053999e56acd704519813cfbf4f8fc9510 Mon Sep 17 00:00:00 2001 From: Miguel Morales Date: Sat, 29 Aug 2015 18:44:08 -0500 Subject: [PATCH 017/216] Tidy up blank line --- plugins/available/del.plugin.bash | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/available/del.plugin.bash b/plugins/available/del.plugin.bash index c6686cbc..94f08de5 100644 --- a/plugins/available/del.plugin.bash +++ b/plugins/available/del.plugin.bash @@ -1,2 +1 @@ function del() { mkdir -p /tmp/.trash && mv "$@" /tmp/.trash; } - From 8c05350c8bb15c70852d2b7844c2d5f4fc123aa5 Mon Sep 17 00:00:00 2001 From: Miguel Morales Date: Sat, 29 Aug 2015 18:47:45 -0500 Subject: [PATCH 018/216] Add comments and explanations --- plugins/available/del.plugin.bash | 6 ++++++ plugins/available/mkcd.plugin.bash | 3 +++ 2 files changed, 9 insertions(+) diff --git a/plugins/available/del.plugin.bash b/plugins/available/del.plugin.bash index 94f08de5..4f4237a0 100644 --- a/plugins/available/del.plugin.bash +++ b/plugins/available/del.plugin.bash @@ -1 +1,7 @@ +cite about-plugin +about-plugin 'soft delete by moving contents into a hidden folder in tmp' + +# the tmp folder gets cleared on reboot +# so this would actually remove the file on +# shutdown function del() { mkdir -p /tmp/.trash && mv "$@" /tmp/.trash; } diff --git a/plugins/available/mkcd.plugin.bash b/plugins/available/mkcd.plugin.bash index 9fd82b25..bea43f99 100644 --- a/plugins/available/mkcd.plugin.bash +++ b/plugins/available/mkcd.plugin.bash @@ -1 +1,4 @@ +cite about-plugin +about-plugin 'make and cd into a directory in one command' + function mkcd () { mkdir -p "$@" && eval cd "\"\$$#\""; } From 74a9f5c4111d135691a0c7d260e9b1529494ade1 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Mon, 31 Aug 2015 08:49:16 +0200 Subject: [PATCH 019/216] Moved some functions Some functions were specific to OS X, but were defined in the `base` plugin. I have moved them to the `osx` plugin: * pman * pcurl * pri As for `pcurl`, the `osx` plugin already had an existing `prevcurl` function, which was doing the same thing. I've aliased `pcurl` to simply call `prevcurl` to avoid breaking existing installations. As far as I know the `open -fa $PREVIEW` thing only works on OS X, which means that these functions have only worked on OS X anyway. --- plugins/available/base.plugin.bash | 27 --------------------------- plugins/available/osx.plugin.bash | 24 ++++++++++++++++++++++-- 2 files changed, 22 insertions(+), 29 deletions(-) diff --git a/plugins/available/base.plugin.bash b/plugins/available/base.plugin.bash index accd3610..da244a8f 100644 --- a/plugins/available/base.plugin.bash +++ b/plugins/available/base.plugin.bash @@ -99,33 +99,6 @@ function lsgrep () ls | grep "$*" } -function pman () -{ - about 'view man documentation in Preview' - param '1: man page to view' - example '$ pman bash' - group 'base' - man -t "${1}" | open -f -a $PREVIEW -} - -function pcurl () -{ - about 'download file and Preview it' - param '1: download URL' - example '$ pcurl http://www.irs.gov/pub/irs-pdf/fw4.pdf' - group 'base' - curl "${1}" | open -f -a $PREVIEW -} - -function pri () -{ - about 'display information about Ruby classes, modules, or methods, in Preview' - param '1: Ruby method, module, or class' - example '$ pri Array' - group 'base' - ri -T "${1}" | open -f -a $PREVIEW -} - function quiet () { about 'what *does* this do?' diff --git a/plugins/available/osx.plugin.bash b/plugins/available/osx.plugin.bash index 8628ca3c..9143ab2c 100644 --- a/plugins/available/osx.plugin.bash +++ b/plugins/available/osx.plugin.bash @@ -63,8 +63,25 @@ function dock-switch() { fi } -# Download a file and open it in Preview +function pman () +{ + about 'view man documentation in Preview' + param '1: man page to view' + example '$ pman bash' + group 'osx' + man -t "${1}" | open -fa $PREVIEW +} +function pri () +{ + about 'display information about Ruby classes, modules, or methods, in Preview' + param '1: Ruby method, module, or class' + example '$ pri Array' + group 'osx' + ri -T "${1}" | open -fa $PREVIEW +} + +# Download a file and open it in Preview function prevcurl() { about 'download a file and open it in Preview' param '1: url' @@ -75,5 +92,8 @@ function prevcurl() { echo "This function only works with Mac OS X" return 1 fi - curl "$*" | open -fa "Preview" + curl "$*" | open -fa $PREVIEW } + +# Make this backwards compatible +alias pcurl='prevcurl' From e6dc31b35dbc7904062012b8589832328e377c0f Mon Sep 17 00:00:00 2001 From: Bez Hermoso Date: Mon, 31 Aug 2015 10:14:55 -0700 Subject: [PATCH 020/216] Indicator if running bash in vim --- themes/powerline/powerline.theme.bash | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/themes/powerline/powerline.theme.bash b/themes/powerline/powerline.theme.bash index 944414db..710bbbfb 100644 --- a/themes/powerline/powerline.theme.bash +++ b/themes/powerline/powerline.theme.bash @@ -25,6 +25,10 @@ CWD_THEME_PROMPT_COLOR=240 LAST_STATUS_THEME_PROMPT_COLOR=52 +IN_VIM_PROMPT_COLOR=35 +IN_VIM_PROMPT_TEXT="vim" + + function set_rgb_color { if [[ "${1}" != "-" ]]; then fg="38;5;${1}" @@ -103,16 +107,26 @@ function powerline_last_status_prompt { fi } +function powerline_in_vim_prompt { + if [ -z "$MYVIMRC" ]; then + IN_VIM_PROMPT="" + else + IN_VIM_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${IN_VIM_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}$(set_rgb_color - ${IN_VIM_PROMPT_COLOR}) ${IN_VIM_PROMPT_TEXT} ${normal}$(set_rgb_color ${IN_VIM_PROMPT_COLOR} -)${normal}" + LAST_THEME_COLOR=${IN_VIM_PROMPT_COLOR} + fi +} + function powerline_prompt_command() { local LAST_STATUS="$?" powerline_shell_prompt + powerline_in_vim_prompt powerline_virtualenv_prompt powerline_scm_prompt powerline_cwd_prompt powerline_last_status_prompt LAST_STATUS - PS1="${SHELL_PROMPT}${VIRTUALENV_PROMPT}${SCM_PROMPT}${CWD_PROMPT}${LAST_STATUS_PROMPT} " + PS1="${SHELL_PROMPT}${IN_VIM_PROMPT}${VIRTUALENV_PROMPT}${SCM_PROMPT}${CWD_PROMPT}${LAST_STATUS_PROMPT} " } PROMPT_COMMAND=powerline_prompt_command From 29861812dd0e29d6e77601603a8c22fe9efb919c Mon Sep 17 00:00:00 2001 From: Bez Hermoso Date: Mon, 31 Aug 2015 12:06:29 -0700 Subject: [PATCH 021/216] Vim indicator for powerline-multiline theme --- .../powerline-multiline.theme.bash | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index 66f57241..a560d4f0 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -42,6 +42,10 @@ BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=160 THEME_PROMPT_CLOCK_FORMAT=${THEME_PROMPT_CLOCK_FORMAT:="%H:%M:%S"} +IN_VIM_PROMPT_COLOR=35 +IN_VIM_PROMPT_TEXT="vim" + + function set_rgb_color { if [[ "${1}" != "-" ]]; then fg="38;5;${1}" @@ -191,6 +195,22 @@ function powerline_battery_status_prompt { fi } +function powerline_in_vim_prompt { + if [ -z "$MYVIMRC" ]; then + IN_VIM_PROMPT="" + else + IN_VIM_PROMPT="$(set_rgb_color - ${IN_VIM_PROMPT_COLOR}) ${IN_VIM_PROMPT_TEXT} " + if [[ "${SEGMENT_AT_RIGHT}" -gt 0 ]]; then + IN_VIM_PROMPT+=$(set_rgb_color ${LAST_THEME_COLOR} ${IN_VIM_PROMPT_COLOR})${THEME_PROMPT_LEFT_SEPARATOR}${normal} + (( RIGHT_PROMPT_LENGTH += SEGMENT_AT_RIGHT )) + fi + RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#IN_VIM_PROMPT_TEXT} )) + LAST_THEME_COLOR=${IN_VIM_PROMPT_COLOR} + (( SEGMENT_AT_RIGHT += 1 )) + fi +} + + function powerline_prompt_command() { local LAST_STATUS="$?" local MOVE_CURSOR_RIGHTMOST='\033[500C' @@ -210,11 +230,12 @@ function powerline_prompt_command() { powerline_shell_prompt powerline_battery_status_prompt powerline_clock_prompt + powerline_in_vim_prompt [[ "${SEGMENT_AT_RIGHT}" -eq 1 ]] && (( RIGHT_PROMPT_LENGTH-=1 )) RIGHT_PROMPT="\033[${RIGHT_PROMPT_LENGTH}D$(set_rgb_color ${LAST_THEME_COLOR} -)${THEME_PROMPT_LEFT_SEPARATOR}${normal}" - RIGHT_PROMPT+="${CLOCK_PROMPT}${BATTERY_PROMPT}${SHELL_PROMPT}${normal}" + RIGHT_PROMPT+="${IN_VIM_PROMPT}${CLOCK_PROMPT}${BATTERY_PROMPT}${SHELL_PROMPT}${normal}" PS1="${LEFT_PROMPT}${RIGHT_PROMPT}\n${LAST_STATUS_PROMPT}${PROMPT_CHAR} " } From 77a891d8c68f0c69d55591b7bab9d395932fbe66 Mon Sep 17 00:00:00 2001 From: Bez Hermoso Date: Mon, 31 Aug 2015 16:35:44 -0700 Subject: [PATCH 022/216] Check VIMRUNTIME instead --- themes/powerline-multiline/powerline-multiline.theme.bash | 2 +- themes/powerline/powerline.theme.bash | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index a560d4f0..ba614bdd 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -196,7 +196,7 @@ function powerline_battery_status_prompt { } function powerline_in_vim_prompt { - if [ -z "$MYVIMRC" ]; then + if [ -z "$VIMRUNTIME" ]; then IN_VIM_PROMPT="" else IN_VIM_PROMPT="$(set_rgb_color - ${IN_VIM_PROMPT_COLOR}) ${IN_VIM_PROMPT_TEXT} " diff --git a/themes/powerline/powerline.theme.bash b/themes/powerline/powerline.theme.bash index 710bbbfb..f486eedf 100644 --- a/themes/powerline/powerline.theme.bash +++ b/themes/powerline/powerline.theme.bash @@ -108,7 +108,7 @@ function powerline_last_status_prompt { } function powerline_in_vim_prompt { - if [ -z "$MYVIMRC" ]; then + if [ -z "$VIMRUNTIME" ]; then IN_VIM_PROMPT="" else IN_VIM_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${IN_VIM_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}$(set_rgb_color - ${IN_VIM_PROMPT_COLOR}) ${IN_VIM_PROMPT_TEXT} ${normal}$(set_rgb_color ${IN_VIM_PROMPT_COLOR} -)${normal}" From 1bbf8204b678557d552653854bcd0a38518626c7 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Tue, 1 Sep 2015 10:47:16 -0500 Subject: [PATCH 023/216] Add bundler completion from @mernen --- completion/available/bundler.completion.bash | 55 ++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 completion/available/bundler.completion.bash diff --git a/completion/available/bundler.completion.bash b/completion/available/bundler.completion.bash new file mode 100644 index 00000000..274a4a36 --- /dev/null +++ b/completion/available/bundler.completion.bash @@ -0,0 +1,55 @@ +#! bash +# bash completion for the `bundle` command. +# +# Copyright (c) 2011-2013 Daniel Luz . +# Distributed under the MIT license. +# http://mernen.com/projects/completion-ruby +# +# To use, source this file on bash: +# . completion-bundle + +__bundle() { + local cur=$2 + local prev=$3 + local bundle_command + __bundle_get_command + COMPREPLY=() + + local options + if [[ $cur = -* ]]; then + options="--no-color --verbose" + if [[ -z $bundle_command ]]; then + options="$options --version --help" + fi + else + if [[ -z $bundle_command || $bundle_command = help ]]; then + options="help install update package exec config check list show + console open viz init gem" + fi + fi + COMPREPLY=($(compgen -W "$options" -- "$cur")) +} + +__bundle_get_command() { + local i + for ((i=1; i < $COMP_CWORD; ++i)); do + local arg=${COMP_WORDS[$i]} + + case $arg in + [^-]*) + bundle_command=$arg + return;; + --version) + # command-killer + bundle_command=- + return;; + --help) + bundle_command=help + return;; + esac + done +} + + +complete -F __bundle -o bashdefault -o default bundle +# vim: ai ft=sh sw=4 sts=2 et From 53906f1fb6b5aa7bb8d7a3b94c8670595b106ef1 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Fri, 4 Sep 2015 14:24:41 +0200 Subject: [PATCH 024/216] Added alias-completion plugin This plugin adds completion to aliases, just as with their regular commands. Example: * Completion works for `git checkout `, which shows available branches. * You have an alias like `alias gco="git checkout"` * The plugin adds support for `gco `, which will also show the available branches. Reference: http://superuser.com/a/437508/119764 --- plugins/available/alias-completion.bash | 82 +++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 plugins/available/alias-completion.bash diff --git a/plugins/available/alias-completion.bash b/plugins/available/alias-completion.bash new file mode 100644 index 00000000..3949c78d --- /dev/null +++ b/plugins/available/alias-completion.bash @@ -0,0 +1,82 @@ +cite about-plugin +about-plugin 'Automatic completion of aliases' + +# References: +# http://superuser.com/questions/436314/how-can-i-get-bash-to-perform-tab-completion-for-my-aliases +# http://stackoverflow.com/a/1793178/1228454 + +# This needs to be a plugin so it gets executed after the completions and the aliases have been defined. +# Bash-it loads its components in the order +# 1) Aliases +# 2) Completions +# 3) Plugins +# 4) Custom scripts + +# Automatically add completion for all aliases to commands having completion functions +function alias_completion { + local namespace="alias_completion" + + # parse function based completion definitions, where capture group 2 => function and 3 => trigger + local compl_regex='complete( +[^ ]+)* -F ([^ ]+) ("[^"]+"|[^ ]+)' + # parse alias definitions, where capture group 1 => trigger, 2 => command, 3 => command arguments + local alias_regex="alias ([^=]+)='(\"[^\"]+\"|[^ ]+)(( +[^ ]+)*)'" + + # create array of function completion triggers, keeping multi-word triggers together + eval "local completions=($(complete -p | sed -Ene "/$compl_regex/s//'\3'/p"))" + (( ${#completions[@]} == 0 )) && return 0 + + # create temporary file for wrapper functions and completions + rm -f "/tmp/${namespace}-*.tmp" # preliminary cleanup + local tmp_file; tmp_file="$(mktemp "/tmp/${namespace}-${RANDOM}XXX.tmp")" || return 1 + + local completion_loader; completion_loader="$(complete -p -D 2>/dev/null | sed -Ene 's/.* -F ([^ ]*).*/\1/p')" + + # read in " '' ''" lines from defined aliases + local line; while read line; do + eval "local alias_tokens; alias_tokens=($line)" 2>/dev/null || continue # some alias arg patterns cause an eval parse error + local alias_name="${alias_tokens[0]}" alias_cmd="${alias_tokens[1]}" alias_args="${alias_tokens[2]# }" + + # skip aliases to pipes, boolan control structures and other command lists + # (leveraging that eval errs out if $alias_args contains unquoted shell metacharacters) + eval "local alias_arg_words; alias_arg_words=($alias_args)" 2>/dev/null || continue + # avoid expanding wildcards + read -a alias_arg_words <<< "$alias_args" + + # skip alias if there is no completion function triggered by the aliased command + if [[ ! " ${completions[*]} " =~ " $alias_cmd " ]]; then + if [[ -n "$completion_loader" ]]; then + # force loading of completions for the aliased command + eval "$completion_loader $alias_cmd" + # 124 means completion loader was successful + [[ $? -eq 124 ]] || continue + completions+=($alias_cmd) + else + continue + fi + fi + local new_completion="$(complete -p "$alias_cmd")" + + # create a wrapper inserting the alias arguments if any + if [[ -n $alias_args ]]; then + local compl_func="${new_completion/#* -F /}"; compl_func="${compl_func%% *}" + # avoid recursive call loops by ignoring our own functions + if [[ "${compl_func#_$namespace::}" == $compl_func ]]; then + local compl_wrapper="_${namespace}::${alias_name}" + echo "function $compl_wrapper { + (( COMP_CWORD += ${#alias_arg_words[@]} )) + COMP_WORDS=($alias_cmd $alias_args \${COMP_WORDS[@]:1}) + (( COMP_POINT -= \${#COMP_LINE} )) + COMP_LINE=\${COMP_LINE/$alias_name/$alias_cmd $alias_args} + (( COMP_POINT += \${#COMP_LINE} )) + $compl_func + }" >> "$tmp_file" + new_completion="${new_completion/ -F $compl_func / -F $compl_wrapper }" + fi + fi + + # replace completion trigger by alias + new_completion="${new_completion% *} $alias_name" + echo "$new_completion" >> "$tmp_file" + done < <(alias -p | sed -Ene "s/$alias_regex/\1 '\2' '\3'/p") + source "$tmp_file" && rm -f "$tmp_file" +}; alias_completion From 86fd5cd5c4417816dd462f9dbbb019c49f3c3278 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Sat, 5 Sep 2015 02:12:38 +0200 Subject: [PATCH 025/216] Improve ref detection in git prompt --- themes/base.theme.bash | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index c199146d..1ac494ff 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -10,8 +10,7 @@ SCM_THEME_PROMPT_PREFIX=' |' SCM_THEME_PROMPT_SUFFIX='|' SCM_THEME_BRANCH_PREFIX='' SCM_THEME_TAG_PREFIX='tag:' -SCM_THEME_COMMIT_PREFIX='commit:' -SCM_THEME_REMOTE_PREFIX='' +SCM_THEME_DETACHED_PREFIX='detached:' CLOCK_CHAR='☆' THEME_CLOCK_CHECK=${THEME_CLOCK_CHECK:=true} @@ -107,6 +106,8 @@ function git_prompt_vars { fi fi + SCM_CHANGE=$(git rev-parse --short HEAD 2>/dev/null) + local ref=$(git symbolic-ref -q HEAD 2> /dev/null) if [[ -n "$ref" ]]; then SCM_BRANCH=${SCM_THEME_BRANCH_PREFIX}${ref#refs/heads/} @@ -115,15 +116,19 @@ function git_prompt_vars { if [[ -n "$ref" ]]; then SCM_BRANCH=${SCM_THEME_TAG_PREFIX}${ref} else - local commit_re='(^remotes/)?(.+-g[a-zA-Z0-9]+)$' - local remote_re='^remotes/(.+)$' - ref=$(git describe --tags --all --always 2> /dev/null) - if [[ "$ref" =~ ${commit_re} ]]; then - SCM_BRANCH=${SCM_THEME_COMMIT_PREFIX}${BASH_REMATCH[2]} - elif [[ "$ref" =~ ${remote_re} ]]; then - SCM_BRANCH=${SCM_THEME_REMOTE_PREFIX}${BASH_REMATCH[1]} + ref=$(git describe --contains --all HEAD 2> /dev/null) + if [[ -n "$ref" ]]; then + local remote_re='^remotes/(.+)$' + if [[ "$ref" =~ ${remote_re} ]]; then + SCM_BRANCH=${SCM_THEME_DETACHED_PREFIX}${BASH_REMATCH[1]} + else + SCM_BRANCH=${SCM_THEME_DETACHED_PREFIX}${ref} + fi fi fi + if [[ -z "$ref" ]]; then + SCM_BRANCH=${SCM_THEME_DETACHED_PREFIX}${SCM_CHANGE} + fi fi local ahead_re='.+ahead ([0-9]+).+' @@ -138,7 +143,6 @@ function git_prompt_vars { SCM_PREFIX=${GIT_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} SCM_SUFFIX=${GIT_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} - SCM_CHANGE=$(git rev-parse HEAD 2>/dev/null) } function svn_prompt_vars { From 78cb41a1cfe32aa61db3641901a3d16c2005a6a6 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Sat, 5 Sep 2015 15:04:25 +0200 Subject: [PATCH 026/216] Add the option to show git branch remote tracking info in git prompt --- themes/base.theme.bash | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 1ac494ff..b1d79ed8 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -17,6 +17,7 @@ THEME_CLOCK_CHECK=${THEME_CLOCK_CHECK:=true} THEME_BATTERY_PERCENTAGE_CHECK=${THEME_BATTERY_PERCENTAGE_CHECK:=true} SCM_GIT_SHOW_DETAILS=${SCM_GIT_SHOW_DETAILS:=true} +SCM_GIT_SHOW_REMOTE_INFO=${SCM_GIT_SHOW_REMOTE_INFO:=auto} SCM_GIT='git' SCM_GIT_CHAR='±' @@ -111,6 +112,24 @@ function git_prompt_vars { local ref=$(git symbolic-ref -q HEAD 2> /dev/null) if [[ -n "$ref" ]]; then SCM_BRANCH=${SCM_THEME_BRANCH_PREFIX}${ref#refs/heads/} + local branch_tracking_info="$(grep "${SCM_BRANCH}..." <<< "${status}")" + if [[ -n "${branch_tracking_info}" ]]; then + branch_tracking_info=${branch_tracking_info#\#\# ${SCM_BRANCH}...} + branch_tracking_info=${branch_tracking_info% [*} + local remote_name=${branch_tracking_info%%/*} + local remote_branch=${branch_tracking_info#${remote_name}/} + local remote_info="" + local num_remotes=$(git remote | wc -l 2> /dev/null) + [[ "${SCM_BRANCH}" = "${remote_branch}" ]] && local same_branch_name=true + if ([[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "auto" ]] && [[ "${num_remotes}" -ge 2 ]]) || + [[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "true" ]]; then + remote_info="${remote_name}" + [[ "${same_branch_name}" != "true" ]] && remote_info+="/${remote_branch}" + elif [[ ${same_branch_name} != "true" ]]; then + remote_info="${remote_branch}" + fi + [[ -n "${remote_info}" ]] && SCM_BRANCH+=" (${remote_info})" + fi else ref=$(git describe --tags --exact-match 2> /dev/null) if [[ -n "$ref" ]]; then From 0943aec34b9349a7299cd4faa4cd3975ab616df2 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Sun, 6 Sep 2015 00:59:27 +0200 Subject: [PATCH 027/216] Improvements in git prompt - Git prompt now indicates when remote tracked branch is "gone" - New env var (SCM_GIT_DETACHED) that indicates when HEAD is detached - New env vars available for themes (SCM_THEME_BRANCH_TRACK_PREFIX, SCM_THEME_BRANCH_GONE_PREFIX, SCM_GIT_DETACHED_CHAR) - Refactor of git_prompt_vars function from base theme --- themes/base.theme.bash | 48 ++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index b1d79ed8..de1b4ad6 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -11,6 +11,8 @@ SCM_THEME_PROMPT_SUFFIX='|' SCM_THEME_BRANCH_PREFIX='' SCM_THEME_TAG_PREFIX='tag:' SCM_THEME_DETACHED_PREFIX='detached:' +SCM_THEME_BRANCH_TRACK_PREFIX=' → ' +SCM_THEME_BRANCH_GONE_PREFIX=' ⇢ ' CLOCK_CHAR='☆' THEME_CLOCK_CHECK=${THEME_CLOCK_CHECK:=true} @@ -21,6 +23,7 @@ SCM_GIT_SHOW_REMOTE_INFO=${SCM_GIT_SHOW_REMOTE_INFO:=auto} SCM_GIT='git' SCM_GIT_CHAR='±' +SCM_GIT_DETACHED_CHAR='⌿' SCM_GIT_AHEAD_CHAR="↑" SCM_GIT_BEHIND_CHAR="↓" SCM_GIT_UNTRACKED_CHAR="?:" @@ -112,12 +115,13 @@ function git_prompt_vars { local ref=$(git symbolic-ref -q HEAD 2> /dev/null) if [[ -n "$ref" ]]; then SCM_BRANCH=${SCM_THEME_BRANCH_PREFIX}${ref#refs/heads/} - local branch_tracking_info="$(grep "${SCM_BRANCH}..." <<< "${status}")" - if [[ -n "${branch_tracking_info}" ]]; then - branch_tracking_info=${branch_tracking_info#\#\# ${SCM_BRANCH}...} - branch_tracking_info=${branch_tracking_info% [*} - local remote_name=${branch_tracking_info%%/*} - local remote_branch=${branch_tracking_info#${remote_name}/} + local tracking_info="$(grep "${SCM_BRANCH}..." <<< "${status}")" + if [[ -n "${tracking_info}" ]]; then + [[ "${tracking_info}" =~ .+\[gone\]$ ]] && local branch_gone="true" + tracking_info=${tracking_info#\#\# ${SCM_BRANCH}...} + tracking_info=${tracking_info% [*} + local remote_name=${tracking_info%%/*} + local remote_branch=${tracking_info#${remote_name}/} local remote_info="" local num_remotes=$(git remote | wc -l 2> /dev/null) [[ "${SCM_BRANCH}" = "${remote_branch}" ]] && local same_branch_name=true @@ -128,26 +132,28 @@ function git_prompt_vars { elif [[ ${same_branch_name} != "true" ]]; then remote_info="${remote_branch}" fi - [[ -n "${remote_info}" ]] && SCM_BRANCH+=" (${remote_info})" - fi - else - ref=$(git describe --tags --exact-match 2> /dev/null) - if [[ -n "$ref" ]]; then - SCM_BRANCH=${SCM_THEME_TAG_PREFIX}${ref} - else - ref=$(git describe --contains --all HEAD 2> /dev/null) - if [[ -n "$ref" ]]; then - local remote_re='^remotes/(.+)$' - if [[ "$ref" =~ ${remote_re} ]]; then - SCM_BRANCH=${SCM_THEME_DETACHED_PREFIX}${BASH_REMATCH[1]} + if [[ -n "${remote_info}" ]];then + if [[ "${branch_gone}" = "true" ]]; then + SCM_BRANCH+="${SCM_THEME_BRANCH_GONE_PREFIX}${remote_info}" else - SCM_BRANCH=${SCM_THEME_DETACHED_PREFIX}${ref} + SCM_BRANCH+="${SCM_THEME_BRANCH_TRACK_PREFIX}${remote_info}" fi fi fi - if [[ -z "$ref" ]]; then - SCM_BRANCH=${SCM_THEME_DETACHED_PREFIX}${SCM_CHANGE} + SCM_GIT_DETACHED="false" + else + local detached_prefix="" + ref=$(git describe --tags --exact-match 2> /dev/null) + if [[ -n "$ref" ]]; then + detached_prefix=${SCM_THEME_TAG_PREFIX} + else + ref=$(git describe --contains --all HEAD 2> /dev/null) + ref=${ref#remotes/} + [[ -z "$ref" ]] && ref=${SCM_CHANGE} + detached_prefix=${SCM_THEME_DETACHED_PREFIX} fi + SCM_BRANCH=${detached_prefix}${ref} + SCM_GIT_DETACHED="true" fi local ahead_re='.+ahead ([0-9]+).+' From f823f89220f16eeddb098bbacdfee925b8c16bd5 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Sun, 6 Sep 2015 01:40:56 +0200 Subject: [PATCH 028/216] Update README.md --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index d3ed2c9c..63062d46 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,23 @@ Set `SCM_GIT_SHOW_DETAILS` to 'false' to **don't show** it: * `export SCM_GIT_SHOW_DETAILS=false` +### Git remotes and remote branches +In some git workflows you must work with various remotes, for this reason, Bash it can provide some useful information about your remotes and your remote branches, for example, the remote on you are working, or if your local branch is tracking a remote branch. + +You can control this feature with the flag `SCM_GIT_SHOW_REMOTE_INFO` as follows: + +Set `SCM_GIT_SHOW_REMOTE_INFO` to 'auto' (the default value) to activate it only when more than one remote is configured in the current repo: + +* `export SCM_GIT_SHOW_REMOTE_INFO=auto` + +Set `SCM_GIT_SHOW_REMOTE_INFO` to 'true' to always activate the feature: + +* `export SCM_GIT_SHOW_REMOTE_INFO=true` + +Set `SCM_GIT_SHOW_REMOTE_INFO` to 'false' to **disable the feature**: + +* `export SCM_GIT_SHOW_REMOTE_INFO=false` + #### pass function renamed to passgen The Bash it `pass` function has been renamed to `passgen` in order to avoid a naming conflict with the [pass password manager]. In order to minimize the impact on users of the legacy Bash it `pass` function, Bash it will create the alias `pass` that calls the new `passgen` function if the `pass` password manager command is not found on the `PATH` (default behavior). From ff87ad74825901c6a49f84af8fa5cb7fae48fbca Mon Sep 17 00:00:00 2001 From: Reto Haeberli Date: Sun, 6 Sep 2015 12:22:48 +0200 Subject: [PATCH 029/216] New binaryanomaly theme --- themes/binaryanomaly/binaryanomaly.theme.bash | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 themes/binaryanomaly/binaryanomaly.theme.bash diff --git a/themes/binaryanomaly/binaryanomaly.theme.bash b/themes/binaryanomaly/binaryanomaly.theme.bash new file mode 100644 index 00000000..58748f1d --- /dev/null +++ b/themes/binaryanomaly/binaryanomaly.theme.bash @@ -0,0 +1,105 @@ +#!/bin/bash + +# Set term to 256color mode, if 256color is not supported, colors won't work properly +if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then + export TERM=gnome-256color +elif infocmp xterm-256color >/dev/null 2>&1; then + export TERM=xterm-256color +fi + + +# Detect whether a rebbot is required +function show_reboot_required() { + if [ ! -z "$_bf_prompt_reboot_info" ]; then + if [ -f /var/run/reboot-required ]; then + printf "Reboot required!" + fi + fi +} + + +# Set different host color for local and remote sessions +function set_host_color() { + # Detect if connection is through SSH + if [[ ! -z $SSH_CLIENT ]]; then + printf "${lime_yellow}" + else + printf "${light_orange}" + fi +} + + +# Set different username color for users and root +function set_user_color() { + case $(id -u) in + 0) + printf "${red}" + ;; + *) + printf "${cyan}" + ;; + esac +} + + +scm_prompt() { + CHAR=$(scm_char) + if [ $CHAR = $SCM_NONE_CHAR ] + then + return + else + echo "[$(scm_char)$(scm_prompt_info)]" + fi +} + + + +# Define custom colors we need +# non-printable bytes in PS1 need to be contained within \[ \]. +# Otherwise, bash will count them in the length of the prompt +function set_custom_colors() { + dark_grey="\[$(tput setaf 8)\]" + light_grey="\[$(tput setaf 248)\]" + + light_orange="\[$(tput setaf 172)\]" + bright_yellow="\[$(tput setaf 220)\]" + lime_yellow="\[$(tput setaf 190)\]" + + powder_blue="\[$(tput setaf 153)\]" +} + + +function prompt_command() { + ps_reboot="${bright_yellow}$(show_reboot_required)${normal}\n" + ps_time="${dark_grey}\t${normal}\n" + + ps_username="$(set_user_color)\u${normal}" + ps_uh_separator="${dark_grey}@${normal}" + ps_hostname="$(set_host_color)\h${normal}" + + ps_path="${yellow}\w${normal}" + ps_scm_prompt="${light_grey}$(scm_prompt)" + + ps_user_mark="${normal} ${normal}" + ps_user_input="${normal}" + + # Set prompt + PS1="$ps_reboot$ps_time$ps_username$ps_uh_separator$ps_hostname $ps_path $ps_scm_prompt$ps_user_mark$ps_user_input" +} + + + +# Initialize custom colors +set_custom_colors + +# scm theming +SCM_THEME_PROMPT_PREFIX="" +SCM_THEME_PROMPT_SUFFIX="" + +SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗${light_grey}" +SCM_THEME_PROMPT_CLEAN=" ${green}✓${light_grey}" +SCM_GIT_CHAR="${green}±${light_grey}" +SCM_SVN_CHAR="${bold_cyan}⑆${light_grey}" +SCM_HG_CHAR="${bold_red}☿${light_grey}" + +PROMPT_COMMAND=prompt_command; From 858b6e95893240386ae570375eed2542a04898da Mon Sep 17 00:00:00 2001 From: Reto Haeberli Date: Sun, 6 Sep 2015 13:49:50 +0200 Subject: [PATCH 030/216] Apt and dpkg aliases for Ubuntu and Debian distros. --- aliases/available/apt.aliases.bash | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 aliases/available/apt.aliases.bash diff --git a/aliases/available/apt.aliases.bash b/aliases/available/apt.aliases.bash new file mode 100644 index 00000000..34deb0d1 --- /dev/null +++ b/aliases/available/apt.aliases.bash @@ -0,0 +1,28 @@ +#!/bin/bash +# +# -binaryanomaly + +cite 'about-alias' +about-alias 'Apt and dpkg aliases for Ubuntu and Debian distros.' + +# set apt aliases +function _set_pkg_aliases() +{ + if [ -x $(which apt) ]; then + alias apts='sudo apt-cache search' + alias aptshow='sudo apt-cache show' + alias aptinst='sudo apt-get install -V' + alias aptupd='sudo apt-get update' + alias aptupg='sudo apt-get dist-upgrade -V && sudo apt-get autoremove' + alias aptupgd='sudo apt-get update && sudo apt-get dist-upgrade -V && sudo apt-get autoremove' + alias aptrm='sudo apt-get remove' + alias aptpurge='sudo apt-get remove --purge' + + alias chkup='/usr/lib/update-notifier/apt-check -p --human-readable' + alias chkboot='cat /var/run/reboot-required' + + alias pkgfiles='dpkg --listfiles' + fi +} + +_set_pkg_aliases From 9006e7a59bde8327109203551fed68d661a30c21 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Sun, 6 Sep 2015 19:17:20 +0200 Subject: [PATCH 031/216] Mark gh plugin as deprecated, hub is suggested as replacement --- plugins/available/gh.plugin.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/available/gh.plugin.bash b/plugins/available/gh.plugin.bash index 64b16567..fb429317 100644 --- a/plugins/available/gh.plugin.bash +++ b/plugins/available/gh.plugin.bash @@ -1,4 +1,4 @@ cite about-plugin -about-plugin 'load gh, if you are using it.' +about-plugin 'load gh, if you are using it (DEPRECATED, use hub instead)' -command -v gh >/dev/null 2>&1 && eval "$(gh alias -s)" +command -v gh 2> /dev/null && eval "$(gh alias -s)" From 6799b151d4b0bae7fd41611cbe7d3c9b06032e45 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Sun, 6 Sep 2015 19:18:14 +0200 Subject: [PATCH 032/216] Add hub plugin and completion --- completion/available/hub.completion.bash | 362 +++++++++++++++++++++++ plugins/available/hub.plugin.bash | 4 + 2 files changed, 366 insertions(+) create mode 100644 completion/available/hub.completion.bash create mode 100644 plugins/available/hub.plugin.bash diff --git a/completion/available/hub.completion.bash b/completion/available/hub.completion.bash new file mode 100644 index 00000000..3e99aca7 --- /dev/null +++ b/completion/available/hub.completion.bash @@ -0,0 +1,362 @@ +# hub tab-completion script for bash. +# This script complements the completion script that ships with git. + +# Check that git tab completion is available +if declare -F _git > /dev/null; then + # Duplicate and rename the 'list_all_commands' function + eval "$(declare -f __git_list_all_commands | \ + sed 's/__git_list_all_commands/__git_list_all_commands_without_hub/')" + + # Wrap the 'list_all_commands' function with extra hub commands + __git_list_all_commands() { + cat <<-EOF +alias +pull-request +fork +create +browse +compare +ci-status +EOF + __git_list_all_commands_without_hub + } + + # Ensure cached commands are cleared + __git_all_commands="" + + ########################## + # hub command completions + ########################## + + # hub alias [-s] [SHELL] + _git_alias() { + local i c=2 s=-s sh shells="bash zsh sh ksh csh fish" + while [ $c -lt $cword ]; do + i="${words[c]}" + case "$i" in + -s) + unset s + ;; + *) + for sh in $shells; do + if [ "$sh" = "$i" ]; then + unset shells + break + fi + done + ;; + esac + ((c++)) + done + __gitcomp "$s $shells" + } + + # hub browse [-u] [--|[USER/]REPOSITORY] [SUBPAGE] + _git_browse() { + local i c=2 u=-u repo subpage + local subpages_="commits issues tree wiki pulls branches stargazers + contributors network network/ graphs graphs/" + local subpages_network="members" + local subpages_graphs="commit-activity code-frequency punch-card" + while [ $c -lt $cword ]; do + i="${words[c]}" + case "$i" in + -u) + unset u + ;; + *) + if [ -z "$repo" ]; then + repo=$i + else + subpage=$i + fi + ;; + esac + ((c++)) + done + if [ -z "$repo" ]; then + __gitcomp "$u -- $(__hub_github_repos '\p')" + elif [ -z "$subpage" ]; then + case "$cur" in + */*) + local pfx="${cur%/*}" cur_="${cur#*/}" + local subpages_var="subpages_$pfx" + __gitcomp "${!subpages_var}" "$pfx/" "$cur_" + ;; + *) + __gitcomp "$u ${subpages_}" + ;; + esac + else + __gitcomp "$u" + fi + } + + # hub compare [-u] [USER[/REPOSITORY]] [[START...]END] + _git_compare() { + local i c=$((cword - 1)) u=-u user remote owner repo arg_repo rev + while [ $c -gt 1 ]; do + i="${words[c]}" + case "$i" in + -u) + unset u + ;; + *) + if [ -z "$rev" ]; then + # Even though the logic below is able to complete both user/repo + # and revision in the right place, when there is only one argument + # (other than -u) in the command, that argument will be taken as + # revision. For example: + # $ hub compare -u upstream + # > https://github.com/USER/REPO/compare/upstream + if __hub_github_repos '\p' | grep -Eqx "^$i(/[^/]+)?"; then + arg_repo=$i + else + rev=$i + fi + elif [ -z "$arg_repo" ]; then + arg_repo=$i + fi + ;; + esac + ((c--)) + done + + # Here we want to find out the git remote name of user/repo, in order to + # generate an appropriate revision list + if [ -z "$arg_repo" ]; then + user=$(__hub_github_user) + if [ -z "$user" ]; then + for i in $(__hub_github_repos); do + remote=${i%%:*} + repo=${i#*:} + if [ "$remote" = origin ]; then + break + fi + done + else + for i in $(__hub_github_repos); do + remote=${i%%:*} + repo=${i#*:} + owner=${repo%%/*} + if [ "$user" = "$owner" ]; then + break + fi + done + fi + else + for i in $(__hub_github_repos); do + remote=${i%%:*} + repo=${i#*:} + owner=${repo%%/*} + case "$arg_repo" in + "$repo"|"$owner") + break + ;; + esac + done + fi + + local pfx cur_="$cur" + case "$cur_" in + *..*) + pfx="${cur_%%..*}..." + cur_="${cur_##*..}" + __gitcomp_nl "$(__hub_revlist $remote)" "$pfx" "$cur_" + ;; + *) + if [ -z "${arg_repo}${rev}" ]; then + __gitcomp "$u $(__hub_github_repos '\o\n\p') $(__hub_revlist $remote)" + elif [ -z "$rev" ]; then + __gitcomp "$u $(__hub_revlist $remote)" + else + __gitcomp "$u" + fi + ;; + esac + } + + # hub create [NAME] [-p] [-d DESCRIPTION] [-h HOMEPAGE] + _git_create() { + local i c=2 name repo flags="-p -d -h" + while [ $c -lt $cword ]; do + i="${words[c]}" + case "$i" in + -d|-h) + ((c++)) + flags=${flags/$i/} + ;; + -p) + flags=${flags/$i/} + ;; + *) + name=$i + ;; + esac + ((c++)) + done + if [ -z "$name" ]; then + repo=$(basename "$(pwd)") + fi + case "$prev" in + -d|-h) + COMPREPLY=() + ;; + -p|*) + __gitcomp "$repo $flags" + ;; + esac + } + + # hub fork [--no-remote] + _git_fork() { + local i c=2 remote=yes + while [ $c -lt $cword ]; do + i="${words[c]}" + case "$i" in + --no-remote) + unset remote + ;; + esac + ((c++)) + done + if [ -n "$remote" ]; then + __gitcomp "--no-remote" + fi + } + + # hub pull-request [-f] [-m |-F |-i |] [-b ] [-h ] + _git_pull_request() { + local i c=2 flags="-f -m -F -i -b -h" + while [ $c -lt $cword ]; do + i="${words[c]}" + case "$i" in + -m|-F|-i|-b|-h) + ((c++)) + flags=${flags/$i/} + ;; + -f) + flags=${flags/$i/} + ;; + esac + ((c++)) + done + case "$prev" in + -i) + COMPREPLY=() + ;; + -b|-h) + # (Doesn't seem to need this...) + # Uncomment the following line when 'owner/repo:[TAB]' misbehaved + #_get_comp_words_by_ref -n : cur + __gitcomp_nl "$(__hub_heads)" + # __ltrim_colon_completions "$cur" + ;; + -F) + COMPREPLY=( "$cur"* ) + ;; + -f|*) + __gitcomp "$flags" + ;; + esac + } + + ################### + # Helper functions + ################### + + # __hub_github_user [HOST] + # Return $GITHUB_USER or the default github user defined in hub config + # HOST - Host to be looked-up in hub config. Default is "github.com" + __hub_github_user() { + if [ -n "$GITHUB_USER" ]; then + echo $GITHUB_USER + return + fi + local line h k v host=${1:-github.com} config=${HUB_CONFIG:-~/.config/hub} + if [ -f "$config" ]; then + while read line; do + if [ "$line" = "---" ]; then + continue + fi + k=${line%%:*} + v=${line#*:} + if [ -z "$v" ]; then + if [ "$h" = "$host" ]; then + break + fi + h=$k + continue + fi + k=${k#* } + v=${v#* } + if [ "$h" = "$host" ] && [ "$k" = "user" ]; then + echo "$v" + break + fi + done < "$config" + fi + } + + # __hub_github_repos [FORMAT] + # List all github hosted repository + # FORMAT - Format string contains multiple of these: + # \m remote + # \p owner/repo + # \o owner + # escaped characters (\n, \t ...etc) work + # If omitted, prints all github repos in the format of "remote:owner/repo" + __hub_github_repos() { + local f format=$1 + if [ -z "$(__gitdir)" ]; then + return + fi + if [ -z "$format" ]; then + format='\1:\2' + else + format=${format//\m/\1} + format=${format//\p/\2} + format=${format//\o/\3} + fi + command git config --get-regexp 'remote\.[^.]*\.url' | + grep -E ' ((https?|git)://|git@)github\.com[:/][^:/]+/[^/]+$' | + sed -E 's#^remote\.([^.]+)\.url +.+[:/](([^/]+)/[^.]+)(\.git)?$#'"$format"'#' + } + + # __hub_heads + # List all local "branch", and remote "owner/repo:branch" + __hub_heads() { + local i remote repo branch dir=$(__gitdir) + if [ -d "$dir" ]; then + command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ + "refs/heads/" + for i in $(__hub_github_repos); do + remote=${i%%:*} + repo=${i#*:} + command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ + "refs/remotes/${remote}/" | while read branch; do + echo "${repo}:${branch#${remote}/}" + done + done + fi + } + + # __hub_revlist [REMOTE] + # List all tags, and branches under REMOTE, without the "remote/" prefix + # REMOTE - Remote name to search branches from. Default is "origin" + __hub_revlist() { + local i remote=${1:-origin} dir=$(__gitdir) + if [ -d "$dir" ]; then + command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ + "refs/remotes/${remote}/" | while read i; do + echo "${i#${remote}/}" + done + command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ + "refs/tags/" + fi + } + + # Enable completion for hub even when not using the alias + complete -o bashdefault -o default -o nospace -F _git hub 2>/dev/null \ + || complete -o default -o nospace -F _git hub +fi diff --git a/plugins/available/hub.plugin.bash b/plugins/available/hub.plugin.bash new file mode 100644 index 00000000..0a67a7af --- /dev/null +++ b/plugins/available/hub.plugin.bash @@ -0,0 +1,4 @@ +cite about-plugin +about-plugin 'load hub, if you are using it' + +command -v hub &> /dev/null && eval "$(hub alias -s)" From d0565e89541a12196adc85029abe826c3ff03965 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Sun, 6 Sep 2015 20:02:20 +0200 Subject: [PATCH 033/216] Add a flag (SCM_GIT_IGNORE_UNTRACKED) to ignore untracked files in git prompt --- themes/base.theme.bash | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index de1b4ad6..1393abd4 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -20,6 +20,7 @@ THEME_BATTERY_PERCENTAGE_CHECK=${THEME_BATTERY_PERCENTAGE_CHECK:=true} SCM_GIT_SHOW_DETAILS=${SCM_GIT_SHOW_DETAILS:=true} SCM_GIT_SHOW_REMOTE_INFO=${SCM_GIT_SHOW_REMOTE_INFO:=auto} +SCM_GIT_IGNORE_UNTRACKED=${SCM_GIT_IGNORE_UNTRACKED:=false} SCM_GIT='git' SCM_GIT_CHAR='±' @@ -95,7 +96,9 @@ function git_prompt_vars { local details='' SCM_STATE=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} if [[ "$(git config --get bash-it.hide-status)" != "1" ]]; then - local status="$(git status -b --porcelain 2> /dev/null || git status --porcelain 2> /dev/null)" + [[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && local git_status_flags='-uno' + local status="$(git status -b --porcelain ${git_status_flags} 2> /dev/null || + git status --porcelain ${git_status_flags} 2> /dev/null)" if [[ -n "${status}" ]] && [[ "${status}" != "\n" ]] && [[ -n "$(grep -v ^# <<< "${status}")" ]]; then SCM_DIRTY=1 if [[ "${SCM_GIT_SHOW_DETAILS}" = "true" ]]; then From f48731fb11ceb16cc81509859f0ee0e6bfb693a3 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Sun, 6 Sep 2015 20:18:57 +0200 Subject: [PATCH 034/216] Update README.md --- README.md | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 63062d46..a486d67e 100644 --- a/README.md +++ b/README.md @@ -66,10 +66,12 @@ This will restore your previous Bash profile. After the uninstall script finishe ## Misc ### Bash Profile Aliases + Bash it creates a `reload` alias that makes it convenient to reload your bash profile when you make changes. ### Prompt Version Control Check + Bash it provides prompt themes the ability to check and display version control information for the current directory. The information is retrieved for each directory and can slow down the navigation of projects with a large number of files and folders. Turn version control checking off to prevent slow directory navigation within large projects. Bash it provides a flag (`SCM_CHECK`) within the `~/.bash_profile` file that turns off/on version control information checking and display within all themes. Version control checking is on by default unless explicitly turned off. @@ -85,10 +87,15 @@ Set `SCM_CHECK` to 'true' (the default value) to **turn on** version control che **NOTE:** It is possible for themes to ignore the `SCM_CHECK` flag and query specific version control information directly. For example, themes that use functions like `git_prompt_vars` skip the `SCM_CHECK` flag to retrieve and display git prompt information. If you turned version control checking off and you still see version control information within your prompt, then functions like `git_prompt_vars` are most likely the reason why. -### Git repository info in the prompt +### Git prompt + +Bash it has some nice features related to git, continue reading to know more about. + +#### Repository info in the prompt + Bash it can show some information about Git repositories in the shell prompt: the current branch, tag or commit you are at, how many commits the local branch is ahead or behind from the remote branch, and if you have changes stashed. -Additionally, you can view the status of your working copy and get the count of staged, unstaged and untracked files. This feature is controlled through the flag `SCM_GIT_SHOW_DETAILS` as follows: +Additionally, you can view the status of your working copy and get the count of *staged*, *unstaged* and *untracked* files. This feature is controlled through the flag `SCM_GIT_SHOW_DETAILS` as follows: Set `SCM_GIT_SHOW_DETAILS` to 'true' (the default value) to **show** the working copy details in your prompt: @@ -98,7 +105,8 @@ Set `SCM_GIT_SHOW_DETAILS` to 'false' to **don't show** it: * `export SCM_GIT_SHOW_DETAILS=false` -### Git remotes and remote branches +#### Remotes and remote branches + In some git workflows you must work with various remotes, for this reason, Bash it can provide some useful information about your remotes and your remote branches, for example, the remote on you are working, or if your local branch is tracking a remote branch. You can control this feature with the flag `SCM_GIT_SHOW_REMOTE_INFO` as follows: @@ -115,6 +123,22 @@ Set `SCM_GIT_SHOW_REMOTE_INFO` to 'false' to **disable the feature**: * `export SCM_GIT_SHOW_REMOTE_INFO=false` +#### Untracked files + +By default, `git status` command shows information about *untracked* files, this behavior can be controlled through command line flags or git configuration files, for big repositories, ignoring *untracked* files can make git faster. Bash it uses `git status` to gather the repo information it shows in the prompt, so in some circumstances, can be useful to instruct Bash it to ignore these files. You can control this behavior with the flag `SCM_GIT_IGNORE_UNTRACKED`: + +Set `SCM_GIT_IGNORE_UNTRACKED` to 'true' (the default value) to get information about *untracked* files: + +* `export SCM_GIT_IGNORE_UNTRACKED=true` + +Set `SCM_GIT_IGNORE_UNTRACKED` to 'false' to **ignore** *untracked* files: + +* `export SCM_GIT_IGNORE_UNTRACKED=false` + +also, with this flag to false, Bash it will not show the repository as dirty when the repo have *untracked* files, and will not display the count of *untracked* files. + +**NOTE:** If you set in git configuration file the option to ignore *untracked* files, this flag has no effect, and Bash it will ignore *untracked* files always. + #### pass function renamed to passgen The Bash it `pass` function has been renamed to `passgen` in order to avoid a naming conflict with the [pass password manager]. In order to minimize the impact on users of the legacy Bash it `pass` function, Bash it will create the alias `pass` that calls the new `passgen` function if the `pass` password manager command is not found on the `PATH` (default behavior). From 39a2c37524d08cf3246a1b985f668ce871f9b2a9 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Sun, 6 Sep 2015 22:17:11 +0200 Subject: [PATCH 035/216] Fix wrong flag description --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a486d67e..1350fb56 100644 --- a/README.md +++ b/README.md @@ -127,14 +127,14 @@ Set `SCM_GIT_SHOW_REMOTE_INFO` to 'false' to **disable the feature**: By default, `git status` command shows information about *untracked* files, this behavior can be controlled through command line flags or git configuration files, for big repositories, ignoring *untracked* files can make git faster. Bash it uses `git status` to gather the repo information it shows in the prompt, so in some circumstances, can be useful to instruct Bash it to ignore these files. You can control this behavior with the flag `SCM_GIT_IGNORE_UNTRACKED`: -Set `SCM_GIT_IGNORE_UNTRACKED` to 'true' (the default value) to get information about *untracked* files: - -* `export SCM_GIT_IGNORE_UNTRACKED=true` - -Set `SCM_GIT_IGNORE_UNTRACKED` to 'false' to **ignore** *untracked* files: +Set `SCM_GIT_IGNORE_UNTRACKED` to 'false' (the default value) to get information about *untracked* files: * `export SCM_GIT_IGNORE_UNTRACKED=false` +Set `SCM_GIT_IGNORE_UNTRACKED` to 'true' to **ignore** *untracked* files: + +* `export SCM_GIT_IGNORE_UNTRACKED=true` + also, with this flag to false, Bash it will not show the repository as dirty when the repo have *untracked* files, and will not display the count of *untracked* files. **NOTE:** If you set in git configuration file the option to ignore *untracked* files, this flag has no effect, and Bash it will ignore *untracked* files always. From 3c97ee84da1176c01ff84791eb10cab7d9d6e0f7 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Sun, 6 Sep 2015 22:29:06 +0200 Subject: [PATCH 036/216] Minor corrections in README.md --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1350fb56..c2ba06bc 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Build Status](https://travis-ci.org/Bash-it/bash-it.svg?branch=master)](https://travis-ci.org/Bash-it/bash-it) [![Join the chat at https://gitter.im/Bash-it/bash-it](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Bash-it/bash-it?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -**Bash it** is a collection of community bash commands and scripts. (And a shameless ripoff of [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh). :) +**Bash it** is a collection of community bash commands and scripts. (And a shameless ripoff of [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) :smiley:) Includes autocompletion, themes, aliases, custom functions, a few stolen pieces from Steve Losh, and more. @@ -46,9 +46,9 @@ Anything in the custom directory will be ignored, with the exception of `custom/ ## Themes -There are a few bash it themes. If you've created your own custom prompts, I'd love it if you shared with everyone else! Just submit a Pull Request to me (revans). +There are a few bash it themes. If you've created your own custom prompts, I'd love it if you shared with everyone else! Just submit a Pull Request to me (revans). -You can see the theme screenshots [here](https://github.com/revans/bash-it/wiki/Themes) +You can see the theme screenshots [here](https://github.com/revans/bash-it/wiki/Themes) Alternatively, you can preview the themes in your own shell using `BASH_PREVIEW=true reload` @@ -85,7 +85,7 @@ Set `SCM_CHECK` to 'true' (the default value) to **turn on** version control che * `export SCM_CHECK=true` **NOTE:** -It is possible for themes to ignore the `SCM_CHECK` flag and query specific version control information directly. For example, themes that use functions like `git_prompt_vars` skip the `SCM_CHECK` flag to retrieve and display git prompt information. If you turned version control checking off and you still see version control information within your prompt, then functions like `git_prompt_vars` are most likely the reason why. +It is possible for themes to ignore the `SCM_CHECK` flag and query specific version control information directly. For example, themes that use functions like `git_prompt_vars` skip the `SCM_CHECK` flag to retrieve and display git prompt information. If you turned version control checking off and you still see version control information within your prompt, then functions like `git_prompt_vars` are most likely the reason why. ### Git prompt @@ -139,7 +139,7 @@ also, with this flag to false, Bash it will not show the repository as dirty whe **NOTE:** If you set in git configuration file the option to ignore *untracked* files, this flag has no effect, and Bash it will ignore *untracked* files always. -#### pass function renamed to passgen +### pass function renamed to passgen The Bash it `pass` function has been renamed to `passgen` in order to avoid a naming conflict with the [pass password manager]. In order to minimize the impact on users of the legacy Bash it `pass` function, Bash it will create the alias `pass` that calls the new `passgen` function if the `pass` password manager command is not found on the `PATH` (default behavior). @@ -153,7 +153,7 @@ Unset `BASH_IT_LEGACY_PASS` to have Bash it **return to default behavior**: * `unset BASH_IT_LEGACY_PASS` -#### Proxy Support +### Proxy Support If you are working in a corporate environment where you have to go through a proxy server for internet access, then you know how painful it is to configure the OS proxy variables in the shell, especially if you are switching between environments, e.g. office (with proxy) and home (without proxy). @@ -186,7 +186,7 @@ There are many more proxy commands, e.g. for changing the local Git project's pr ## Help out -We think everyone has their own custom scripts accumulated over time. And so, following in the footsteps of oh-my-zsh, Bash it is a framework for easily customizing your bash shell. Everyone's got a custom toolbox, so let's start making them even better, **as a community!** +We think everyone has their own custom scripts accumulated over time. And so, following in the footsteps of oh-my-zsh, Bash it is a framework for easily customizing your bash shell. Everyone's got a custom toolbox, so let's start making them even better, **as a community!** Send us a pull request and we'll merge it as long as it looks good. If you change an existing command, please give an explanation why. That will help a lot when we merge your changes in. From 14490362858519d558f21bc8eab7cf276bf11db2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matias=20Iba=C3=B1ez?= Date: Mon, 7 Sep 2015 01:43:40 -0300 Subject: [PATCH 037/216] Update simple theme PS1 definition via PROMPT variable produces an invalid prompt --- themes/simple/simple.theme.bash | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/themes/simple/simple.theme.bash b/themes/simple/simple.theme.bash index 39e16a1c..8b897ddc 100644 --- a/themes/simple/simple.theme.bash +++ b/themes/simple/simple.theme.bash @@ -11,11 +11,15 @@ case $TERM in TITLEBAR="" ;; esac -PROMPT="${TITLEBAR}${orange}${reset_color}${green}\w${bold_blue}\[\$(scm_prompt_info)\]${reset_color} " +function prompt_command() { + PS1="${TITLEBAR}${orange}${reset_color}${green}\w${bold_blue}\[\$(scm_prompt_info)\]${reset_color} " +} # scm themeing SCM_THEME_PROMPT_DIRTY=" ✗" SCM_THEME_PROMPT_CLEAN=" ✓" SCM_THEME_PROMPT_PREFIX="(" SCM_THEME_PROMPT_SUFFIX=")" + +PROMPT_COMMAND=prompt_command; From 994c235b3f321c8805d83022844667fc34325ccd Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Mon, 7 Sep 2015 08:54:29 +0200 Subject: [PATCH 038/216] Fixed a couple of repo references --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c2ba06bc..39a73bd0 100644 --- a/README.md +++ b/README.md @@ -46,9 +46,9 @@ Anything in the custom directory will be ignored, with the exception of `custom/ ## Themes -There are a few bash it themes. If you've created your own custom prompts, I'd love it if you shared with everyone else! Just submit a Pull Request to me (revans). +There are a few bash it themes. If you've created your own custom prompts, I'd love it if you shared with everyone else! Just submit a Pull Request. -You can see the theme screenshots [here](https://github.com/revans/bash-it/wiki/Themes) +You can see the theme screenshots [here](https://github.com/Bash-it/bash-it/wiki/Themes) Alternatively, you can preview the themes in your own shell using `BASH_PREVIEW=true reload` @@ -89,7 +89,7 @@ It is possible for themes to ignore the `SCM_CHECK` flag and query specific vers ### Git prompt -Bash it has some nice features related to git, continue reading to know more about. +Bash it has some nice features related to Git, continue reading to know more about these features. #### Repository info in the prompt @@ -197,5 +197,5 @@ Thanks, and happing bashing! * [List of contributors][contribute] -[contribute]: https://github.com/revans/bash-it/contributors +[contribute]: https://github.com/Bash-it/bash-it/contributors [pass password manager]: http://www.passwordstore.org/ From 7384b284ec737ce0b3ec803d9108b7f94f6d8057 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Mon, 7 Sep 2015 09:56:16 +0200 Subject: [PATCH 039/216] Added alias completion to the default install options --- install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install.sh b/install.sh index 3baa1d58..38b5d64e 100755 --- a/install.sh +++ b/install.sh @@ -89,6 +89,7 @@ else echo "" echo -e "\033[0;32mEnabling sane defaults\033[0m" load_one completion bash-it.completion.bash + load_one plugins alias-completion.bash fi echo "" From 546f90e368da2b132577efdb91da1c53cfc3d104 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Mon, 7 Sep 2015 12:46:34 +0200 Subject: [PATCH 040/216] Fixed reference and typo --- plugins/available/alias-completion.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/available/alias-completion.bash b/plugins/available/alias-completion.bash index 3949c78d..75c8263f 100644 --- a/plugins/available/alias-completion.bash +++ b/plugins/available/alias-completion.bash @@ -2,7 +2,7 @@ cite about-plugin about-plugin 'Automatic completion of aliases' # References: -# http://superuser.com/questions/436314/how-can-i-get-bash-to-perform-tab-completion-for-my-aliases +# http://superuser.com/a/437508/119764 # http://stackoverflow.com/a/1793178/1228454 # This needs to be a plugin so it gets executed after the completions and the aliases have been defined. @@ -36,7 +36,7 @@ function alias_completion { eval "local alias_tokens; alias_tokens=($line)" 2>/dev/null || continue # some alias arg patterns cause an eval parse error local alias_name="${alias_tokens[0]}" alias_cmd="${alias_tokens[1]}" alias_args="${alias_tokens[2]# }" - # skip aliases to pipes, boolan control structures and other command lists + # skip aliases to pipes, boolean control structures and other command lists # (leveraging that eval errs out if $alias_args contains unquoted shell metacharacters) eval "local alias_arg_words; alias_arg_words=($alias_args)" 2>/dev/null || continue # avoid expanding wildcards From d751b3da676f39b05e58a6b8adca7260ec8c2d98 Mon Sep 17 00:00:00 2001 From: Lyle Franklin Date: Tue, 8 Sep 2015 18:03:10 -0700 Subject: [PATCH 041/216] Rename docker-machine file to include 'plugin' - We have some automation around enabling plugins which expects the word 'plugin' --- .../available/{docker-machine.bash => docker-machine.plugin.bash} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename plugins/available/{docker-machine.bash => docker-machine.plugin.bash} (100%) diff --git a/plugins/available/docker-machine.bash b/plugins/available/docker-machine.plugin.bash similarity index 100% rename from plugins/available/docker-machine.bash rename to plugins/available/docker-machine.plugin.bash From 412bb7fc88d3ebf39571a7f0e20609ef2c8a6375 Mon Sep 17 00:00:00 2001 From: Lyle Franklin Date: Wed, 9 Sep 2015 09:38:07 -0700 Subject: [PATCH 042/216] Replace `~` with $HOME in docker-machine plugin The `~` caused docker commands to error with the following: ``` $ docker images Could not read CA certificate "~/.docker/machine/machines/dev/ca.pem" ``` Switching to $HOME fixes the issue --- plugins/available/docker-machine.plugin.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/available/docker-machine.plugin.bash b/plugins/available/docker-machine.plugin.bash index 18bf8ace..8c6c146f 100644 --- a/plugins/available/docker-machine.plugin.bash +++ b/plugins/available/docker-machine.plugin.bash @@ -5,7 +5,7 @@ about-plugin 'Helpers to get Docker setup correctly for docker-machine' # or its configured for a different IP if [[ `uname -s` == "Darwin" ]]; then export DOCKER_HOST="tcp://192.168.99.100:2376" - export DOCKER_CERT_PATH="~/.docker/machine/machines/dev" + export DOCKER_CERT_PATH="$HOME/.docker/machine/machines/dev" export DOCKER_TLS_VERIFY=1 export DOCKER_MACHINE_NAME="dev" fi From 86b9af62c34588bbec14de5979e661eab31af341 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Thu, 10 Sep 2015 20:07:04 +0200 Subject: [PATCH 043/216] Fix grep pattern --- themes/base.theme.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 1393abd4..fc5e529a 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -118,7 +118,7 @@ function git_prompt_vars { local ref=$(git symbolic-ref -q HEAD 2> /dev/null) if [[ -n "$ref" ]]; then SCM_BRANCH=${SCM_THEME_BRANCH_PREFIX}${ref#refs/heads/} - local tracking_info="$(grep "${SCM_BRANCH}..." <<< "${status}")" + local tracking_info="$(grep "${SCM_BRANCH}\.\.\." <<< "${status}")" if [[ -n "${tracking_info}" ]]; then [[ "${tracking_info}" =~ .+\[gone\]$ ]] && local branch_gone="true" tracking_info=${tracking_info#\#\# ${SCM_BRANCH}...} From e4ef3b1f504f9916694c189c403254495a7e3d4c Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Fri, 11 Sep 2015 16:07:07 +0200 Subject: [PATCH 044/216] Add doc for feature added in PR #280 --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 39a73bd0..912da87e 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,24 @@ also, with this flag to false, Bash it will not show the repository as dirty whe **NOTE:** If you set in git configuration file the option to ignore *untracked* files, this flag has no effect, and Bash it will ignore *untracked* files always. +#### Ignore repo status + +When working in repos with a large code base Bash it can slow down your prompt when checking the repo status, to avoid it, there is an option you can set via Git config to disable checking repo status in Bash it. + +To disable checking the status in the current repo: + +``` +$ git config --add bash-it.hide-status 1 +``` + +But if you would like to disable it globally, and stop checking the status for all of your repos: + +``` +$ git config --global --add bash-it.hide-status 1 +``` + +setting this flag globally has the same effect that `SCM_CHECK=true` but only for Git repos. + ### pass function renamed to passgen The Bash it `pass` function has been renamed to `passgen` in order to avoid a naming conflict with the [pass password manager]. In order to minimize the impact on users of the legacy Bash it `pass` function, Bash it will create the alias `pass` that calls the new `passgen` function if the `pass` password manager command is not found on the `PATH` (default behavior). From cf06aea3c762175d573c18343f8e512ec18bb744 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Tue, 15 Sep 2015 15:33:09 -0400 Subject: [PATCH 045/216] Set executable flag on uninstall script --- uninstall.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 uninstall.sh diff --git a/uninstall.sh b/uninstall.sh old mode 100644 new mode 100755 From c74378632f66e1b49dfa9075b1a237f74e497a8b Mon Sep 17 00:00:00 2001 From: cornfeedhobo Date: Sat, 26 Sep 2015 18:32:01 -0500 Subject: [PATCH 046/216] added projects plugin and completion --- completion/available/projects.completion.bash | 44 +++++++++++++++++++ plugins/available/projects.plugin.bash | 31 +++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 completion/available/projects.completion.bash create mode 100644 plugins/available/projects.plugin.bash diff --git a/completion/available/projects.completion.bash b/completion/available/projects.completion.bash new file mode 100644 index 00000000..f090f562 --- /dev/null +++ b/completion/available/projects.completion.bash @@ -0,0 +1,44 @@ +_pj() { + [ -z "$PROJECT_PATHS" ] && return + + shift + + [ "$1" == "open" ] && shift + + local cur prev words cword + _init_completion || return + + local IFS=$'\n' i j k + + compopt -o filenames + + local -r mark_dirs=$(_rl_enabled mark-directories && echo y) + local -r mark_symdirs=$(_rl_enabled mark-symlinked-directories && echo y) + + for i in ${PROJECT_PATHS//:/$'\n'}; do + # create an array of matched subdirs + k="${#COMPREPLY[@]}" + for j in $( compgen -d $i/$cur ); do + if [[ ( $mark_symdirs && -h $j || $mark_dirs && ! -h $j ) && ! -d ${j#$i/} ]]; then + j+="/" + fi + COMPREPLY[k++]=${j#$i/} + done + done + + _filedir -d + + if [[ ${#COMPREPLY[@]} -eq 1 ]]; then + i=${COMPREPLY[0]} + if [[ "$i" == "$cur" && $i != "*/" ]]; then + COMPREPLY[0]="${i}/" + fi + fi + + return 0 +} +if shopt -q cdable_vars; then + complete -v -F _pj -o nospace pj +else + complete -F _pj -o nospace pj +fi diff --git a/plugins/available/projects.plugin.bash b/plugins/available/projects.plugin.bash new file mode 100644 index 00000000..6e4926ca --- /dev/null +++ b/plugins/available/projects.plugin.bash @@ -0,0 +1,31 @@ +cite about-plugin +about-plugin 'add "export PROJECT_PATHS=~/projects:~/intertrode/projects" to navigate quickly to your project directories with `pj` and `pjo`' + +function pj { + about 'navigate quickly to your various project directories' + group 'projects' + + if [ -n "$PROJECT_PATHS" ]; then + local cmd + + if [ "$1" == "open" ]; then + shift + cmd="$EDITOR" + fi + + cmd="${cmd:-cd}" + + if [ -n "$1" ]; then + for i in ${PROJECT_PATHS//:/$'\n'}; do + if [ -d "$i"/"$1" ]; then + $cmd "$i"/"$1" + return + fi + done + fi + fi + + echo "No such project '$1'" +} + +alias pjo="pj open" From 79d4d84c5cd82e224b7f37e80204defca0a87e86 Mon Sep 17 00:00:00 2001 From: Nick Twyman Date: Sat, 26 Sep 2015 16:49:34 -0700 Subject: [PATCH 047/216] Addresses duplicate emacs alias use of 'et'. See Issue #578 --- aliases/available/emacs.aliases.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aliases/available/emacs.aliases.bash b/aliases/available/emacs.aliases.bash index 597ae2dd..1116b117 100644 --- a/aliases/available/emacs.aliases.bash +++ b/aliases/available/emacs.aliases.bash @@ -4,7 +4,7 @@ about-alias 'emacs editor' case $OSTYPE in linux*) alias em='emacs' - alias et='emacs -nw' + alias en='emacs -nw' alias e='emacsclient -n' alias et='emacsclient -t' alias ed='emacs --daemon' From 94d37939e5365e7e289d5fbb5d41295a5df60914 Mon Sep 17 00:00:00 2001 From: joe DeCapo Date: Tue, 29 Sep 2015 01:41:56 -0500 Subject: [PATCH 048/216] Add `gf` alias for fetching all and pruning --- aliases/available/git.aliases.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/aliases/available/git.aliases.bash b/aliases/available/git.aliases.bash index 819f1450..4982686f 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -5,6 +5,7 @@ about-alias 'common git abbreviations' alias gcl='git clone' alias ga='git add' alias gall='git add .' +alias gf='git fetch --all --prune' alias gus='git reset HEAD' alias gm="git merge" alias g='git' From 8744f6899c898eb5ef143eb62a643d2ddb7e0bfc Mon Sep 17 00:00:00 2001 From: cornfeedhobo Date: Wed, 30 Sep 2015 01:32:47 -0500 Subject: [PATCH 049/216] fixed to not also include the current directory --- completion/available/projects.completion.bash | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/completion/available/projects.completion.bash b/completion/available/projects.completion.bash index f090f562..a46864b7 100644 --- a/completion/available/projects.completion.bash +++ b/completion/available/projects.completion.bash @@ -1,8 +1,6 @@ _pj() { [ -z "$PROJECT_PATHS" ] && return - shift - [ "$1" == "open" ] && shift local cur prev words cword @@ -26,8 +24,6 @@ _pj() { done done - _filedir -d - if [[ ${#COMPREPLY[@]} -eq 1 ]]; then i=${COMPREPLY[0]} if [[ "$i" == "$cur" && $i != "*/" ]]; then @@ -37,8 +33,6 @@ _pj() { return 0 } -if shopt -q cdable_vars; then - complete -v -F _pj -o nospace pj -else - complete -F _pj -o nospace pj -fi + +complete -F _pj -o nospace pj + From ca3f1baf80dac99e40677c46a196eaf29f2703ad Mon Sep 17 00:00:00 2001 From: Miguel Morales Date: Wed, 7 Oct 2015 15:55:38 -0500 Subject: [PATCH 050/216] Add del function to the base plugins --- plugins/available/base.plugin.bash | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/available/base.plugin.bash b/plugins/available/base.plugin.bash index accd3610..06c52f65 100644 --- a/plugins/available/base.plugin.bash +++ b/plugins/available/base.plugin.bash @@ -223,3 +223,11 @@ function buf () local filetime=$(date +%Y%m%d_%H%M%S) cp -a "${filename}" "${filename}_${filetime}" } + +function del() { + about 'move files to hidden folder in tmp, that gets cleared on each reboot' + param 'file or folder to be deleted' + example 'del ./file.txt' + group 'base' + mkdir -p /tmp/.trash && mv "$@" /tmp/.trash; +} From 9c23a1507572f56a62e73045ebce7a0db0d9a0ee Mon Sep 17 00:00:00 2001 From: Lyle Franklin Date: Wed, 7 Oct 2015 13:56:40 -0700 Subject: [PATCH 051/216] Source docker-machine environment variables rather than hardcoding Signed-off-by: Frank Kotsianas --- plugins/available/docker-machine.plugin.bash | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/plugins/available/docker-machine.plugin.bash b/plugins/available/docker-machine.plugin.bash index 8c6c146f..20bf0f29 100644 --- a/plugins/available/docker-machine.plugin.bash +++ b/plugins/available/docker-machine.plugin.bash @@ -4,8 +4,5 @@ about-plugin 'Helpers to get Docker setup correctly for docker-machine' # Note, this might need to be different if you use a machine other than 'dev', # or its configured for a different IP if [[ `uname -s` == "Darwin" ]]; then - export DOCKER_HOST="tcp://192.168.99.100:2376" - export DOCKER_CERT_PATH="$HOME/.docker/machine/machines/dev" - export DOCKER_TLS_VERIFY=1 - export DOCKER_MACHINE_NAME="dev" + eval "$(docker-machine env dev)" fi From f59ab436e4042a16d1a32986b20f018cc1365feb Mon Sep 17 00:00:00 2001 From: Miguel Morales Date: Wed, 7 Oct 2015 15:57:09 -0500 Subject: [PATCH 052/216] Delete del.plugin.bash --- plugins/available/del.plugin.bash | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 plugins/available/del.plugin.bash diff --git a/plugins/available/del.plugin.bash b/plugins/available/del.plugin.bash deleted file mode 100644 index 4f4237a0..00000000 --- a/plugins/available/del.plugin.bash +++ /dev/null @@ -1,7 +0,0 @@ -cite about-plugin -about-plugin 'soft delete by moving contents into a hidden folder in tmp' - -# the tmp folder gets cleared on reboot -# so this would actually remove the file on -# shutdown -function del() { mkdir -p /tmp/.trash && mv "$@" /tmp/.trash; } From f5d4210ffdec2f69141633a4dc9ad6a9523da524 Mon Sep 17 00:00:00 2001 From: Miguel Morales Date: Wed, 7 Oct 2015 15:57:19 -0500 Subject: [PATCH 053/216] Delete mkcd.plugin.bash --- plugins/available/mkcd.plugin.bash | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 plugins/available/mkcd.plugin.bash diff --git a/plugins/available/mkcd.plugin.bash b/plugins/available/mkcd.plugin.bash deleted file mode 100644 index bea43f99..00000000 --- a/plugins/available/mkcd.plugin.bash +++ /dev/null @@ -1,4 +0,0 @@ -cite about-plugin -about-plugin 'make and cd into a directory in one command' - -function mkcd () { mkdir -p "$@" && eval cd "\"\$$#\""; } From e704bd72f3cd9ff5b4fcae533cd71b0118eb48ed Mon Sep 17 00:00:00 2001 From: Shash Reddy Date: Thu, 8 Oct 2015 11:11:12 -0700 Subject: [PATCH 054/216] Check whether docker-machine dev is running before configuring env variables Signed-off-by: Lyle Franklin --- plugins/available/docker-machine.plugin.bash | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/available/docker-machine.plugin.bash b/plugins/available/docker-machine.plugin.bash index 20bf0f29..fc2dc44d 100644 --- a/plugins/available/docker-machine.plugin.bash +++ b/plugins/available/docker-machine.plugin.bash @@ -1,8 +1,11 @@ cite about-plugin about-plugin 'Helpers to get Docker setup correctly for docker-machine' -# Note, this might need to be different if you use a machine other than 'dev', -# or its configured for a different IP +# Note, this might need to be different if you use a machine other than 'dev' if [[ `uname -s` == "Darwin" ]]; then - eval "$(docker-machine env dev)" + # check if dev machine is running + docker-machine ls | grep --quiet 'dev.*Running' + if [[ "$?" = "0" ]]; then + eval "$(docker-machine env dev)" + fi fi From 7923b865ea997ef16a0560bc39c49dbe74c20223 Mon Sep 17 00:00:00 2001 From: Justin Dray Date: Wed, 14 Oct 2015 13:08:04 +0000 Subject: [PATCH 055/216] Allow for any install location --- install.sh | 10 ++++++---- template/bash_profile.template.bash | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 38b5d64e..77ce7270 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -BASH_IT="$HOME/.bash_it" +BASH_IT="$(dirname "$(readlink -f "$0")")" case $OSTYPE in darwin*) @@ -36,18 +36,20 @@ test -w "$HOME/$CONFIG_FILE" && cp -a "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" && echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m" -cp "$HOME/.bash_it/template/bash_profile.template.bash" "$HOME/$CONFIG_FILE" +cp "$BASH_IT/template/bash_profile.template.bash" "$HOME/$CONFIG_FILE" +sed -i "s|{{BASH_IT}}|$BASH_IT|" "$HOME/$CONFIG_FILE" +exit echo -e "\033[0;32mCopied the template $CONFIG_FILE into ~/$CONFIG_FILE, edit this file to customize bash-it\033[0m" function load_one() { file_type=$1 file_to_enable=$2 - [ ! -d "$BASH_IT/$file_type/enabled" ] && mkdir "$BASH_IT/${file_type}/enabled" + mkdir -p "$BASH_IT/${file_type}/enabled" dest="${BASH_IT}/${file_type}/enabled/${file_to_enable}" if [ ! -e "${dest}" ]; then - ln -s "../available/${file_to_enable}" "${dest}" + ln -sf "../available/${file_to_enable}" "${dest}" else echo "File ${dest} exists, skipping" fi diff --git a/template/bash_profile.template.bash b/template/bash_profile.template.bash index 9fda847e..94e04209 100755 --- a/template/bash_profile.template.bash +++ b/template/bash_profile.template.bash @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Path to the bash it configuration -export BASH_IT="$HOME/.bash_it" +export BASH_IT="{{BASH_IT}}" # Lock and Load a custom theme file # location /.bash_it/themes/ From 2d60d6ccd4ccdb7fc8b2f716da25db205b1da7e7 Mon Sep 17 00:00:00 2001 From: James Cuzella Date: Wed, 14 Oct 2015 09:59:11 -0600 Subject: [PATCH 056/216] Adding mankier.com explain() function to explain other commands --- plugins/available/explain.plugin.bash | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 plugins/available/explain.plugin.bash diff --git a/plugins/available/explain.plugin.bash b/plugins/available/explain.plugin.bash new file mode 100644 index 00000000..b2d9593a --- /dev/null +++ b/plugins/available/explain.plugin.bash @@ -0,0 +1,23 @@ +cite about-plugin +about-plugin 'mankier.com explain function to explain other commands' + +# Add this to ~/.bash_profile or ~/.bashrc +explain () { + if [ "$#" -eq 0 ]; then + while read -p "Command: " cmd; do + curl -Gs "https://www.mankier.com/api/explain/?cols="$(tput cols) --data-urlencode "q=$cmd" + done + echo "Bye!" + elif [ "$#" -eq 1 ]; then + curl -Gs "https://www.mankier.com/api/explain/?cols="$(tput cols) --data-urlencode "q=$1" + else + echo "Usage" + echo "explain interactive mode." + echo "explain 'cmd -o | ...' one quoted command to explain it." + fi +} + +# Update 26-03-2015. If using this command gives no output, see if running a simple fetch causes this error: +# $ curl https://www.mankier.com +# curl: (35) Cannot communicate securely with peer: no common encryption algorithm(s). +# If so, try specifying a cipher in the curl commands: curl --ciphers ecdhe_ecdsa_aes_128_sha From 503fc7bede567dc7244ef2388caff5767643ed8e Mon Sep 17 00:00:00 2001 From: Dwight Holman Date: Wed, 14 Oct 2015 16:58:40 -0700 Subject: [PATCH 057/216] Basename -s is platform specific, so use Bash's variable expansion instead. --- lib/preview.bash | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/preview.bash b/lib/preview.bash index 6e0d0357..306b475a 100644 --- a/lib/preview.bash +++ b/lib/preview.bash @@ -10,7 +10,8 @@ then THEMES="$BASH_IT/themes/*/*.theme.bash" for theme in $THEMES do - BASH_IT_THEME=$(basename -s '.theme.bash' $theme) + BASH_IT_THEME=${theme%.theme.bash} + BASH_IT_THEME=${BASH_IT_THEME##*/} echo " $BASH_IT_THEME" echo "" | bash --init-file $BASH_IT/bash_it.sh -i From c43f3d83273d88d2f4758c6014a0b8fcd91fa930 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Thu, 15 Oct 2015 11:26:52 +0200 Subject: [PATCH 058/216] Enabling general aliases by default --- install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install.sh b/install.sh index 38b5d64e..0cee031c 100755 --- a/install.sh +++ b/install.sh @@ -90,6 +90,7 @@ else echo -e "\033[0;32mEnabling sane defaults\033[0m" load_one completion bash-it.completion.bash load_one plugins alias-completion.bash + load_one aliases general.aliases.bash fi echo "" From 36caf70f8d6ceaa29b3d42dd130e19b0e3660440 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Thu, 15 Oct 2015 11:27:49 +0200 Subject: [PATCH 059/216] Renamed alias-completion file to match naming conventions --- install.sh | 2 +- .../{alias-completion.bash => alias-completion.plugin.bash} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename plugins/available/{alias-completion.bash => alias-completion.plugin.bash} (100%) diff --git a/install.sh b/install.sh index 0cee031c..84dab322 100755 --- a/install.sh +++ b/install.sh @@ -89,7 +89,7 @@ else echo "" echo -e "\033[0;32mEnabling sane defaults\033[0m" load_one completion bash-it.completion.bash - load_one plugins alias-completion.bash + load_one plugins alias-completion.plugin.bash load_one aliases general.aliases.bash fi diff --git a/plugins/available/alias-completion.bash b/plugins/available/alias-completion.plugin.bash similarity index 100% rename from plugins/available/alias-completion.bash rename to plugins/available/alias-completion.plugin.bash From dad983adb5e94f0dda493dfe1ad3fcf7ef734c58 Mon Sep 17 00:00:00 2001 From: Justin Dray Date: Fri, 16 Oct 2015 16:27:58 +0200 Subject: [PATCH 060/216] Remove exit from install. Update readme for install locations --- README.md | 2 +- install.sh | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 912da87e..e8866e7f 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Bash it provides a solid framework for using, developing and maintaining shell s ## Install -1. Check a clone of this repo: `git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it` +1. Check a clone of this repo to a location of your choice, such as: `git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it` 2. Run `~/.bash_it/install.sh` (it automatically backs up your `~/.bash_profile` or `~/.bashrc`, depending on your OS) 3. Edit your modified config (`~/.bash_profile` or `~/.bashrc`) file in order to customize Bash it. 4. Check out available aliases, completions and plugins and enable the ones you want to use (see the next section for more details). diff --git a/install.sh b/install.sh index 77ce7270..e55308c1 100755 --- a/install.sh +++ b/install.sh @@ -38,7 +38,6 @@ test -w "$HOME/$CONFIG_FILE" && cp "$BASH_IT/template/bash_profile.template.bash" "$HOME/$CONFIG_FILE" sed -i "s|{{BASH_IT}}|$BASH_IT|" "$HOME/$CONFIG_FILE" -exit echo -e "\033[0;32mCopied the template $CONFIG_FILE into ~/$CONFIG_FILE, edit this file to customize bash-it\033[0m" From 34e9878943eb8c0ffb0cee97bbdfc62d6a720e56 Mon Sep 17 00:00:00 2001 From: James Cuzella Date: Fri, 16 Oct 2015 10:11:00 -0600 Subject: [PATCH 061/216] explain: remove comments, add about, example, group, param metadata to explain() --- plugins/available/explain.plugin.bash | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/available/explain.plugin.bash b/plugins/available/explain.plugin.bash index b2d9593a..d57b78e2 100644 --- a/plugins/available/explain.plugin.bash +++ b/plugins/available/explain.plugin.bash @@ -1,8 +1,13 @@ cite about-plugin about-plugin 'mankier.com explain function to explain other commands' -# Add this to ~/.bash_profile or ~/.bashrc explain () { + about 'explain any bash command via mankier.com manpage API' + param '1: Name of the command to explain' + example '$ explain # interactive mode. Type commands to explain in REPL' + example '$ explain 'cmd -o | ...' # one quoted command to explain it.' + group 'explain' + if [ "$#" -eq 0 ]; then while read -p "Command: " cmd; do curl -Gs "https://www.mankier.com/api/explain/?cols="$(tput cols) --data-urlencode "q=$cmd" @@ -17,7 +22,3 @@ explain () { fi } -# Update 26-03-2015. If using this command gives no output, see if running a simple fetch causes this error: -# $ curl https://www.mankier.com -# curl: (35) Cannot communicate securely with peer: no common encryption algorithm(s). -# If so, try specifying a cipher in the curl commands: curl --ciphers ecdhe_ecdsa_aes_128_sha From f3542fcabed6702082c314c9c390fb7117ab8f24 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Wed, 21 Oct 2015 09:24:17 +0200 Subject: [PATCH 062/216] Added Visual Studio Code plugin Only required on Mac OS X. More details here: https://code.visualstudio.com/Docs/editor/setup --- plugins/available/visual-studio-code.plugin.bash | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 plugins/available/visual-studio-code.plugin.bash diff --git a/plugins/available/visual-studio-code.plugin.bash b/plugins/available/visual-studio-code.plugin.bash new file mode 100644 index 00000000..5bc20995 --- /dev/null +++ b/plugins/available/visual-studio-code.plugin.bash @@ -0,0 +1,12 @@ +cite about-plugin +about-plugin 'Defines the `code` executable for Visual Studio Code on OS X' + +# Based on https://code.visualstudio.com/Docs/editor/setup +if [[ `uname -s` == "Darwin" ]]; then + function code () { + about 'Starts Visual Studio Code in the provided directory' + group 'visual-studio-code' + + VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ; + } +fi From ad537b4c0560955d0d88f928b6c950a7f85c95a0 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Sun, 18 Oct 2015 16:14:43 +0200 Subject: [PATCH 063/216] Renamed file --- plugins/available/{boot2docker.bash => boot2docker.plugin.bash} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename plugins/available/{boot2docker.bash => boot2docker.plugin.bash} (100%) diff --git a/plugins/available/boot2docker.bash b/plugins/available/boot2docker.plugin.bash similarity index 100% rename from plugins/available/boot2docker.bash rename to plugins/available/boot2docker.plugin.bash From c23a041f82a75aa7409f45cf5c3fb27eed5069e0 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Wed, 21 Oct 2015 09:27:40 +0200 Subject: [PATCH 064/216] Added a missing "out" --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e8866e7f..49f54a33 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Bash it provides a solid framework for using, developing and maintaining shell s ## Install -1. Check a clone of this repo to a location of your choice, such as: `git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it` +1. Check out a clone of this repo to a location of your choice, such as: `git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it` 2. Run `~/.bash_it/install.sh` (it automatically backs up your `~/.bash_profile` or `~/.bashrc`, depending on your OS) 3. Edit your modified config (`~/.bash_profile` or `~/.bashrc`) file in order to customize Bash it. 4. Check out available aliases, completions and plugins and enable the ones you want to use (see the next section for more details). From a9ca1ae3fb886ca5fc82612ba9b38ac6629ac294 Mon Sep 17 00:00:00 2001 From: luispcosta Date: Thu, 22 Oct 2015 11:30:37 +0100 Subject: [PATCH 065/216] Added new git push origin master --- aliases/available/general.aliases.bash | 2 +- aliases/available/git.aliases.bash | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/aliases/available/general.aliases.bash b/aliases/available/general.aliases.bash index bc884050..428af6e9 100644 --- a/aliases/available/general.aliases.bash +++ b/aliases/available/general.aliases.bash @@ -3,7 +3,7 @@ about-alias 'general aliases' # List directory contents alias sl=ls -alias ls='ls -G' # Compact view, show colors +alias ls='ls -alG' # Compact view, show colors alias la='ls -AF' # Compact view, show hidden alias ll='ls -al' alias l='ls -a' diff --git a/aliases/available/git.aliases.bash b/aliases/available/git.aliases.bash index 4982686f..8a303a15 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -4,7 +4,7 @@ about-alias 'common git abbreviations' # Aliases alias gcl='git clone' alias ga='git add' -alias gall='git add .' +alias gall='git add -A' alias gf='git fetch --all --prune' alias gus='git reset HEAD' alias gm="git merge" @@ -20,6 +20,7 @@ alias gpp='git pull && git push' alias gup='git fetch && git rebase' alias gp='git push' alias gpo='git push origin' +alias gpom='git push origin master' alias gdv='git diff -w "$@" | vim -R -' alias gc='git commit -v' alias gca='git commit -v -a' From 1f5f2e246c49a861da37b34c3a1320ccc1ed9a01 Mon Sep 17 00:00:00 2001 From: luispcosta Date: Thu, 22 Oct 2015 11:42:40 +0100 Subject: [PATCH 066/216] Fixed back general aliases --- aliases/available/general.aliases.bash | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aliases/available/general.aliases.bash b/aliases/available/general.aliases.bash index 428af6e9..3f6b844f 100644 --- a/aliases/available/general.aliases.bash +++ b/aliases/available/general.aliases.bash @@ -3,7 +3,7 @@ about-alias 'general aliases' # List directory contents alias sl=ls -alias ls='ls -alG' # Compact view, show colors +alias ls='ls -G' # Compact view, show colors alias la='ls -AF' # Compact view, show hidden alias ll='ls -al' alias l='ls -a' @@ -53,8 +53,8 @@ then fi # Directory -alias md='mkdir -p' -alias rd='rmdir' +alias md='mkdir -p' +alias rd='rmdir' # Display whatever file is regular file or folder catt() { @@ -65,4 +65,4 @@ catt() { cat "$i" fi done -} +} \ No newline at end of file From dd8831faf1aad06b81b253540d99072048be74a7 Mon Sep 17 00:00:00 2001 From: Justin Dray Date: Thu, 22 Oct 2015 16:20:44 +0200 Subject: [PATCH 067/216] Fix for OS X installation --- install.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index e55308c1..7f7223c3 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -BASH_IT="$(dirname "$(readlink -f "$0")")" +BASH_IT="$(cd "$(dirname "$0")" && pwd)" case $OSTYPE in darwin*) @@ -36,8 +36,7 @@ test -w "$HOME/$CONFIG_FILE" && cp -a "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" && echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m" -cp "$BASH_IT/template/bash_profile.template.bash" "$HOME/$CONFIG_FILE" -sed -i "s|{{BASH_IT}}|$BASH_IT|" "$HOME/$CONFIG_FILE" +sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" > "$HOME/$CONFIG_FILE" echo -e "\033[0;32mCopied the template $CONFIG_FILE into ~/$CONFIG_FILE, edit this file to customize bash-it\033[0m" From a42e5f4d732594b9ecc9227347365165c7bc521b Mon Sep 17 00:00:00 2001 From: crazygit Date: Wed, 14 Oct 2015 15:25:33 +0800 Subject: [PATCH 068/216] add bulk enable or disable function --- completion/available/bash-it.completion.bash | 79 +++++++------------- lib/helpers.bash | 22 ++++-- 2 files changed, 42 insertions(+), 59 deletions(-) diff --git a/completion/available/bash-it.completion.bash b/completion/available/bash-it.completion.bash index 68d067c8..43a26a64 100644 --- a/completion/available/bash-it.completion.bash +++ b/completion/available/bash-it.completion.bash @@ -51,10 +51,10 @@ _bash-it-comp() COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" - + chose_opt="${COMP_WORDS[1]}" + file_type="${COMP_WORDS[2]}" opts="help show enable disable" - - case "${prev}" in + case "${chose_opt}" in show) local show_args="plugins aliases completions" COMPREPLY=( $(compgen -W "${show_args}" -- ${cur}) ) @@ -65,13 +65,30 @@ _bash-it-comp() COMPREPLY=( $(compgen -W "${help_args}" -- ${cur}) ) return 0 ;; - enable) - _bash-it-comp-enable-disable - return 0 - ;; - disable) - _bash-it-comp-enable-disable - return 0 + enable | disable) + if [ x"${chose_opt}" == x"enable" ];then + suffix="available-not-enabled" + else + suffix="enabled" + fi + case "${file_type}" in + alias) + _bash-it-comp-list-${suffix} aliases + return 0 + ;; + plugin) + _bash-it-comp-list-${suffix} plugins + return 0 + ;; + completion) + _bash-it-comp-list-${suffix} completion + return 0 + ;; + *) + _bash-it-comp-enable-disable + return 0 + ;; + esac ;; aliases) prevprev="${COMP_WORDS[COMP_CWORD-2]}" @@ -83,48 +100,6 @@ _bash-it-comp() ;; esac ;; - alias) - prevprev="${COMP_WORDS[COMP_CWORD-2]}" - - case "${prevprev}" in - enable) - _bash-it-comp-list-available-not-enabled aliases - return 0 - ;; - disable) - _bash-it-comp-list-enabled aliases - return 0 - ;; - esac - ;; - plugin) - prevprev="${COMP_WORDS[COMP_CWORD-2]}" - - case "${prevprev}" in - enable) - _bash-it-comp-list-available-not-enabled plugins - return 0 - ;; - disable) - _bash-it-comp-list-enabled plugins - return 0 - ;; - esac - ;; - completion) - prevprev="${COMP_WORDS[COMP_CWORD-2]}" - - case "${prevprev}" in - enable) - _bash-it-comp-list-available-not-enabled completion - return 0 - ;; - disable) - _bash-it-comp-list-enabled completion - return 0 - ;; - esac - ;; esac COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) diff --git a/lib/helpers.bash b/lib/helpers.bash index ebd68119..ae295a7c 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -37,8 +37,8 @@ bash-it () param '3: specific component [optional]' example '$ bash-it show plugins' example '$ bash-it help aliases' - example '$ bash-it enable plugin git' - example '$ bash-it disable alias hg' + example '$ bash-it enable plugin git [tmux]...' + example '$ bash-it disable alias hg [tmux]...' typeset verb=${1:-} shift typeset component=${1:-} @@ -72,7 +72,15 @@ bash-it () fi fi fi - $func $* + + if [ x"$verb" == x"enable" -o x"$verb" == x"disable" ];then + for arg in "$@" + do + $func $arg + done + else + $func $* + fi } _is_function () @@ -134,9 +142,9 @@ _bash-it-describe () printf "%-20s%-10s%s\n" "$(basename $f | cut -d'.' -f1)" " [$enabled]" "$(cat $f | metafor about-$file_type)" done printf '\n%s\n' "to enable $preposition $file_type, do:" - printf '%s\n' "$ bash-it enable $file_type <$file_type name> -or- $ bash-it enable $file_type all" + printf '%s\n' "$ bash-it enable $file_type <$file_type name> [$file_type name]... -or- $ bash-it enable $file_type all" printf '\n%s\n' "to disable $preposition $file_type, do:" - printf '%s\n' "$ bash-it disable $file_type <$file_type name> -or- $ bash-it disable $file_type all" + printf '%s\n' "$ bash-it disable $file_type <$file_type name> [$file_type name]... -or- $ bash-it disable $file_type all" } _disable-plugin () @@ -198,7 +206,7 @@ _disable-thing () else typeset plugin=$(command ls $BASH_IT/$subdirectory/enabled/$file_entity.*bash 2>/dev/null | head -1) if [ -z "$plugin" ]; then - printf '%s\n' "sorry, that does not appear to be an enabled $file_type." + printf '%s\n' "sorry, $file_entity does not appear to be an enabled $file_type." return fi rm $BASH_IT/$subdirectory/enabled/$(basename $plugin) @@ -267,7 +275,7 @@ _enable-thing () else typeset plugin=$(command ls $BASH_IT/$subdirectory/available/$file_entity.*bash 2>/dev/null | head -1) if [ -z "$plugin" ]; then - printf '%s\n' "sorry, that does not appear to be an available $file_type." + printf '%s\n' "sorry, $file_entity does not appear to be an available $file_type." return fi From 25ef4e127522fb7fba8481bc8e0b53167e81c519 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Thu, 22 Oct 2015 22:08:18 +0200 Subject: [PATCH 069/216] Add gradle completion Code borrowed from gist: https://gist.github.com/nolanlawson/8694399 --- completion/available/gradle.completion.bash | 51 +++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 completion/available/gradle.completion.bash diff --git a/completion/available/gradle.completion.bash b/completion/available/gradle.completion.bash new file mode 100644 index 00000000..03fcc741 --- /dev/null +++ b/completion/available/gradle.completion.bash @@ -0,0 +1,51 @@ +function __gradle { + local cur=${COMP_WORDS[COMP_CWORD]} + local tasks='' + local cache_dir="$HOME/.gradle/completion_cache" + + case $OSTYPE in + darwin*) + local checksum_command="find . -name build.gradle -print0 | xargs -0 md5 -q | md5 -q" + local parsing_command="gradle --console=plain --quiet tasks | grep -v Rules | sed -nE -e 's/^([a-zA-Z]+)($| - .+)/\1/p'" + ;; + *) + local checksum_command="find . -name build.gradle -print0 | xargs -0 md5sum | md5sum | cut -d ' ' -f 1" + local parsing_command="gradle --console=plain --quiet tasks | grep -v Rules | sed -nr -e 's/^([a-zA-Z]+)($| - .+)/\1/p'" + ;; + esac + + mkdir -p "${cache_dir}" + + local gradle_files_checksum='no_cache_file' + if [[ -f build.gradle ]]; then + gradle_files_checksum="$(eval "${checksum_command}")" + if [[ -f "${cache_dir}/${gradle_files_checksum}" ]]; then + newest_gradle_file="$(find . -type f -name build.gradle -newer "${cache_dir}/${gradle_files_checksum}")" + if [ -n "${newest_gradle_file}" ]; then + tasks="$(eval "${parsing_command}")" + [[ -n "${tasks}" ]] && echo "${tasks}" > "${cache_dir}/${gradle_files_checksum}" + else + tasks="$(cat "${cache_dir}/${gradle_files_checksum}")" + touch "${cache_dir}/${gradle_files_checksum}" + fi + else + tasks="$(eval "${parsing_command}")" + [[ -n "${tasks}" ]] && echo "${tasks}" > "${cache_dir}/${gradle_files_checksum}" + fi + else + tasks="$(eval "${parsing_command}")" + [[ -n "${tasks}" ]] && echo "${tasks}" > "${cache_dir}/${gradle_files_checksum}" + fi + COMPREPLY=( $(compgen -W "${tasks}" -- "${cur}") ) +} + +function __clear_gradle_cache { + local cache_dir="$HOME/.gradle/completion_cache" + [[ -d "${cache_dir}" ]] && find "${cache_dir}" -type f -mtime +7 -exec rm -f {} \; +} + +__clear_gradle_cache + +complete -F __gradle gradle +complete -F __gradle gradlew +complete -F __gradle ./gradlew From bea8beca6f93eb983126b5e6af61be459e3c94b8 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Thu, 22 Oct 2015 23:51:42 +0200 Subject: [PATCH 070/216] Add new git aliases --- aliases/available/git.aliases.bash | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/aliases/available/git.aliases.bash b/aliases/available/git.aliases.bash index 8a303a15..c2de34bb 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -5,7 +5,8 @@ about-alias 'common git abbreviations' alias gcl='git clone' alias ga='git add' alias gall='git add -A' -alias gf='git fetch --all --prune' +alias gf='git fetch --all --prune --verbose' +alias gft='git fetch --all --prune --tags --verbose' alias gus='git reset HEAD' alias gm="git merge" alias g='git' @@ -20,6 +21,7 @@ alias gpp='git pull && git push' alias gup='git fetch && git rebase' alias gp='git push' alias gpo='git push origin' +alias gpu='git push --set-upstream' alias gpom='git push origin master' alias gdv='git diff -w "$@" | vim -R -' alias gc='git commit -v' @@ -28,9 +30,12 @@ alias gcm='git commit -v -m' alias gci='git commit --interactive' alias gb='git branch' alias gba='git branch -a' +alias gbt='git branch --track' alias gcount='git shortlog -sn' alias gcp='git cherry-pick' alias gco='git checkout' +alias gcb='git checkout -b' +alias gct='git checkout --track' alias gexport='git archive --format zip --output' alias gdel='git branch -D' alias gmu='git fetch origin -v; git fetch upstream -v; git merge upstream/master' From 6d453fe1e4fae88bd7fccc269e87e824b3ab048f Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Thu, 22 Oct 2015 23:52:14 +0200 Subject: [PATCH 071/216] Make git gg alias more readable --- aliases/available/git.aliases.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aliases/available/git.aliases.bash b/aliases/available/git.aliases.bash index c2de34bb..aeab208f 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -40,7 +40,7 @@ alias gexport='git archive --format zip --output' alias gdel='git branch -D' alias gmu='git fetch origin -v; git fetch upstream -v; git merge upstream/master' alias gll='git log --graph --pretty=oneline --abbrev-commit' -alias gg="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative" +alias gg="git log --graph --pretty=format:'%C(bold)%h%Creset%C(yellow)%d%Creset %s %C(yellow)%an %C(cyan)%cr%Creset' --abbrev-commit --date=relative" alias ggs="gg --stat" alias gsl="git shortlog -sn" alias gw="git whatchanged" From 56c6e3ecd3d04299344cc49f0bd249161dafb700 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Wed, 28 Oct 2015 00:43:33 +0000 Subject: [PATCH 072/216] Now, right prompt can be totally disabled in powerline multiline theme - New env var (THEME_PROMPT_USERINFO_MODE) to choose "user info" mode: Possible values: default: same behaviour as before sudo: only show a "hint" when sudo credentials are cached any other values disables this segment. --- .../powerline-multiline.theme.bash | 50 +++++++++++++------ 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index ba614bdd..7b690683 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -42,6 +42,8 @@ BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=160 THEME_PROMPT_CLOCK_FORMAT=${THEME_PROMPT_CLOCK_FORMAT:="%H:%M:%S"} +THEME_PROMPT_USERINFO_MODE=${THEME_PROMPT_USERINFO_MODE:="default"} + IN_VIM_PROMPT_COLOR=35 IN_VIM_PROMPT_TEXT="vim" @@ -58,20 +60,33 @@ function set_rgb_color { } function powerline_shell_prompt { + SHELL_PROMPT="" SHELL_PROMPT_COLOR=${SHELL_THEME_PROMPT_COLOR} if sudo -n uptime 2>&1 | grep -q "load"; then SHELL_PROMPT_COLOR=${SHELL_THEME_PROMPT_COLOR_SUDO} fi - SEGMENT_AT_RIGHT=0 - if [[ -n "${SSH_CLIENT}" ]]; then - SHELL_PROMPT="${SHELL_SSH_CHAR}${USER}@${HOSTNAME}" - else - SHELL_PROMPT="${USER}" - fi - RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#SHELL_PROMPT} + 2 )) - SHELL_PROMPT="$(set_rgb_color - ${SHELL_PROMPT_COLOR}) ${SHELL_PROMPT} ${normal}" - LAST_THEME_COLOR=${SHELL_PROMPT_COLOR} - (( SEGMENT_AT_RIGHT += 1 )) + case "${THEME_PROMPT_USERINFO_MODE}" in + "default") + if [[ -n "${SSH_CLIENT}" ]]; then + SHELL_PROMPT="${SHELL_SSH_CHAR}${USER}@${HOSTNAME}" + else + SHELL_PROMPT="${USER}" + fi + RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#SHELL_PROMPT} + 2 )) + SHELL_PROMPT="$(set_rgb_color - ${SHELL_PROMPT_COLOR}) ${SHELL_PROMPT} ${normal}" + LAST_THEME_COLOR=${SHELL_PROMPT_COLOR} + (( SEGMENT_AT_RIGHT += 1 )) + ;; + "sudo") + if [[ "${SHELL_PROMPT_COLOR}" == "${SHELL_THEME_PROMPT_COLOR_SUDO}" ]]; then + SHELL_PROMPT="!" + RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#SHELL_PROMPT} + 2 )) + SHELL_PROMPT="$(set_rgb_color - ${SHELL_PROMPT_COLOR}) ${SHELL_PROMPT} ${normal}" + LAST_THEME_COLOR=${SHELL_PROMPT_COLOR} + (( SEGMENT_AT_RIGHT += 1 )) + fi + ;; + esac } function powerline_rvm_prompt { @@ -188,6 +203,8 @@ function powerline_battery_status_prompt { if [[ "${SEGMENT_AT_RIGHT}" -gt 0 ]]; then BATTERY_PROMPT+=$(set_rgb_color ${LAST_THEME_COLOR} ${BATTERY_STATUS_THEME_PROMPT_COLOR})${THEME_PROMPT_LEFT_SEPARATOR}${normal} (( RIGHT_PROMPT_LENGTH += SEGMENT_AT_RIGHT )) + else + BATTERY_STATUS+=" " fi RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#BATTERY_STATUS} + 2 )) LAST_THEME_COLOR=${BATTERY_STATUS_THEME_PROMPT_COLOR} @@ -214,7 +231,10 @@ function powerline_in_vim_prompt { function powerline_prompt_command() { local LAST_STATUS="$?" local MOVE_CURSOR_RIGHTMOST='\033[500C' + SEGMENT_AT_LEFT=0 + SEGMENT_AT_RIGHT=0 RIGHT_PROMPT_LENGTH=1 + RIGHT_PROMPT="" ## left prompt ## powerline_scm_prompt @@ -232,10 +252,12 @@ function powerline_prompt_command() { powerline_clock_prompt powerline_in_vim_prompt - [[ "${SEGMENT_AT_RIGHT}" -eq 1 ]] && (( RIGHT_PROMPT_LENGTH-=1 )) - - RIGHT_PROMPT="\033[${RIGHT_PROMPT_LENGTH}D$(set_rgb_color ${LAST_THEME_COLOR} -)${THEME_PROMPT_LEFT_SEPARATOR}${normal}" - RIGHT_PROMPT+="${IN_VIM_PROMPT}${CLOCK_PROMPT}${BATTERY_PROMPT}${SHELL_PROMPT}${normal}" + if [[ "${SEGMENT_AT_RIGHT}" -gt 0 ]]; then + LEFT_PROMPT+="${MOVE_CURSOR_RIGHTMOST}" + [[ "${SEGMENT_AT_RIGHT}" -eq 1 ]] && (( RIGHT_PROMPT_LENGTH-=1 )) + RIGHT_PROMPT="\033[${RIGHT_PROMPT_LENGTH}D$(set_rgb_color ${LAST_THEME_COLOR} -)${THEME_PROMPT_LEFT_SEPARATOR}${normal}" + RIGHT_PROMPT+="${IN_VIM_PROMPT}${CLOCK_PROMPT}${BATTERY_PROMPT}${SHELL_PROMPT}${normal}" + fi PS1="${LEFT_PROMPT}${RIGHT_PROMPT}\n${LAST_STATUS_PROMPT}${PROMPT_CHAR} " } From 7352c748deccd99910290cfed661a6dcd782e4e8 Mon Sep 17 00:00:00 2001 From: luispcosta Date: Wed, 28 Oct 2015 12:33:07 +0000 Subject: [PATCH 073/216] Defined section for typical programming languages aliases. Added python and ipython aliases --- aliases/available/general.aliases.bash | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/aliases/available/general.aliases.bash b/aliases/available/general.aliases.bash index 3f6b844f..99939386 100644 --- a/aliases/available/general.aliases.bash +++ b/aliases/available/general.aliases.bash @@ -32,7 +32,10 @@ alias q='exit' alias irc="$IRC_CLIENT" +# Language aliases alias rb='ruby' +alias py='python' +alias ipy='ipython' # Pianobar can be found here: http://github.com/PromyLOPh/pianobar/ @@ -65,4 +68,4 @@ catt() { cat "$i" fi done -} \ No newline at end of file +} From e8e01b5794b95da9e61da31d3dd081ebb8c32f94 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Wed, 28 Oct 2015 23:51:05 +0000 Subject: [PATCH 074/216] Add awscli completion --- completion/available/awscli.completion.bash | 1 + 1 file changed, 1 insertion(+) create mode 100644 completion/available/awscli.completion.bash diff --git a/completion/available/awscli.completion.bash b/completion/available/awscli.completion.bash new file mode 100644 index 00000000..530bdd27 --- /dev/null +++ b/completion/available/awscli.completion.bash @@ -0,0 +1 @@ +[[ -x "$(which aws_completer)" ]] && complete -C "$(which aws_completer)" aws From 35902d00d9d69ce00902679eb1363fa499412e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Sat, 31 Oct 2015 00:53:41 +0100 Subject: [PATCH 075/216] Fixed pygmentize in less. Was not working correctly with file extensions unknown to pygmenties. Added the -g option to pygmentize command. --- plugins/available/less-pretty-cat.plugin.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/available/less-pretty-cat.plugin.bash b/plugins/available/less-pretty-cat.plugin.bash index b6d31b86..9221dde6 100644 --- a/plugins/available/less-pretty-cat.plugin.bash +++ b/plugins/available/less-pretty-cat.plugin.bash @@ -23,6 +23,6 @@ if $(command -v pygmentize &> /dev/null) ; then about 'it pigments the file passed in and passes it to less for pagination' param '$1: the file to paginate with less' example 'less mysite/manage.py' - pygmentize "$*" | "$LESS_BIN" -R + pygmentize -g $* | "$LESS_BIN" -R } fi From 7a00fe981c2646709012e0004c57cd4d2ce863ed Mon Sep 17 00:00:00 2001 From: Manoj Date: Mon, 2 Nov 2015 17:06:18 +0530 Subject: [PATCH 076/216] Add jenv plugin --- plugins/available/jenv.plugin.bash | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 plugins/available/jenv.plugin.bash diff --git a/plugins/available/jenv.plugin.bash b/plugins/available/jenv.plugin.bash new file mode 100644 index 00000000..42b752c2 --- /dev/null +++ b/plugins/available/jenv.plugin.bash @@ -0,0 +1,8 @@ +cite about-plugin +about-plugin 'load jenv, if you are using it' + +export JENV_ROOT="$HOME/.jenv" +export PATH="$JENV_ROOT/bin:$PATH" +if which jenv > /dev/null; then eval "$(jenv init -)"; fi + +[[ -e $JENV_ROOT/completions/jenv.bash ]] && source $JENV_ROOT/completions/jenv.bash From 5b87b2db0e830035f978e895433dfd1a65d33530 Mon Sep 17 00:00:00 2001 From: Manoj Date: Tue, 3 Nov 2015 12:10:02 +0530 Subject: [PATCH 077/216] Using pathmunge in jenv plugin --- plugins/available/jenv.plugin.bash | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/available/jenv.plugin.bash b/plugins/available/jenv.plugin.bash index 42b752c2..3cb2bcfc 100644 --- a/plugins/available/jenv.plugin.bash +++ b/plugins/available/jenv.plugin.bash @@ -2,7 +2,8 @@ cite about-plugin about-plugin 'load jenv, if you are using it' export JENV_ROOT="$HOME/.jenv" -export PATH="$JENV_ROOT/bin:$PATH" +pathmunge "$JENV_ROOT/bin" + if which jenv > /dev/null; then eval "$(jenv init -)"; fi [[ -e $JENV_ROOT/completions/jenv.bash ]] && source $JENV_ROOT/completions/jenv.bash From 7abde2fdcf8bc494c64df2f1f341ee62a6793ffd Mon Sep 17 00:00:00 2001 From: Georg Ogris Date: Thu, 5 Nov 2015 13:47:35 +0100 Subject: [PATCH 078/216] no sudo for apt-cache --- aliases/available/apt.aliases.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aliases/available/apt.aliases.bash b/aliases/available/apt.aliases.bash index 34deb0d1..2f444931 100644 --- a/aliases/available/apt.aliases.bash +++ b/aliases/available/apt.aliases.bash @@ -9,8 +9,8 @@ about-alias 'Apt and dpkg aliases for Ubuntu and Debian distros.' function _set_pkg_aliases() { if [ -x $(which apt) ]; then - alias apts='sudo apt-cache search' - alias aptshow='sudo apt-cache show' + alias apts='apt-cache search' + alias aptshow='apt-cache show' alias aptinst='sudo apt-get install -V' alias aptupd='sudo apt-get update' alias aptupg='sudo apt-get dist-upgrade -V && sudo apt-get autoremove' From 73d2b4f87e50623dcd5b90439b1583139c3cc96b Mon Sep 17 00:00:00 2001 From: Frank Becker Date: Sun, 18 Jan 2015 13:52:22 +0100 Subject: [PATCH 079/216] gvmtool completion - determine local installed versions --- completion/available/gvmtool.completion.bash | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/completion/available/gvmtool.completion.bash b/completion/available/gvmtool.completion.bash index c2158747..3bc9b4ee 100644 --- a/completion/available/gvmtool.completion.bash +++ b/completion/available/gvmtool.completion.bash @@ -41,15 +41,24 @@ _gvm_complete() _gvm_candidate_versions(){ + + CANDIDATE_LOCAL_VERSIONS=$(__gvm_cleanup_local_versions $1) if _gvm_offline; then - __gvmtool_build_version_csv $1 - CANDIDATE_VERSIONS="$(echo $CSV | tr ',' ' ')" + CANDIDATE_VERSIONS=$CANDIDATE_LOCAL_VERSIONS else - CANDIDATE_VERSIONS="$(curl -s "${GVM_SERVICE}/candidates/$1" | tr ',' ' ')" + CANDIDATE_ONLINE_VERSIONS="$(curl -s "${GVM_SERVICE}/candidates/$1" | tr ',' ' ')" + CANDIDATE_VERSIONS="$(echo $CANDIDATE_ONLINE_VERSIONS $CANDIDATE_LOCAL_VERSIONS |sort | uniq ) " fi } +__gvm_cleanup_local_versions(){ + + __gvmtool_build_version_csv $1 + echo $CSV | tr ',' ' ' + +} + _gvm_offline() { if [ "$GVM_ONLINE" = "true" ]; then From 5738e5d45eced88c9dc1d8eb298fa1bcf62088d2 Mon Sep 17 00:00:00 2001 From: Frank Becker Date: Tue, 17 Mar 2015 22:13:53 +0100 Subject: [PATCH 080/216] added outdated command to gvmtool completion --- completion/available/gvmtool.completion.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/completion/available/gvmtool.completion.bash b/completion/available/gvmtool.completion.bash index 3bc9b4ee..163141fc 100644 --- a/completion/available/gvmtool.completion.bash +++ b/completion/available/gvmtool.completion.bash @@ -6,10 +6,10 @@ _gvm_complete() COMPREPLY=() if [ $COMP_CWORD -eq 1 ]; then - COMPREPLY=( $(compgen -W "install uninstall rm list ls use current version default selfupdate broadcast offline help flush" -- ${COMP_WORDS[COMP_CWORD]}) ) + COMPREPLY=( $(compgen -W "install uninstall rm list ls use current outdated version default selfupdate broadcast offline help flush" -- ${COMP_WORDS[COMP_CWORD]}) ) elif [ $COMP_CWORD -eq 2 ]; then case "${COMP_WORDS[COMP_CWORD-1]}" in - "install" | "uninstall" | "rm" | "list" | "ls" | "use" | "current" ) + "install" | "uninstall" | "rm" | "list" | "ls" | "use" | "current" | "outdated" ) CANDIDATES=$(echo "${GVM_CANDIDATES_CSV}" | tr ',' ' ') COMPREPLY=( $(compgen -W "$CANDIDATES" -- ${COMP_WORDS[COMP_CWORD]}) ) ;; From e2a596b7080abff0489a487145b811e03709bdba Mon Sep 17 00:00:00 2001 From: Frank Becker Date: Wed, 23 Sep 2015 12:30:13 +0200 Subject: [PATCH 081/216] renamed gvmtool to sdkman --- ...completion.bash => sdkman.completion.bash} | 24 +++++++++---------- plugins/available/gvmtool.plugin.bash | 6 ----- plugins/available/sdkman.plugin.bash | 5 ++++ 3 files changed, 17 insertions(+), 18 deletions(-) rename completion/available/{gvmtool.completion.bash => sdkman.completion.bash} (73%) delete mode 100644 plugins/available/gvmtool.plugin.bash create mode 100644 plugins/available/sdkman.plugin.bash diff --git a/completion/available/gvmtool.completion.bash b/completion/available/sdkman.completion.bash similarity index 73% rename from completion/available/gvmtool.completion.bash rename to completion/available/sdkman.completion.bash index 163141fc..2bf217bb 100644 --- a/completion/available/gvmtool.completion.bash +++ b/completion/available/sdkman.completion.bash @@ -1,4 +1,4 @@ -_gvm_complete() +_sdkman_complete() { local CANDIDATES local CANDIDATE_VERSIONS @@ -10,7 +10,7 @@ _gvm_complete() elif [ $COMP_CWORD -eq 2 ]; then case "${COMP_WORDS[COMP_CWORD-1]}" in "install" | "uninstall" | "rm" | "list" | "ls" | "use" | "current" | "outdated" ) - CANDIDATES=$(echo "${GVM_CANDIDATES_CSV}" | tr ',' ' ') + CANDIDATES=$(echo "${SDKMAN_CANDIDATES_CSV}" | tr ',' ' ') COMPREPLY=( $(compgen -W "$CANDIDATES" -- ${COMP_WORDS[COMP_CWORD]}) ) ;; "offline" ) @@ -28,7 +28,7 @@ _gvm_complete() elif [ $COMP_CWORD -eq 3 ]; then case "${COMP_WORDS[COMP_CWORD-2]}" in "install" | "uninstall" | "rm" | "use" | "default" ) - _gvm_candidate_versions ${COMP_WORDS[COMP_CWORD-1]} + _sdkman_candidate_versions ${COMP_WORDS[COMP_CWORD-1]} COMPREPLY=( $(compgen -W "$CANDIDATE_VERSIONS" -- ${COMP_WORDS[COMP_CWORD]}) ) ;; *) @@ -39,33 +39,33 @@ _gvm_complete() return 0 } -_gvm_candidate_versions(){ +_sdkman_candidate_versions(){ - CANDIDATE_LOCAL_VERSIONS=$(__gvm_cleanup_local_versions $1) - if _gvm_offline; then + CANDIDATE_LOCAL_VERSIONS=$(__sdkman_cleanup_local_versions $1) + if _sdkman_offline; then CANDIDATE_VERSIONS=$CANDIDATE_LOCAL_VERSIONS else - CANDIDATE_ONLINE_VERSIONS="$(curl -s "${GVM_SERVICE}/candidates/$1" | tr ',' ' ')" + CANDIDATE_ONLINE_VERSIONS="$(curl -s "${SDKMAN_SERVICE}/candidates/$1" | tr ',' ' ')" CANDIDATE_VERSIONS="$(echo $CANDIDATE_ONLINE_VERSIONS $CANDIDATE_LOCAL_VERSIONS |sort | uniq ) " fi } -__gvm_cleanup_local_versions(){ +__sdkman_cleanup_local_versions(){ - __gvmtool_build_version_csv $1 + __sdkmantool_build_version_csv $1 echo $CSV | tr ',' ' ' } -_gvm_offline() +_sdkman_offline() { - if [ "$GVM_ONLINE" = "true" ]; then + if [ "$SDKMAN_ONLINE" = "true" ]; then return 1 else return 0 fi } -complete -F _gvm_complete gvm +complete -F _sdkman_complete sdk diff --git a/plugins/available/gvmtool.plugin.bash b/plugins/available/gvmtool.plugin.bash deleted file mode 100644 index ee69a669..00000000 --- a/plugins/available/gvmtool.plugin.bash +++ /dev/null @@ -1,6 +0,0 @@ -cite about-plugin -about-plugin 'load groovy environment manager' - -GVM_DIR="$HOME/.gvm" - -[[ -s "${GVM_DIR}/bin/gvm-init.sh" ]] && source "${GVM_DIR}/bin/gvm-init.sh" diff --git a/plugins/available/sdkman.plugin.bash b/plugins/available/sdkman.plugin.bash new file mode 100644 index 00000000..0f3722b6 --- /dev/null +++ b/plugins/available/sdkman.plugin.bash @@ -0,0 +1,5 @@ +cite about-plugin +about-plugin 'Load Software Development Kit Manager' + +export SDKMAN_DIR="$HOME/.sdkman" +[[ -s "${SDKMAN_DIR}/bin/sdkman-init.sh" ]] && source "${SDKMAN_DIR}/bin/sdkman-init.sh" From 705635827110e853b9ee5104aa318b4c06c4faee Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Tue, 17 Nov 2015 10:24:35 +0100 Subject: [PATCH 082/216] Removed nvm script, replaced with loader and deprecation warning. If you want to keep using nvm, install the latest version from https://github.com/creationix/nvm.git --- plugins/available/nvm.plugin.bash | 326 ++---------------------------- 1 file changed, 15 insertions(+), 311 deletions(-) diff --git a/plugins/available/nvm.plugin.bash b/plugins/available/nvm.plugin.bash index 632de967..72f47fd5 100644 --- a/plugins/available/nvm.plugin.bash +++ b/plugins/available/nvm.plugin.bash @@ -1,318 +1,22 @@ -# Node Version Manager -# Implemented as a bash function -# To use source this file from your bash profile +# Bash-it no longer bundles nvm, as this was quickly becoming outdated. # -# Implemented by Tim Caswell -# with much bash help from Matthew Ranney +# Please install nvm from https://github.com/creationix/nvm.git if you want to use it. cite about-plugin -about-plugin 'node version manager, as a bash function' +about-plugin 'node version manager configuration' export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm -if [ ! -d "$NVM_DIR" ]; then - mkdir $NVM_DIR +if ! command -v nvm &>/dev/null +then + function nvm() { + echo "Bash-it no longer bundles the nvm script. Please install the latest version from" + echo "" + echo "https://github.com/creationix/nvm.git" + echo "" + echo "if you want to use nvm. You can keep this plugin enabled once you have installed nvm." + } + + nvm fi - -# Auto detect the NVM_DIR -if [ ! -d "$NVM_DIR" ]; then - export NVM_DIR=$(cd $(dirname ${BASH_SOURCE[0]:-$0}); pwd) -fi - -# Expand a version using the version cache -nvm_version() -{ - PATTERN=$1 - # The default version is the current one - if [ ! "$PATTERN" ]; then - PATTERN='current' - fi - - VERSION=`nvm_ls $PATTERN | tail -n1` - echo "$VERSION" - - if [ "$VERSION" = 'N/A' ]; then - return 13 - fi -} - -nvm_ls() -{ - PATTERN=$1 - VERSIONS='' - if [ "$PATTERN" = 'current' ]; then - echo `node -v 2>/dev/null` - return - fi - - if [ -f "$NVM_DIR/alias/$PATTERN" ]; then - nvm_version `cat $NVM_DIR/alias/$PATTERN` - return - fi - # If it looks like an explicit version, don't do anything funny - if [[ "$PATTERN" == v?*.?*.?* ]]; then - VERSIONS="$PATTERN" - else - VERSIONS=`(cd $NVM_DIR; \ls -d v${PATTERN}* 2>/dev/null) | sort -t. -k 1.2,1n -k 2,2n -k 3,3n` - fi - if [ ! "$VERSIONS" ]; then - echo "N/A" - return - fi - echo "$VERSIONS" - return -} - -print_versions() -{ - OUTPUT='' - for VERSION in $1; do - PADDED_VERSION=`printf '%10s' $VERSION` - if [[ -d "$NVM_DIR/$VERSION" ]]; then - PADDED_VERSION="\033[0;34m$PADDED_VERSION\033[0m" - fi - OUTPUT="$OUTPUT\n$PADDED_VERSION" - done - echo -e "$OUTPUT" | column -} - -nvm() -{ - about 'Node Version Manager' - param '1: command, see nvm help' - group 'nvm' - - if [ $# -lt 1 ]; then - nvm help - return - fi - case $1 in - "help" ) - echo - echo "Node Version Manager" - echo - echo "Usage:" - echo " nvm help Show this message" - echo " nvm install Download and install a " - echo " nvm uninstall Uninstall a version" - echo " nvm use Modify PATH to use " - echo " nvm run [] Run with as arguments" - echo " nvm ls List installed versions" - echo " nvm ls List versions matching a given description" - echo " nvm deactivate Undo effects of NVM on current shell" - echo " nvm alias [] Show all aliases beginning with " - echo " nvm alias Set an alias named pointing to " - echo " nvm unalias Deletes the alias named " - echo " nvm copy-packages Install global NPM packages contained in to current version" - echo - echo "Example:" - echo " nvm install v0.4.12 Install a specific version number" - echo " nvm use 0.2 Use the latest available 0.2.x release" - echo " nvm run 0.4.12 myApp.js Run myApp.js using node v0.4.12" - echo " nvm alias default 0.4 Auto use the latest installed v0.4.x version" - echo - ;; - "install" ) - if [ ! `which curl` ]; then - echo 'NVM Needs curl to proceed.' >&2; - fi - - if [ $# -ne 2 ]; then - nvm help - return - fi - VERSION=`nvm_version $2` - - [ -d "$NVM_DIR/$VERSION" ] && echo "$VERSION is already installed." && return - - tarball='' - if [ "`curl -Is "http://nodejs.org/dist/$VERSION/node-$VERSION.tar.gz" | grep '200 OK'`" != '' ]; then - tarball="http://nodejs.org/dist/$VERSION/node-$VERSION.tar.gz" - elif [ "`curl -Is "http://nodejs.org/dist/node-$VERSION.tar.gz" | grep '200 OK'`" != '' ]; then - tarball="http://nodejs.org/dist/node-$VERSION.tar.gz" - fi - if ( - [ ! -z $tarball ] && \ - mkdir -p "$NVM_DIR/src" && \ - cd "$NVM_DIR/src" && \ - curl -C - --progress-bar $tarball -o "node-$VERSION.tar.gz" && \ - tar -xzf "node-$VERSION.tar.gz" && \ - cd "node-$VERSION" && \ - ./configure --prefix="$NVM_DIR/$VERSION" && \ - make && \ - rm -f "$NVM_DIR/$VERSION" 2>/dev/null && \ - make install - ) - then - nvm use $VERSION - if ! which npm ; then - echo "Installing npm..." - if [[ "`expr match $VERSION '\(^v0\.1\.\)'`" != '' ]]; then - echo "npm requires node v0.2.3 or higher" - elif [[ "`expr match $VERSION '\(^v0\.2\.\)'`" != '' ]]; then - if [[ "`expr match $VERSION '\(^v0\.2\.[0-2]$\)'`" != '' ]]; then - echo "npm requires node v0.2.3 or higher" - else - curl http://npmjs.org/install.sh | clean=yes npm_install=0.2.19 sh - fi - else - curl http://npmjs.org/install.sh | clean=yes sh - fi - fi - else - echo "nvm: install $VERSION failed!" - fi - ;; - "uninstall" ) - [ $# -ne 2 ] && nvm help && return - if [[ $2 == `nvm_version` ]]; then - echo "nvm: Cannot uninstall currently-active node version, $2." - return - fi - VERSION=`nvm_version $2` - if [ ! -d $NVM_DIR/$VERSION ]; then - echo "$VERSION version is not installed yet" - return; - fi - - # Delete all files related to target version. - (mkdir -p "$NVM_DIR/src" && \ - cd "$NVM_DIR/src" && \ - rm -rf "node-$VERSION" 2>/dev/null && \ - rm -f "node-$VERSION.tar.gz" 2>/dev/null && \ - rm -rf "$NVM_DIR/$VERSION" 2>/dev/null) - echo "Uninstalled node $VERSION" - - # Rm any aliases that point to uninstalled version. - for A in `grep -l $VERSION $NVM_DIR/alias/*` - do - nvm unalias `basename $A` - done - - ;; - "deactivate" ) - if [[ $PATH == *$NVM_DIR/*/bin* ]]; then - export PATH=${PATH%$NVM_DIR/*/bin*}${PATH#*$NVM_DIR/*/bin:} - hash -r - echo "$NVM_DIR/*/bin removed from \$PATH" - else - echo "Could not find $NVM_DIR/*/bin in \$PATH" - fi - if [[ $MANPATH == *$NVM_DIR/*/share/man* ]]; then - export MANPATH=${MANPATH%$NVM_DIR/*/share/man*}${MANPATH#*$NVM_DIR/*/share/man:} - echo "$NVM_DIR/*/share/man removed from \$MANPATH" - else - echo "Could not find $NVM_DIR/*/share/man in \$MANPATH" - fi - ;; - "use" ) - if [ $# -ne 2 ]; then - nvm help - return - fi - VERSION=`nvm_version $2` - if [ ! -d $NVM_DIR/$VERSION ]; then - echo "$VERSION version is not installed yet" - return; - fi - if [[ $PATH == *$NVM_DIR/*/bin* ]]; then - PATH=${PATH%$NVM_DIR/*/bin*}$NVM_DIR/$VERSION/bin${PATH#*$NVM_DIR/*/bin} - else - PATH="$NVM_DIR/$VERSION/bin:$PATH" - fi - if [[ $MANPATH == *$NVM_DIR/*/share/man* ]]; then - MANPATH=${MANPATH%$NVM_DIR/*/share/man*}$NVM_DIR/$VERSION/share/man${MANPATH#*$NVM_DIR/*/share/man} - else - MANPATH="$NVM_DIR/$VERSION/share/man:$MANPATH" - fi - export PATH - hash -r - export MANPATH - export NVM_PATH="$NVM_DIR/$VERSION/lib/node" - export NVM_BIN="$NVM_DIR/$VERSION/bin" - echo "Now using node $VERSION" - ;; - "run" ) - # run given version of node - if [ $# -lt 2 ]; then - nvm help - return - fi - VERSION=`nvm_version $2` - if [ ! -d $NVM_DIR/$VERSION ]; then - echo "$VERSION version is not installed yet" - return; - fi - echo "Running node $VERSION" - $NVM_DIR/$VERSION/bin/node "${@:3}" - ;; - "ls" | "list" ) - print_versions "`nvm_ls $2`" - if [ $# -eq 1 ]; then - echo -ne "current: \t"; nvm_version current - nvm alias - fi - return - ;; - "alias" ) - mkdir -p $NVM_DIR/alias - if [ $# -le 2 ]; then - (cd $NVM_DIR/alias && for ALIAS in `\ls $2* 2>/dev/null`; do - DEST=`cat $ALIAS` - VERSION=`nvm_version $DEST` - if [ "$DEST" = "$VERSION" ]; then - echo "$ALIAS -> $DEST" - else - echo "$ALIAS -> $DEST (-> $VERSION)" - fi - done) - return - fi - if [ ! "$3" ]; then - rm -f $NVM_DIR/alias/$2 - echo "$2 -> *poof*" - return - fi - mkdir -p $NVM_DIR/alias - VERSION=`nvm_version $3` - if [ $? -ne 0 ]; then - echo "! WARNING: Version '$3' does not exist." >&2 - fi - echo $3 > "$NVM_DIR/alias/$2" - if [ ! "$3" = "$VERSION" ]; then - echo "$2 -> $3 (-> $VERSION)" - else - echo "$2 -> $3" - fi - ;; - "unalias" ) - mkdir -p $NVM_DIR/alias - [ $# -ne 2 ] && nvm help && return - [ ! -f $NVM_DIR/alias/$2 ] && echo "Alias $2 doesn't exist!" && return - rm -f $NVM_DIR/alias/$2 - echo "Deleted alias $2" - ;; - "copy-packages" ) - if [ $# -ne 2 ]; then - nvm help - return - fi - VERSION=`nvm_version $2` - ROOT=`nvm use $VERSION && npm -g root` - INSTALLS=`nvm use $VERSION > /dev/null && npm -g -p ll | grep "$ROOT\/[^/]\+$" | cut -d '/' -f 8 | cut -d ":" -f 2 | grep -v npm | tr "\n" " "` - npm install -g $INSTALLS - ;; - "clear-cache" ) - rm -f $NVM_DIR/v* 2>/dev/null - echo "Cache cleared." - ;; - "version" ) - print_versions "`nvm_version $2`" - ;; - * ) - nvm help - ;; - esac -} - -nvm ls default >/dev/null 2>&1 && nvm use default >/dev/null From cab40e02b995984ee66afb40736c352e3e1ef014 Mon Sep 17 00:00:00 2001 From: oxnz Date: Tue, 17 Nov 2015 19:29:22 +0800 Subject: [PATCH 083/216] improve extract function to support a short help message as well as some more formats support --- plugins/available/extract.plugin.bash | 80 +++++++++++++++++++-------- 1 file changed, 56 insertions(+), 24 deletions(-) diff --git a/plugins/available/extract.plugin.bash b/plugins/available/extract.plugin.bash index bb520451..e357814a 100644 --- a/plugins/available/extract.plugin.bash +++ b/plugins/available/extract.plugin.bash @@ -1,27 +1,59 @@ cite about-plugin about-plugin 'one command to extract them all...' -extract () { - if [ $# -ne 1 ] - then - echo "Error: No file specified." - return 1 - fi - if [ -f $1 ] ; then - case $1 in - *.tar.bz2) tar xvjf $1 ;; - *.tar.gz) tar xvzf $1 ;; - *.bz2) bunzip2 $1 ;; - *.rar) unrar x $1 ;; - *.gz) gunzip $1 ;; - *.tar) tar xvf $1 ;; - *.tbz2) tar xvjf $1 ;; - *.tgz) tar xvzf $1 ;; - *.zip) unzip $1 ;; - *.Z) uncompress $1 ;; - *.7z) 7z x $1 ;; - *) echo "'$1' cannot be extracted via extract" ;; - esac - else - echo "'$1' is not a valid file" - fi + +# extract file(s) from compressed status +extract() { + local opt + local OPTIND=1 + while getopts "hv" opt; do + case "$opt" in + h) + cat < + options: + -h show this message and exit + -v verbosely list files processed +End-Of-Usage + return + ;; + v) + local -r verbose='v' + ;; + ?) + extract -h >&2 + return 1 + ;; + esac + done + shift $((OPTIND-1)) + + [ $# -eq 0 ] && extract -h && return 1 + while [ $# -gt 0 ]; do + if [ -f "$1" ]; then + case "$1" in + *.tar.bz2|*.tbz|*.tbz2) tar "x${verbose}jf" "$1" ;; + *.tar.gz|*.tgz) tar "x${verbose}zf" "$1" ;; + *.tar.xz) xz --decompress "$1"; set -- "$@" "${1:0:-3}" ;; + *.tar.Z) uncompress "$1"; set -- "$@" "${1:0:-2}" ;; + *.bz2) bunzip2 "$1" ;; + *.deb) dpkg-deb -x${verbose} "$1" "${1:0:-4}" ;; + *.pax.gz) gunzip "$1"; set -- "$@" "${1:0:-3}" ;; + *.gz) gunzip "$1" ;; + *.pax) pax -r -f "$1" ;; + *.pkg) pkgutil --expand "$1" "${1:0:-4}" ;; + *.rar) unrar x "$1" ;; + *.rpm) rpm2cpio "$1" | cpio -idm${verbose} ;; + *.tar) tar "x${verbose}f" "$1" ;; + *.txz) mv "$1" "${1:0:-4}.tar.xz"; set -- "$@" "${1:0:-4}.tar.xz" ;; + *.xz) xz --decompress "$1" ;; + *.zip|*.war|*.jar) unzip "$1" ;; + *.Z) uncompress "$1" ;; + *.7z) 7za x "$1" ;; + *) echo "'$1' cannot be extracted via extract" >&2;; + esac + else + echo "extract: '$1' is not a valid file" >&2 + fi + shift + done } From d589f9547745a11726d74ec33e943f2e6dfc7acb Mon Sep 17 00:00:00 2001 From: Don Reilly Date: Tue, 24 Nov 2015 15:55:06 -0600 Subject: [PATCH 084/216] Allow custom themes to be in $BASH_IT/custom/themes --- lib/appearance.bash | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/appearance.bash b/lib/appearance.bash index fecb4686..05e0e40a 100644 --- a/lib/appearance.bash +++ b/lib/appearance.bash @@ -7,7 +7,15 @@ export GREP_COLOR='1;33' # colored ls export LSCOLORS='Gxfxcxdxdxegedabagacad' +if [[ -z "$CUSTOM_THEME_DIR" ]]; then + CUSTOM_THEME_DIR="${BASH_IT}/custom/themes" +fi + # Load the theme if [[ $BASH_IT_THEME ]]; then - source "$BASH_IT/themes/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash" + if [[ -f "$CUSTOM_THEME_DIR/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash" ]]; then + source "$CUSTOM_THEME_DIR/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash" + else + source "$BASH_IT/themes/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash" + fi fi From e164f0d7f189dc8b38626152eb60b1a3ea243f45 Mon Sep 17 00:00:00 2001 From: Don Reilly Date: Wed, 25 Nov 2015 14:24:45 -0600 Subject: [PATCH 085/216] Update README.md for custom themes --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 49f54a33..638f3a97 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ bash-it help completions # shows help for installed completions bash-it help plugins # shows help for installed plugins ``` -## Your Custom scripts, aliases, and functions +## Your Custom scripts, aliases, themes, and functions For custom scripts, and aliases, just create the following files (they'll be ignored by the git repo): @@ -41,6 +41,7 @@ For custom scripts, and aliases, just create the following files (they'll be ign * `completion/custom.completion.bash` * `lib/custom.bash` * `plugins/custom.plugins.bash` +* `custom/themes//.theme.bash` Anything in the custom directory will be ignored, with the exception of `custom/example.bash`. From 5396bf69a017a6cca3e8526b93224d23e59447fb Mon Sep 17 00:00:00 2001 From: Dongri Jin Date: Fri, 27 Nov 2015 01:15:30 +0900 Subject: [PATCH 086/216] Initial commit --- themes/pro/pro.theme.bash | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 themes/pro/pro.theme.bash diff --git a/themes/pro/pro.theme.bash b/themes/pro/pro.theme.bash new file mode 100644 index 00000000..2294810e --- /dev/null +++ b/themes/pro/pro.theme.bash @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +light_blue="$(color reset blue)" +light_red="$(color reset red)" + + +SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗" +SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓" +SCM_THEME_PROMPT_PREFIX=" ${light_blue}scm:(" +SCM_THEME_PROMPT_SUFFIX="${light_blue})" + +GIT_THEME_PROMPT_DIRTY=" ${bold_red}✗" +GIT_THEME_PROMPT_CLEAN=" ${bold_green}✓" +GIT_THEME_PROMPT_PREFIX="${light_blue}git:(" +GIT_THEME_PROMPT_SUFFIX="${light_blue})" + +RVM_THEME_PROMPT_PREFIX="|" +RVM_THEME_PROMPT_SUFFIX="|" + +function git_prompt_info { + git_prompt_vars + echo -e "$SCM_PREFIX$SCM_BRANCH$SCM_STATE$SCM_SUFFIX" +} + +prompt() { + PS1="\h: ${reset_color}${green}\W${reset_color} $(scm_prompt_info)${reset_color}${reset_color} $ " +} + +PROMPT_COMMAND=prompt From 5f246cfcac69288e9f73c1af2bcde04b816d5549 Mon Sep 17 00:00:00 2001 From: Dongri Jin Date: Fri, 27 Nov 2015 01:16:20 +0900 Subject: [PATCH 087/216] Fix --- themes/pro/pro.theme.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/pro/pro.theme.bash b/themes/pro/pro.theme.bash index 2294810e..ac5daf77 100644 --- a/themes/pro/pro.theme.bash +++ b/themes/pro/pro.theme.bash @@ -5,12 +5,12 @@ light_red="$(color reset red)" SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗" -SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓" +SCM_THEME_PROMPT_CLEAN=" ${green}✓" SCM_THEME_PROMPT_PREFIX=" ${light_blue}scm:(" SCM_THEME_PROMPT_SUFFIX="${light_blue})" GIT_THEME_PROMPT_DIRTY=" ${bold_red}✗" -GIT_THEME_PROMPT_CLEAN=" ${bold_green}✓" +GIT_THEME_PROMPT_CLEAN=" ${green}✓" GIT_THEME_PROMPT_PREFIX="${light_blue}git:(" GIT_THEME_PROMPT_SUFFIX="${light_blue})" From 53d2452276396db6415a7cdc8dd335819b65a5fe Mon Sep 17 00:00:00 2001 From: Dongri Jin Date: Fri, 27 Nov 2015 01:19:14 +0900 Subject: [PATCH 088/216] Fix --- themes/pro/pro.theme.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/pro/pro.theme.bash b/themes/pro/pro.theme.bash index ac5daf77..a46c6474 100644 --- a/themes/pro/pro.theme.bash +++ b/themes/pro/pro.theme.bash @@ -11,8 +11,8 @@ SCM_THEME_PROMPT_SUFFIX="${light_blue})" GIT_THEME_PROMPT_DIRTY=" ${bold_red}✗" GIT_THEME_PROMPT_CLEAN=" ${green}✓" -GIT_THEME_PROMPT_PREFIX="${light_blue}git:(" -GIT_THEME_PROMPT_SUFFIX="${light_blue})" +GIT_THEME_PROMPT_PREFIX="${light_blue}git:( " +GIT_THEME_PROMPT_SUFFIX="${light_blue} )" RVM_THEME_PROMPT_PREFIX="|" RVM_THEME_PROMPT_SUFFIX="|" From 1eb7b4b4c28d844d5ddb28d3b50800943437be58 Mon Sep 17 00:00:00 2001 From: Dongri Jin Date: Fri, 27 Nov 2015 01:37:53 +0900 Subject: [PATCH 089/216] Fix --- themes/pro/pro.theme.bash | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/themes/pro/pro.theme.bash b/themes/pro/pro.theme.bash index a46c6474..74e74ad8 100644 --- a/themes/pro/pro.theme.bash +++ b/themes/pro/pro.theme.bash @@ -1,29 +1,22 @@ #!/usr/bin/env bash -light_blue="$(color reset blue)" -light_red="$(color reset red)" - - -SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗" +SCM_THEME_PROMPT_DIRTY=" ${red}✗" SCM_THEME_PROMPT_CLEAN=" ${green}✓" -SCM_THEME_PROMPT_PREFIX=" ${light_blue}scm:(" -SCM_THEME_PROMPT_SUFFIX="${light_blue})" +SCM_THEME_PROMPT_PREFIX=" ${blue}scm:(" +SCM_THEME_PROMPT_SUFFIX="${blue})" -GIT_THEME_PROMPT_DIRTY=" ${bold_red}✗" +GIT_THEME_PROMPT_DIRTY=" ${red}✗" GIT_THEME_PROMPT_CLEAN=" ${green}✓" -GIT_THEME_PROMPT_PREFIX="${light_blue}git:( " -GIT_THEME_PROMPT_SUFFIX="${light_blue} )" - -RVM_THEME_PROMPT_PREFIX="|" -RVM_THEME_PROMPT_SUFFIX="|" +GIT_THEME_PROMPT_PREFIX="${echo_green}git:( " +GIT_THEME_PROMPT_SUFFIX="${echo_green} )" function git_prompt_info { git_prompt_vars echo -e "$SCM_PREFIX$SCM_BRANCH$SCM_STATE$SCM_SUFFIX" } -prompt() { - PS1="\h: ${reset_color}${green}\W${reset_color} $(scm_prompt_info)${reset_color}${reset_color} $ " +function prompt() { + PS1="\h: \W $(scm_prompt_info)${reset_color} $ " } PROMPT_COMMAND=prompt From 9c9c20da2aa2cc671f62fb1a66c65e26f7b8b42d Mon Sep 17 00:00:00 2001 From: Dongri Jin Date: Fri, 27 Nov 2015 01:41:19 +0900 Subject: [PATCH 090/216] Fix --- themes/pro/pro.theme.bash | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/themes/pro/pro.theme.bash b/themes/pro/pro.theme.bash index 74e74ad8..6ac697bf 100644 --- a/themes/pro/pro.theme.bash +++ b/themes/pro/pro.theme.bash @@ -2,13 +2,13 @@ SCM_THEME_PROMPT_DIRTY=" ${red}✗" SCM_THEME_PROMPT_CLEAN=" ${green}✓" -SCM_THEME_PROMPT_PREFIX=" ${blue}scm:(" -SCM_THEME_PROMPT_SUFFIX="${blue})" +SCM_THEME_PROMPT_PREFIX=" ${blue}scm:( " +SCM_THEME_PROMPT_SUFFIX="${blue} )" GIT_THEME_PROMPT_DIRTY=" ${red}✗" GIT_THEME_PROMPT_CLEAN=" ${green}✓" -GIT_THEME_PROMPT_PREFIX="${echo_green}git:( " -GIT_THEME_PROMPT_SUFFIX="${echo_green} )" +GIT_THEME_PROMPT_PREFIX="${green}git:( " +GIT_THEME_PROMPT_SUFFIX="${green} )" function git_prompt_info { git_prompt_vars From b967674e6cd4b909db657de214b03beafa61b58d Mon Sep 17 00:00:00 2001 From: Bill Moritz Date: Sat, 5 Dec 2015 11:52:58 -0500 Subject: [PATCH 091/216] Add support for AWS Tools Profile. http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html --- themes/base.theme.bash | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index fc5e529a..c491e5e5 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -188,9 +188,9 @@ function svn_prompt_vars { } # this functions returns absolute location of .hg directory if one exists -# It starts in the current directory and moves its way up until it hits /. +# It starts in the current directory and moves its way up until it hits /. # If we get to / then no Mercurial repository was found. -# Example: +# Example: # - lets say we cd into ~/Projects/Foo/Bar # - .hg is located in ~/Projects/Foo/.hg # - get_hg_root starts at ~/Projects/Foo/Bar and sees that there is no .hg directory, so then it goes into ~/Projects/Foo @@ -221,7 +221,7 @@ function hg_prompt_vars { HG_ROOT=$(get_hg_root) if [ -f $HG_ROOT/branch ]; then - # Mercurial holds it's current branch in .hg/branch file + # Mercurial holds it's current branch in .hg/branch file SCM_BRANCH=$(cat $HG_ROOT/branch) else SCM_BRANCH=$(hg summary 2> /dev/null | grep branch: | awk '{print $2}') @@ -352,3 +352,11 @@ if [ ! -e $BASH_IT/plugins/enabled/battery.plugin.bash ]; then echo -n } fi + +function aws_profile { + if [[ $AWS_DEFAULT_PROFILE ]]; then + echo -e "${AWS_DEFAULT_PROFILE}" + else + echo -e "default" + fi +} From d8ce333ae76fba6dfadfa71102f336c1d65f7cb3 Mon Sep 17 00:00:00 2001 From: Bill Moritz Date: Sun, 6 Dec 2015 09:55:19 -0500 Subject: [PATCH 092/216] Add Support for different docker-machine VM names Add the variable BASH_IT_DOCKER_MACHINE to set a name other than 'dev' as Virtual Machine name. --- plugins/available/docker-machine.plugin.bash | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/available/docker-machine.plugin.bash b/plugins/available/docker-machine.plugin.bash index fc2dc44d..95827f42 100644 --- a/plugins/available/docker-machine.plugin.bash +++ b/plugins/available/docker-machine.plugin.bash @@ -1,11 +1,13 @@ cite about-plugin about-plugin 'Helpers to get Docker setup correctly for docker-machine' +[ -z ${BASH_IT_DOCKER_MACHINE+x} ] && BASH_IT_DOCKER_MACHINE='dev' + # Note, this might need to be different if you use a machine other than 'dev' if [[ `uname -s` == "Darwin" ]]; then # check if dev machine is running - docker-machine ls | grep --quiet 'dev.*Running' + docker-machine ls | grep --quiet "$BASH_IT_DOCKER_MACHINE.*Running" if [[ "$?" = "0" ]]; then - eval "$(docker-machine env dev)" + eval "$(docker-machine env $BASH_IT_DOCKER_MACHINE)" fi fi From f2acd2035683779a754c2c35d90d067f9ccbd760 Mon Sep 17 00:00:00 2001 From: Sebastian Just Date: Mon, 7 Dec 2015 14:52:56 -0500 Subject: [PATCH 093/216] Added simple support for terraform Not providing help for the speicifc commands yet but at least complete the available commands as a starting point --- .../available/terraform.completion.bash | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 completion/available/terraform.completion.bash diff --git a/completion/available/terraform.completion.bash b/completion/available/terraform.completion.bash new file mode 100644 index 00000000..729c72b6 --- /dev/null +++ b/completion/available/terraform.completion.bash @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# Bash Terraform completion + +_terraform() +{ + local cmds cur colonprefixes + cmds="apply destroy get graph init output plan push \ + refresh remote show taint version" + + COMPREPLY=() + cur=${COMP_WORDS[COMP_CWORD]} + # Work-around bash_completion issue where bash interprets a colon + # as a separator. + # Work-around borrowed from the darcs work-around for the same + # issue. + colonprefixes=${cur%"${cur##*:}"} + COMPREPLY=( $(compgen -W '$cmds' -- $cur)) + local i=${#COMPREPLY[*]} + while [ $((--i)) -ge 0 ]; do + COMPREPLY[$i]=${COMPREPLY[$i]#"$colonprefixes"} + done + + return 0 +} && +complete -F _terraform terraform From 6515ff40070c57dbd828aaa5e9674393bb16fecb Mon Sep 17 00:00:00 2001 From: Raphael Parree Date: Mon, 14 Dec 2015 17:03:35 +0100 Subject: [PATCH 094/216] Added jboss 7 completion --- completion/available/jboss7.completion.bash | 141 ++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 completion/available/jboss7.completion.bash diff --git a/completion/available/jboss7.completion.bash b/completion/available/jboss7.completion.bash new file mode 100644 index 00000000..66d07179 --- /dev/null +++ b/completion/available/jboss7.completion.bash @@ -0,0 +1,141 @@ +# Completions for JBoss Application Server 7 (EAP 6) +# VERSION: 0.6 +# DATE: 2012-10-30 +# rparree-at-edc4it-dot-com + + + + +_serverProfiles(){ + if [[ $COMP_WORDS == *standalone.sh* ]] + then + serverdir="../standalone/configuration/" + else + # assume is domain.sh + serverdir="../domain/configuration/" + fi + + for i in ${!COMP_WORDS[*]} + do + if [[ "${COMP_WORDS[i]}" == "-Djboss.server.base.dir" || "${COMP_WORDS[i]}" == "-Djboss.domain.base.dir" ]]; then + serverdir="${COMP_WORDS[i+2]}/configuration" + fi + + done + if [ -d "${serverdir}" ] + then + + IFS=$'\n' tmp="$(ls "${serverdir}" | grep xml)" + local fls="${tmp[@]// /\ }" + unset IFS + COMPREPLY=( $(compgen -W "${fls} initial boot last v" -- "$cur" )) + fi +} + +_bindingAddress(){ + # from /etc/bash_completion.d/ssh + COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \ + "0.0.0.0 $( PATH="$PATH:/sbin" ifconfig -a | \ + sed -ne 's/.*addr:\([^[:space:]]*\).*/\1/p' \ + -ne 's/.*inet[[:space:]]\{1,\}\([^[:space:]]*\).*/\1/p' )" \ + -- "$cur" ) ) +} + +_jboss(){ + + local cur prev words cword + COMPREPLY=() + _get_comp_words_by_ref -n = cur prev words cword + + case $cur in + + -Djboss.socket.binding.port-offset=*) + cur=${cur#*=} + #static list of common bindings sets + local bindings="100 200 300 400 10000 20000 30000 40000" + COMPREPLY=( $(compgen -W "${bindings}" -- ${cur}) ) + return 0 + ;; + -Djboss.default.jgroups.stack=*) + cur=${cur#*=} + #static list of standard JGroups stacks + local stacks="udp udp-async udp-sync tcp tcp-sync" + COMPREPLY=( $(compgen -W "${stacks}" -- ${cur}) ) + return 0 + ;; + + -Dorg.jboss.ejb3.remoting.IsLocalInterceptor.passByRef=*|-Dcom.sun.management.jmxremote.authenticate=*|-Dcom.sun.management.jmxremote.ssl=*) + cur=${cur#*=} + local booleans="true false" + COMPREPLY=( $(compgen -W "${booleans}" -- ${cur}) ) + return 0 + ;; + + -Djboss.server.base.dir=*|-Djboss.home.dir=*|-Djboss.domain.base.dir=*) + cur=${cur#*=} + _filedir -d + return 0 + ;; + + -Djboss.domain.master.address=*|-Djboss.bind.address*=*) + cur=${cur#*=} + _bindingAddress + return 0 + ;; + --server-config=*|-c=|--host-config=*) + cur=${cur#*=} + _serverProfiles + return 0 + + + esac + + + case $prev in + -u) + # a few from RFC 2365 IPv4 Local Scope () + local addresses="239.255.0.1 239.255.0.2 239.255.0.3" + COMPREPLY=( $(compgen -W "${addresses}" -- ${cur}) ) + return 0 + ;; + -b*) + _bindingAddress + return 0 + ;; + -c) + _serverProfiles + return 0 + ;; + *) + ;; + esac + # *** from jboss5 ******************** + # *** -modulepath -c -m -g -l -d -p -n -B -L -C -Djboss.platform.mbeanserver -Djboss.server.base.directory + # *** -Djboss.Domain -Djboss.modcluster.proxyList -Djboss.jvmRoute -Djboss.default.jgroups.stack -Dorg.jboss.ejb3.remoting.IsLocalInterceptor.passByRef -Djboss.platform.mbeanserver -Dcom.sun.management.jmxremote.port -Dcom.sun.management.jmxremote.ssl + # ************************************* + + # standard commands for standalone and domain mode + local commandsWithoutEqualSign='-b -bmanagement -bunsecure -bpublic --admin-only -h -help -u -version -V -v' + local commandsWithEqualSign='-P -Djboss.node.name -Djboss.home.dir -Djboss.socket.binding.port-offset -Djboss.bind.address.management -Djboss.bind.address -Djboss.bind.address.unsecure' + + if [[ $COMP_WORDS == *standalone.sh* ]] + then + commandsWithoutEqualSign="${commandsWithoutEqualSign} -c" + commandsWithEqualSign="${commandsWithEqualSign} --server-config -Djboss.server.base.dir -c" + else + # assume is domain.sh + commandsWithoutEqualSign="${commandsWithoutEqualSign} --backup --cached-dc" + commandsWithEqualSign="${commandsWithEqualSign} -Djboss.domain.master.address --host-config -Djboss.domain.master.port -Djboss.domain.base.dir " + fi + + + + + COMPREPLY=( $( compgen -W "$commandsWithoutEqualSign" -- "$cur" ) + $( compgen -W "$commandsWithEqualSign" -S '=' -- "$cur" ) ) + return 0 + + +} +complete -o nospace -F _jboss standalone.sh +complete -o nospace -F _jboss domain.sh From 567b19333f3e9685b2e1ca2c525304cf93661af0 Mon Sep 17 00:00:00 2001 From: gbanks Date: Thu, 17 Dec 2015 12:53:58 -0700 Subject: [PATCH 095/216] Add alias for apm install --- aliases/available/atom.aliases.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/aliases/available/atom.aliases.bash b/aliases/available/atom.aliases.bash index f067697d..8d70cffa 100644 --- a/aliases/available/atom.aliases.bash +++ b/aliases/available/atom.aliases.bash @@ -4,3 +4,4 @@ about-alias 'Atom.io editor abbreviations' alias a='atom' alias ah='atom .' alias apmup='apm update --no-confirm' +alias apmi='apm install' From 337caf1a503e25abb6ad4e588eb6eee812bc35fc Mon Sep 17 00:00:00 2001 From: James Whisnant Date: Fri, 18 Dec 2015 18:12:07 -0500 Subject: [PATCH 096/216] Add support to zork them for crouton debian chroot and virtualenv Adds support for a crouton debian chroot and python virtualenvwrapper to the zork theme. --- themes/zork/zork.theme.bash | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/themes/zork/zork.theme.bash b/themes/zork/zork.theme.bash index c71f1344..5c9becda 100644 --- a/themes/zork/zork.theme.bash +++ b/themes/zork/zork.theme.bash @@ -46,6 +46,27 @@ modern_scm_prompt() { fi } +# show chroot if exist +chroot(){ + if [ -n "$debian_chroot" ] + then + my_ps_chroot="\[\033[01;36m\]\$debian_chroot\[\033[00m\]"; + echo "($my_ps_chroot)"; + fi + } + +# show virtualenvwrapper +my_ve(){ + if [ -n "$VIRTUAL_ENV" ] + then + my_ps_ve="\[\033[01;35m\]\$ve\[\033[00m\]"; + echo "($my_ps_ve)"; + fi + echo ""; + } + + + prompt() { case $HOSTNAME in @@ -61,12 +82,17 @@ prompt() { my_ps_root="\[\033[01;31m\]\u\[\033[00m\]"; my_ps_path="\[\033[01;36m\]\w\[\033[00m\]"; + if [ -n "$VIRTUAL_ENV" ] + then + ve=`basename $VIRTUAL_ENV`; + fi + # nice prompt case "`id -u`" in - 0) PS1="${TITLEBAR}┌─[$my_ps_root][$my_ps_host]$(modern_scm_prompt)$(__my_rvm_ruby_version)[${cyan}\w${normal}]$(is_vim_shell) + 0) PS1="${TITLEBAR}┌─$(my_ve)$(chroot)[$my_ps_root][$my_ps_host]$(modern_scm_prompt)$(__my_rvm_ruby_version)[${cyan}\w${normal}]$(is_vim_shell) └─▪ " ;; - *) PS1="${TITLEBAR}┌─[$my_ps_user][$my_ps_host]$(modern_scm_prompt)$(__my_rvm_ruby_version)[${cyan}\w${normal}]$(is_vim_shell) + *) PS1="${TITLEBAR}┌─$(my_ve)$(chroot)[$my_ps_user][$my_ps_host]$(modern_scm_prompt)$(__my_rvm_ruby_version)[${cyan}\w${normal}]$(is_vim_shell) └─▪ " ;; esac From ddba9555c7dbc04bb76689922461425b286a876c Mon Sep 17 00:00:00 2001 From: James Whisnant Date: Sat, 19 Dec 2015 23:28:23 -0500 Subject: [PATCH 097/216] use words instead of escape codes, some code cleanup --- themes/zork/zork.theme.bash | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/themes/zork/zork.theme.bash b/themes/zork/zork.theme.bash index 5c9becda..456ac0de 100644 --- a/themes/zork/zork.theme.bash +++ b/themes/zork/zork.theme.bash @@ -50,7 +50,7 @@ modern_scm_prompt() { chroot(){ if [ -n "$debian_chroot" ] then - my_ps_chroot="\[\033[01;36m\]\$debian_chroot\[\033[00m\]"; + my_ps_chroot="${bold_cyan}$debian_chroot${normal}"; echo "($my_ps_chroot)"; fi } @@ -59,28 +59,20 @@ chroot(){ my_ve(){ if [ -n "$VIRTUAL_ENV" ] then - my_ps_ve="\[\033[01;35m\]\$ve\[\033[00m\]"; + my_ps_ve="${bold_purple}$ve${normal}"; echo "($my_ps_ve)"; fi echo ""; } - - prompt() { - case $HOSTNAME in - "zork"* ) my_ps_host="${green}\h${normal}"; - ;; - "pandora") my_ps_host="${red}\h${normal}"; - ;; - * ) my_ps_host="${green}\h${normal}"; - ;; - esac - - my_ps_user="\[\033[01;32m\]\u\[\033[00m\]"; - my_ps_root="\[\033[01;31m\]\u\[\033[00m\]"; - my_ps_path="\[\033[01;36m\]\w\[\033[00m\]"; + my_ps_host="${green}\h${normal}"; + # yes, these are the the same for now ... + my_ps_host_root="${green}\h${normal}"; + + my_ps_user="${green}\h${normal}" + my_ps_root="${bold_red}\u${normal}"; if [ -n "$VIRTUAL_ENV" ] then @@ -89,7 +81,7 @@ prompt() { # nice prompt case "`id -u`" in - 0) PS1="${TITLEBAR}┌─$(my_ve)$(chroot)[$my_ps_root][$my_ps_host]$(modern_scm_prompt)$(__my_rvm_ruby_version)[${cyan}\w${normal}]$(is_vim_shell) + 0) PS1="${TITLEBAR}┌─$(my_ve)$(chroot)[$my_ps_root][$my_ps_host_root]$(modern_scm_prompt)$(__my_rvm_ruby_version)[${cyan}\w${normal}]$(is_vim_shell) └─▪ " ;; *) PS1="${TITLEBAR}┌─$(my_ve)$(chroot)[$my_ps_user][$my_ps_host]$(modern_scm_prompt)$(__my_rvm_ruby_version)[${cyan}\w${normal}]$(is_vim_shell) From fbd0a33cd1c5dc0a8ed6c7c2ed221fde9e6f346d Mon Sep 17 00:00:00 2001 From: James Whisnant Date: Sat, 19 Dec 2015 23:37:12 -0500 Subject: [PATCH 098/216] fix normal user username --- themes/zork/zork.theme.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/zork/zork.theme.bash b/themes/zork/zork.theme.bash index 456ac0de..c022a408 100644 --- a/themes/zork/zork.theme.bash +++ b/themes/zork/zork.theme.bash @@ -71,7 +71,7 @@ prompt() { # yes, these are the the same for now ... my_ps_host_root="${green}\h${normal}"; - my_ps_user="${green}\h${normal}" + my_ps_user="${bold_green}\u${normal}" my_ps_root="${bold_red}\u${normal}"; if [ -n "$VIRTUAL_ENV" ] From 127ac23eead252d7f06023ae1f9de49539a3827a Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Tue, 22 Dec 2015 09:39:41 +0100 Subject: [PATCH 099/216] Added base plugin to default install Fixes #609 --- install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install.sh b/install.sh index 791abe79..b9926110 100755 --- a/install.sh +++ b/install.sh @@ -89,6 +89,7 @@ else echo "" echo -e "\033[0;32mEnabling sane defaults\033[0m" load_one completion bash-it.completion.bash + load_one plugins base.plugin.bash load_one plugins alias-completion.plugin.bash load_one aliases general.aliases.bash fi From 1dcfecbc17b96c8747fcf18adabf4d41492e5fa6 Mon Sep 17 00:00:00 2001 From: Kyle VanderBeek Date: Wed, 23 Dec 2015 12:49:57 -0800 Subject: [PATCH 100/216] Enable discovery and use of nvm installed via homebrew. https://github.com/Homebrew/homebrew/blob/master/Library/Formula/nvm.rb#L27 --- plugins/available/nvm.plugin.bash | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/available/nvm.plugin.bash b/plugins/available/nvm.plugin.bash index 72f47fd5..3959c236 100644 --- a/plugins/available/nvm.plugin.bash +++ b/plugins/available/nvm.plugin.bash @@ -6,7 +6,13 @@ cite about-plugin about-plugin 'node version manager configuration' export NVM_DIR="$HOME/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm +# This loads nvm +if command -v brew &>/dev/null && [ -s $(brew --prefix nvm)/nvm.sh ] +then + . $(brew --prefix nvm)/nvm.sh +else + [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" +fi if ! command -v nvm &>/dev/null then From 468475dc49e3185b3f2de75f970e0bbf7106f107 Mon Sep 17 00:00:00 2001 From: wxf Date: Fri, 1 Jan 2016 15:36:50 +0800 Subject: [PATCH 101/216] add personal theme --- themes/morris/morris.theme.bash | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 themes/morris/morris.theme.bash diff --git a/themes/morris/morris.theme.bash b/themes/morris/morris.theme.bash new file mode 100644 index 00000000..27571bde --- /dev/null +++ b/themes/morris/morris.theme.bash @@ -0,0 +1,25 @@ + +# prompt theming + +# added TITLEBAR for updating the tab and window titles with the pwd +case $TERM in + xterm*) + TITLEBAR="\[\033]0;\w\007\]" + ;; + *) + TITLEBAR="" + ;; +esac + +function prompt_command() { + PS1="${TITLEBAR}[\u@\h \W $(scm_prompt_info)]\$ " +} + +# scm theming +SCM_THEME_PROMPT_DIRTY=" ${red}✗" +SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓" +SCM_THEME_PROMPT_PREFIX="${green}(" +SCM_THEME_PROMPT_SUFFIX="${green})${reset_color}" + + +PROMPT_COMMAND=prompt_command; From 56fdb6333c513ebb836c3ad0e9256396efa4822c Mon Sep 17 00:00:00 2001 From: wxf Date: Fri, 1 Jan 2016 15:46:53 +0800 Subject: [PATCH 102/216] support system completion --- completion/available/system.completion.bash | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 completion/available/system.completion.bash diff --git a/completion/available/system.completion.bash b/completion/available/system.completion.bash new file mode 100644 index 00000000..b13121d7 --- /dev/null +++ b/completion/available/system.completion.bash @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +if [ -f /etc/bash_completion ]; + . /etc/bash_completion +fi From 9cb4ae0650441c844ec4408578ad36b1028cb4a7 Mon Sep 17 00:00:00 2001 From: wxf Date: Fri, 1 Jan 2016 16:29:26 +0800 Subject: [PATCH 103/216] add host info in titlebar --- themes/morris/morris.theme.bash | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/themes/morris/morris.theme.bash b/themes/morris/morris.theme.bash index 27571bde..da51e55a 100644 --- a/themes/morris/morris.theme.bash +++ b/themes/morris/morris.theme.bash @@ -4,11 +4,14 @@ # added TITLEBAR for updating the tab and window titles with the pwd case $TERM in xterm*) - TITLEBAR="\[\033]0;\w\007\]" - ;; + TITLEBAR=$(printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}") + ;; + screen) + TITLEBAR=$(printf "\033]0;%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}") + ;; *) - TITLEBAR="" - ;; + TITLEBAR="" + ;; esac function prompt_command() { From 25940111e8ace733d0b0ae7856e48453818003a1 Mon Sep 17 00:00:00 2001 From: was4444 Date: Mon, 4 Jan 2016 18:42:40 +0800 Subject: [PATCH 104/216] fix wrong syntax --- completion/available/system.completion.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/completion/available/system.completion.bash b/completion/available/system.completion.bash index b13121d7..d3076593 100644 --- a/completion/available/system.completion.bash +++ b/completion/available/system.completion.bash @@ -1,5 +1,5 @@ #!/usr/bin/env bash -if [ -f /etc/bash_completion ]; +if [ -f /etc/bash_completion ]; then . /etc/bash_completion fi From 38bd3a3b9907fa470a0cafc3c729bfce4d09b520 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Tue, 5 Jan 2016 07:31:09 +0100 Subject: [PATCH 105/216] Loading Homebrew Bash Completion if installed In addition to the regular /etc/bash_completion, the one from Homebrew is loaded when running on OS X, and when Homebrew is installed. Also added the system completion to the default install options, since this is a feature that's requested frequently. --- completion/available/system.completion.bash | 13 ++++++++++++- install.sh | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/completion/available/system.completion.bash b/completion/available/system.completion.bash index d3076593..aeaa5375 100644 --- a/completion/available/system.completion.bash +++ b/completion/available/system.completion.bash @@ -1,5 +1,16 @@ #!/usr/bin/env bash +# Loads the system's Bash completion modules. +# If Homebrew is installed (OS X), its Bash completion modules are loaded. + if [ -f /etc/bash_completion ]; then - . /etc/bash_completion + . /etc/bash_completion +fi + +if [ $(uname) = "Darwin" ] && command -v brew &>/dev/null ; then + BREW_PREFIX=$(brew --prefix) + + if [ -f "$BREW_PREFIX"/etc/bash_completion ]; then + . "$BREW_PREFIX"/etc/bash_completion + fi fi diff --git a/install.sh b/install.sh index b9926110..d3c9b001 100755 --- a/install.sh +++ b/install.sh @@ -89,6 +89,7 @@ else echo "" echo -e "\033[0;32mEnabling sane defaults\033[0m" load_one completion bash-it.completion.bash + load_one completion system.completion.bash load_one plugins base.plugin.bash load_one plugins alias-completion.plugin.bash load_one aliases general.aliases.bash From f21795a9fc07d687e8eca02aa76be1a223530a13 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Tue, 5 Jan 2016 08:18:00 +0100 Subject: [PATCH 106/216] Added first draft of contribution guidelines --- CONTRIBUTING.md | 34 ++++++++++++++++++++++++++++++++++ README.md | 6 ++++++ 2 files changed, 40 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..ca8688b2 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,34 @@ +# Contribution Guidelines + +When contributing a new feature, a bug fix, a new theme, or any other change to Bash-it, please consider the following guidelines. Most of this is common sense, but please try to stick to the conventions listed here. + +## Issues + +* When opening a new issue in the issue tracker, please include information about which _Operating System_ you're using, and which version of _Bash_. +* In many cases, it also makes sense to show which Bash-it plugins you are using. This information can be obtained using `bash-it show plugins`. +* If the issue happens while loading Bash-it, please also include your `~/.bash_profile` or `~/.bashrc` file, as well as the install location of Bash-it (default should be `~/.bash_it`). +* When reporting a bug or requesting a new feature, consider providing a Pull Request that fixes the issue or can be used as a starting point for the new feature. Don't be afraid, most things aren't that complex... + +## Pull Requests + +* Fork the Bash-it repo, create a new feature branch from _master_ and apply your changes there. Create a _Pull Request_ from your feature branch against Bash-it's _master_ branch. +* Limit each Pull Request to one feature. Don't bundle multiple features/changes (e.g. a new _Theme_ and a fix to an existing plugin) into a single Pull Request - create one PR for the theme, and a separate PR for the fix. +* For complex changes, try to _squash_ your changes into a single commit. Don't create a PR consisting of 20 commits that show your work in progress. Before you create the PR, _squash_ your changes into a single commit. + +## Code Style + +* Try to stick to the existing code style. Please don't reformat or change the syntax of existing code simply because you don't like that style. +* Indentation is using spaces, not tabs. Most of the code is indented with 2 spaces, some with 4 spaces. Please try to stick to 2 spaces. +* When creating new functions, please use a dash ("-") to separate the words of the function's name, e.g. `my-new-function`. Don't use underscores, e.g. `my_new_function`. +* Internal functions that aren't to be used by the end user should start with an underscore, e.g. `_my-new-internal-function`. +* Use the provided meta functions to document your code, e.g. `about-plugin`, `about`, `group`, `param`, `example`. This will make it easier for other people to use your new functionality. Take a look at the existing code for an example (e.g. [the base plugin](plugins/available/base.plugin.bash)). +* When adding files, please use the existing file naming conventions, e.g. plugin files need to end in `.plugin.bash`. This is important for the installation functionality. + +## Features + +* When adding new completions or plugins, please don't simply copy existing tools into the Bash-it codebase, try to load/integrate the tools instead. An example is using `nvm`: Instead of copying the existing `nvm` script into Bash-it, the `nvm.plugin.bash` file tries to load an existing installation of `nvm`. This means an additional step for the user (installing `nvm` from its own repo, or through a package manager), but it will also ensure that `nvm` can be upgraded in an easy way. + +## Themes + +* When adding a new theme, please include a screenshot and a short description about what makes this theme unique in the Pull Request. +* Ideally, each theme's folder should contain a `README.md` file describing the theme and its configuration options. diff --git a/README.md b/README.md index 638f3a97..a7bf87ed 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,10 @@ cd $BASH_IT This will restore your previous Bash profile. After the uninstall script finishes, remove the Bash it directory from your machine (`rm -rf $BASH_IT`) and start a new shell. +## Contributing + +Please take a look at the [Contribution Guidelines](CONTRIBUTING.md) before reporting a bug or providing a new feature. + ## Misc ### Bash Profile Aliases @@ -209,6 +213,8 @@ We think everyone has their own custom scripts accumulated over time. And so, fo Send us a pull request and we'll merge it as long as it looks good. If you change an existing command, please give an explanation why. That will help a lot when we merge your changes in. +Please take a look at the [Contribution Guidelines](CONTRIBUTING.md) before reporting a bug or providing a new feature. + Thanks, and happing bashing! From c08c1c095ab3f5681b2838e0072e7a5763e7d4dc Mon Sep 17 00:00:00 2001 From: codefalling Date: Tue, 5 Jan 2016 17:37:27 +0800 Subject: [PATCH 107/216] add plugin:percol --- plugins/available/percol.plugin.bash | 44 ++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 plugins/available/percol.plugin.bash diff --git a/plugins/available/percol.plugin.bash b/plugins/available/percol.plugin.bash new file mode 100644 index 00000000..067c6c8f --- /dev/null +++ b/plugins/available/percol.plugin.bash @@ -0,0 +1,44 @@ +cite about-plugin +about-plugin 'Search&Select history and fasd with percol' + +# Notice +## You have to upgrade bash to bash 4.x on Mac OS X. +## http://stackoverflow.com/questions/16416195/how-do-i-upgrade-bash-in-mac-osx-mountain-lion-and-set-it-the-correct-path + +# Install +## (sudo) pip install percol +## bash-it enable percol +## optional: bash-it enable fasd + +# Usage +## C-r to search&select from history +## zz to search&select from fasd + +_replace_by_history() { + if command -v tac>/dev/null; then + alias _tac=tac + else + alias _tac="tail -r" + fi + local l=$(HISTTIMEFORMAT= history | _tac | sed -e 's/^\ *[0-9]*\ *//' | percol --query "$READLINE_LINE") + READLINE_LINE="$l" + READLINE_POINT=${#l} +} + + +if command -v percol>/dev/null; then + local current_version=${BASH_VERSION%%[^0-9]*} + if [ $current_version -lt 4 ]; then + echo "Warning:You have to upgrade bash to bash 4.x to use percol plugin." + else + bind -x '"\C-r": _replace_by_history' + + # bind zz to percol if fasd enable + if command -v fasd>/dev/null; then + zz(){ + local l=$(fasd -d | awk '{print $2}' | percol) + cd $l + } + fi + fi +fi From eec0aa6e9c3619e7cb13dc73a4889fe11f31025d Mon Sep 17 00:00:00 2001 From: Edward Freeman Date: Tue, 5 Jan 2016 16:58:54 -0800 Subject: [PATCH 108/216] fixed brew cask aliases they removed the - from their CLI --- aliases/available/homebrew-cask.aliases.bash | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/aliases/available/homebrew-cask.aliases.bash b/aliases/available/homebrew-cask.aliases.bash index 37114bb1..f4c4836b 100644 --- a/aliases/available/homebrew-cask.aliases.bash +++ b/aliases/available/homebrew-cask.aliases.bash @@ -3,13 +3,13 @@ cite 'about-alias' about-alias 'homebrew-cask abbreviations' -alias bcup='brew-cask update' -alias bcin='brew-cask install' -alias bcrm='brew-cask uninstall' -alias bczp='brew-cask zap' -alias bccl='brew-cask cleanup' -alias bcsr='brew-cask search' -alias bcls='brew-cask list' -alias bcinf='brew-cask info' -alias bcdr='brew-cask doctor' -alias bced='brew-cask edit' +alias bcup='brew cask update' +alias bcin='brew cask install' +alias bcrm='brew cask uninstall' +alias bczp='brew cask zap' +alias bccl='brew cask cleanup' +alias bcsr='brew cask search' +alias bcls='brew cask list' +alias bcinf='brew cask info' +alias bcdr='brew cask doctor' +alias bced='brew cask edit' From a3efe1479a52d593b8f5a99b767ab32977752883 Mon Sep 17 00:00:00 2001 From: Daniele Andreoli Date: Wed, 6 Jan 2016 12:53:05 +0100 Subject: [PATCH 109/216] Add follow sym link and option to append template to existing .bashrc --- install.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index b9926110..6e4232fd 100755 --- a/install.sh +++ b/install.sh @@ -32,11 +32,22 @@ if [ -e "$HOME/$BACKUP_FILE" ]; then done fi -test -w "$HOME/$CONFIG_FILE" && - cp -a "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" && - echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m" - -sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" > "$HOME/$CONFIG_FILE" +read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash_it templates at the end?[y/N] " choice + case $choice in + [yY]) + (sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" || tail -n +2) >> "$HOME/$CONFIG_FILE" + echo -e "\033[0;32mBash_it template has correctly added to your $CONFIG_FILE\033[0m" + ;; + [nN]|"") + test -w "$HOME/$CONFIG_FILE" && + cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" && + echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m" + sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" > "$HOME/$CONFIG_FILE" + ;; + *) + echo -e "\033[91mPlease choose y or n.\033[m" + ;; + esac echo -e "\033[0;32mCopied the template $CONFIG_FILE into ~/$CONFIG_FILE, edit this file to customize bash-it\033[0m" From 55245cc98e816c63a91e92ccb298c7437e6f0e99 Mon Sep 17 00:00:00 2001 From: Daniele Andreoli Date: Thu, 7 Jan 2016 09:20:23 +0100 Subject: [PATCH 110/216] Fix typo and missing spaces --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 6e4232fd..f8afeaf7 100755 --- a/install.sh +++ b/install.sh @@ -32,11 +32,11 @@ if [ -e "$HOME/$BACKUP_FILE" ]; then done fi -read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash_it templates at the end?[y/N] " choice +read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash-it templates at the end? [y/N] " choice case $choice in [yY]) (sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" || tail -n +2) >> "$HOME/$CONFIG_FILE" - echo -e "\033[0;32mBash_it template has correctly added to your $CONFIG_FILE\033[0m" + echo -e "\033[0;32mBash-it template has been added to your $CONFIG_FILE\033[0m" ;; [nN]|"") test -w "$HOME/$CONFIG_FILE" && From fdc75e42b90bbacf46f8650a85569dee33e6d410 Mon Sep 17 00:00:00 2001 From: Daniele Andreoli Date: Thu, 7 Jan 2016 09:23:36 +0100 Subject: [PATCH 111/216] Add while block to allow correct choice --- install.sh | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/install.sh b/install.sh index f8afeaf7..678197df 100755 --- a/install.sh +++ b/install.sh @@ -32,22 +32,28 @@ if [ -e "$HOME/$BACKUP_FILE" ]; then done fi -read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash-it templates at the end? [y/N] " choice - case $choice in - [yY]) - (sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" || tail -n +2) >> "$HOME/$CONFIG_FILE" - echo -e "\033[0;32mBash-it template has been added to your $CONFIG_FILE\033[0m" - ;; - [nN]|"") - test -w "$HOME/$CONFIG_FILE" && - cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" && - echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m" - sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" > "$HOME/$CONFIG_FILE" - ;; - *) - echo -e "\033[91mPlease choose y or n.\033[m" - ;; - esac +while true +do + read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash-it templates at the end? [y/N] " choice + case $choice in + [yY]) + (sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" || tail -n +2) >> "$HOME/$CONFIG_FILE" + echo -e "\033[0;32mBash-it template has been added to your $CONFIG_FILE\033[0m" + break + ;; + [nN]|"") + test -w "$HOME/$CONFIG_FILE" && + cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" && + echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m" + sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" > "$HOME/$CONFIG_FILE" + break + ;; + *) + echo -e "\033[91mPlease choose y or n.\033[m" + ;; + esac +done + echo -e "\033[0;32mCopied the template $CONFIG_FILE into ~/$CONFIG_FILE, edit this file to customize bash-it\033[0m" From 98eb5495fe7c89a6638f86f0d54a1eefe08d2b7d Mon Sep 17 00:00:00 2001 From: cs-networks Date: Thu, 7 Jan 2016 20:37:01 +0100 Subject: [PATCH 112/216] osx_terminal_exit_code_fix The update_terminal_cmd is interfering with the $? variable. Somehow it is always 0. ``` caesium@Mac:~/Documents/projects/git/bash-it 0 >export PROMPT_COMMAND="update_terminal_cwd;set_prompt" caesium@Mac:~/Documents/projects/git/bash-it 0 >false caesium@Mac:~/Documents/projects/git/bash-it 0 >true caesium@Mac:~/Documents/projects/git/bash-it 0 >export PROMPT_COMMAND="set_prompt;update_terminal_cwd" caesium@Mac:~/Documents/projects/git/bash-it 0 >false caesium@Mac:~/Documents/projects/git/bash-it 1 >true caesium@Mac:~/Documents/projects/git/bash-it 0 > ``` After the fix it is working properly. --- plugins/available/osx.plugin.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/available/osx.plugin.bash b/plugins/available/osx.plugin.bash index 9143ab2c..c1d2b18b 100644 --- a/plugins/available/osx.plugin.bash +++ b/plugins/available/osx.plugin.bash @@ -5,7 +5,7 @@ about-plugin 'osx-specific functions' if [ $(uname) = "Darwin" ]; then if type update_terminal_cwd > /dev/null 2>&1 ; then if ! [[ $PROMPT_COMMAND =~ (^|;)update_terminal_cwd($|;) ]] ; then - export PROMPT_COMMAND="update_terminal_cwd;$PROMPT_COMMAND" + export PROMPT_COMMAND="$PROMPT_COMMAND;update_terminal_cwd" fi fi fi From 245fcfa49b7aa1ff92e1216ecef231d743467eb6 Mon Sep 17 00:00:00 2001 From: Daniele Andreoli Date: Fri, 8 Jan 2016 02:20:18 +0100 Subject: [PATCH 113/216] Fix wrong pipe. Add in any case a backup file for compatibility --- install.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 678197df..0009139f 100755 --- a/install.sh +++ b/install.sh @@ -37,7 +37,11 @@ do read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash-it templates at the end? [y/N] " choice case $choice in [yY]) - (sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" || tail -n +2) >> "$HOME/$CONFIG_FILE" + test -w "$HOME/$CONFIG_FILE" && + cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" && + echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m" + + (sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" | tail -n +2) >> "$HOME/$CONFIG_FILE" echo -e "\033[0;32mBash-it template has been added to your $CONFIG_FILE\033[0m" break ;; From 696d0e50b09d223d51dd3b0e8f33acd73a95b7df Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Fri, 8 Jan 2016 08:25:53 +0100 Subject: [PATCH 114/216] Fixed indentation Removed tabs, using 2 spaces everywhere. --- install.sh | 79 +++++++++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/install.sh b/install.sh index d0a587c7..17250eb0 100755 --- a/install.sh +++ b/install.sh @@ -13,52 +13,51 @@ esac BACKUP_FILE=$CONFIG_FILE.bak if [ -e "$HOME/$BACKUP_FILE" ]; then - echo -e "\033[0;33mBackup file already exists. Make sure to backup your .bashrc before running this installation.\033[0m" >&2 - while true - do - read -e -n 1 -r -p "Would you like to overwrite the existing backup? This will delete your existing backup file ($HOME/$BACKUP_FILE) [y/N] " RESP - case $RESP in - [yY]) - break - ;; - [nN]|"") - echo -e "\033[91mInstallation aborted. Please come back soon!\033[m" - exit 1 - ;; - *) - echo -e "\033[91mPlease choose y or n.\033[m" - ;; - esac - done + echo -e "\033[0;33mBackup file already exists. Make sure to backup your .bashrc before running this installation.\033[0m" >&2 + while true + do + read -e -n 1 -r -p "Would you like to overwrite the existing backup? This will delete your existing backup file ($HOME/$BACKUP_FILE) [y/N] " RESP + case $RESP in + [yY]) + break + ;; + [nN]|"") + echo -e "\033[91mInstallation aborted. Please come back soon!\033[m" + exit 1 + ;; + *) + echo -e "\033[91mPlease choose y or n.\033[m" + ;; + esac + done fi while true do read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash-it templates at the end? [y/N] " choice - case $choice in - [yY]) - test -w "$HOME/$CONFIG_FILE" && - cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" && - echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m" + case $choice in + [yY]) + test -w "$HOME/$CONFIG_FILE" && + cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" && + echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m" - (sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" | tail -n +2) >> "$HOME/$CONFIG_FILE" - echo -e "\033[0;32mBash-it template has been added to your $CONFIG_FILE\033[0m" - break - ;; - [nN]|"") - test -w "$HOME/$CONFIG_FILE" && - cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" && - echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m" - sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" > "$HOME/$CONFIG_FILE" - break - ;; - *) - echo -e "\033[91mPlease choose y or n.\033[m" - ;; - esac + (sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" | tail -n +2) >> "$HOME/$CONFIG_FILE" + echo -e "\033[0;32mBash-it template has been added to your $CONFIG_FILE\033[0m" + break + ;; + [nN]|"") + test -w "$HOME/$CONFIG_FILE" && + cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" && + echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m" + sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" > "$HOME/$CONFIG_FILE" + break + ;; + *) + echo -e "\033[91mPlease choose y or n.\033[m" + ;; + esac done - echo -e "\033[0;32mCopied the template $CONFIG_FILE into ~/$CONFIG_FILE, edit this file to customize bash-it\033[0m" function load_one() { @@ -68,9 +67,9 @@ function load_one() { dest="${BASH_IT}/${file_type}/enabled/${file_to_enable}" if [ ! -e "${dest}" ]; then - ln -sf "../available/${file_to_enable}" "${dest}" + ln -sf "../available/${file_to_enable}" "${dest}" else - echo "File ${dest} exists, skipping" + echo "File ${dest} exists, skipping" fi } From 881a1535fcbbd64aa463dfa67b402f744fe4426e Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Fri, 8 Jan 2016 08:35:43 +0100 Subject: [PATCH 115/216] Added editorconfig file See http://editorconfig.org/ for more info... If you're using an editor that supports _editorconfig_, the editor's settings for indentation, line endings, etc. should automatically adjust when editing files. --- .editorconfig | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..4dc96bd5 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +# EditorConfig is awesome: http://EditorConfig.org + +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false From 544ba1ca57e314df681e2525d03f9f69426b032a Mon Sep 17 00:00:00 2001 From: James Cuzella Date: Fri, 8 Jan 2016 17:34:49 -0700 Subject: [PATCH 116/216] Adding alias for sane default options to "ag" ("the silver searcher" a fast grep / ack alternative) --- aliases/available/ag.aliases.bash | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 aliases/available/ag.aliases.bash diff --git a/aliases/available/ag.aliases.bash b/aliases/available/ag.aliases.bash new file mode 100644 index 00000000..e5318fc9 --- /dev/null +++ b/aliases/available/ag.aliases.bash @@ -0,0 +1,4 @@ +cite 'about-alias' +about-alias 'the silver searcher (ag) aliases' + +alias ag='ag --smart-case --pager="less -MIRFX"' From 219832bc5660bb41c692fc8a751dc52d582dcf37 Mon Sep 17 00:00:00 2001 From: James Cuzella Date: Fri, 8 Jan 2016 17:53:25 -0700 Subject: [PATCH 117/216] Adding docker command line client completion from https://github.com/docker/docker/blob/master/contrib/completion/bash/docker --- completion/available/docker.completion.bash | 2038 +++++++++++++++++++ 1 file changed, 2038 insertions(+) create mode 100644 completion/available/docker.completion.bash diff --git a/completion/available/docker.completion.bash b/completion/available/docker.completion.bash new file mode 100644 index 00000000..0e9d4b79 --- /dev/null +++ b/completion/available/docker.completion.bash @@ -0,0 +1,2038 @@ +#!/bin/bash +# +# bash completion file for core docker commands +# +# This script provides completion of: +# - commands and their options +# - container ids and names +# - image repos and tags +# - filepaths +# +# To enable the completions either: +# - place this file in /etc/bash_completion.d +# or +# - copy this file to e.g. ~/.docker-completion.sh and add the line +# below to your .bashrc after bash completion features are loaded +# . ~/.docker-completion.sh +# +# Configuration: +# +# For several commands, the amount of completions can be configured by +# setting environment variables. +# +# DOCKER_COMPLETION_SHOW_NETWORK_IDS +# "no" - Show names only (default) +# "yes" - Show names and ids +# +# You can tailor completion for the "events", "history", "inspect", "run", +# "rmi" and "save" commands by settings the following environment +# variables: +# +# DOCKER_COMPLETION_SHOW_IMAGE_IDS +# "none" - Show names only (default) +# "non-intermediate" - Show names and ids, but omit intermediate image IDs +# "all" - Show names and ids, including intermediate image IDs +# +# DOCKER_COMPLETION_SHOW_TAGS +# "yes" - include tags in completion options (default) +# "no" - don't include tags in completion options + +# +# Note: +# Currently, the completions will not work if the docker daemon is not +# bound to the default communication port/socket +# If the docker daemon is using a unix socket for communication your user +# must have access to the socket for the completions to function correctly +# +# Note for developers: +# Please arrange options sorted alphabetically by long name with the short +# options immediately following their corresponding long form. +# This order should be applied to lists, alternatives and code blocks. + +__docker_previous_extglob_setting=$(shopt -p extglob) +shopt -s extglob + +__docker_q() { + docker ${host:+-H "$host"} ${config:+--config "$config"} 2>/dev/null "$@" +} + +__docker_complete_containers_all() { + local IFS=$'\n' + local containers=( $(__docker_q ps -aq --no-trunc) ) + if [ "$1" ]; then + containers=( $(__docker_q inspect --format "{{if $1}}{{.Id}}{{end}}" "${containers[@]}") ) + fi + local names=( $(__docker_q inspect --format '{{.Name}}' "${containers[@]}") ) + names=( "${names[@]#/}" ) # trim off the leading "/" from the container names + unset IFS + COMPREPLY=( $(compgen -W "${names[*]} ${containers[*]}" -- "$cur") ) +} + +__docker_complete_containers_running() { + __docker_complete_containers_all '.State.Running' +} + +__docker_complete_containers_stopped() { + __docker_complete_containers_all 'not .State.Running' +} + +__docker_complete_containers_pauseable() { + __docker_complete_containers_all 'and .State.Running (not .State.Paused)' +} + +__docker_complete_containers_unpauseable() { + __docker_complete_containers_all '.State.Paused' +} + +__docker_complete_container_names() { + local containers=( $(__docker_q ps -aq --no-trunc) ) + local names=( $(__docker_q inspect --format '{{.Name}}' "${containers[@]}") ) + names=( "${names[@]#/}" ) # trim off the leading "/" from the container names + COMPREPLY=( $(compgen -W "${names[*]}" -- "$cur") ) +} + +__docker_complete_container_ids() { + local containers=( $(__docker_q ps -aq) ) + COMPREPLY=( $(compgen -W "${containers[*]}" -- "$cur") ) +} + +__docker_complete_images() { + local images_args="" + + case "$DOCKER_COMPLETION_SHOW_IMAGE_IDS" in + all) + images_args="--no-trunc -a" + ;; + non-intermediate) + images_args="--no-trunc" + ;; + esac + + local repo_print_command + if [ "${DOCKER_COMPLETION_SHOW_TAGS:-yes}" = "yes" ]; then + repo_print_command='print $1; print $1":"$2' + else + repo_print_command='print $1' + fi + + local awk_script + case "$DOCKER_COMPLETION_SHOW_IMAGE_IDS" in + all|non-intermediate) + awk_script='NR>1 { print $3; if ($1 != "") { '"$repo_print_command"' } }' + ;; + none|*) + awk_script='NR>1 && $1 != "" { '"$repo_print_command"' }' + ;; + esac + + local images=$(__docker_q images $images_args | awk "$awk_script") + COMPREPLY=( $(compgen -W "$images" -- "$cur") ) + __ltrim_colon_completions "$cur" +} + +__docker_complete_image_repos() { + local repos="$(__docker_q images | awk 'NR>1 && $1 != "" { print $1 }')" + COMPREPLY=( $(compgen -W "$repos" -- "$cur") ) +} + +__docker_complete_image_repos_and_tags() { + local reposAndTags="$(__docker_q images | awk 'NR>1 && $1 != "" { print $1; print $1":"$2 }')" + COMPREPLY=( $(compgen -W "$reposAndTags" -- "$cur") ) + __ltrim_colon_completions "$cur" +} + +__docker_complete_containers_and_images() { + __docker_complete_containers_all + local containers=( "${COMPREPLY[@]}" ) + __docker_complete_images + COMPREPLY+=( "${containers[@]}" ) +} + +__docker_networks() { + # By default, only network names are completed. + # Set DOCKER_COMPLETION_SHOW_NETWORK_IDS=yes to also complete network IDs. + local fields='$2' + [ "${DOCKER_COMPLETION_SHOW_NETWORK_IDS}" = yes ] && fields='$1,$2' + __docker_q network ls --no-trunc | awk "NR>1 {print $fields}" +} + +__docker_complete_networks() { + COMPREPLY=( $(compgen -W "$(__docker_networks)" -- "$cur") ) +} + +__docker_complete_network_ids() { + COMPREPLY=( $(compgen -W "$(__docker_q network ls -q --no-trunc)" -- "$cur") ) +} + +__docker_complete_network_names() { + COMPREPLY=( $(compgen -W "$(__docker_q network ls | awk 'NR>1 {print $2}')" -- "$cur") ) +} + +__docker_complete_containers_in_network() { + local containers=$(__docker_q network inspect -f '{{range $i, $c := .Containers}}{{$i}} {{$c.Name}} {{end}}' "$1") + COMPREPLY=( $(compgen -W "$containers" -- "$cur") ) +} + +__docker_complete_volumes() { + COMPREPLY=( $(compgen -W "$(__docker_q volume ls -q)" -- "$cur") ) +} + +__docker_plugins() { + __docker_q info | sed -n "/^Plugins/,/^[^ ]/s/ $1: //p" +} + +__docker_complete_plugins() { + COMPREPLY=( $(compgen -W "$(__docker_plugins $1)" -- "$cur") ) +} + +# Finds the position of the first word that is neither option nor an option's argument. +# If there are options that require arguments, you should pass a glob describing those +# options, e.g. "--option1|-o|--option2" +# Use this function to restrict completions to exact positions after the argument list. +__docker_pos_first_nonflag() { + local argument_flags=$1 + + local counter=$((${subcommand_pos:-${command_pos}} + 1)) + while [ $counter -le $cword ]; do + if [ -n "$argument_flags" ] && eval "case '${words[$counter]}' in $argument_flags) true ;; *) false ;; esac"; then + (( counter++ )) + # eat "=" in case of --option=arg syntax + [ "${words[$counter]}" = "=" ] && (( counter++ )) + else + case "${words[$counter]}" in + -*) + ;; + *) + break + ;; + esac + fi + + # Bash splits words at "=", retaining "=" as a word, examples: + # "--debug=false" => 3 words, "--log-opt syslog-facility=daemon" => 4 words + while [ "${words[$counter + 1]}" = "=" ] ; do + counter=$(( counter + 2)) + done + + (( counter++ )) + done + + echo $counter +} + +# Returns the value of the first option matching option_glob. +# Valid values for option_glob are option names like '--log-level' and +# globs like '--log-level|-l' +# Only positions between the command and the current word are considered. +__docker_value_of_option() { + local option_extglob=$(__docker_to_extglob "$1") + + local counter=$((command_pos + 1)) + while [ $counter -lt $cword ]; do + case ${words[$counter]} in + $option_extglob ) + echo ${words[$counter + 1]} + break + ;; + esac + (( counter++ )) + done +} + +# Transforms a multiline list of strings into a single line string +# with the words separated by "|". +# This is used to prepare arguments to __docker_pos_first_nonflag(). +__docker_to_alternatives() { + local parts=( $1 ) + local IFS='|' + echo "${parts[*]}" +} + +# Transforms a multiline list of options into an extglob pattern +# suitable for use in case statements. +__docker_to_extglob() { + local extglob=$( __docker_to_alternatives "$1" ) + echo "@($extglob)" +} + +# Subcommand processing. +# Locates the first occurrence of any of the subcommands contained in the +# first argument. In case of a match, calls the corresponding completion +# function and returns 0. +# If no match is found, 1 is returned. The calling function can then +# continue processing its completion. +# +# TODO if the preceding command has options that accept arguments and an +# argument is equal ot one of the subcommands, this is falsely detected as +# a match. +__docker_subcommands() { + local subcommands="$1" + + local counter=$(($command_pos + 1)) + while [ $counter -lt $cword ]; do + case "${words[$counter]}" in + $(__docker_to_extglob "$subcommands") ) + subcommand_pos=$counter + local subcommand=${words[$counter]} + local completions_func=_docker_${command}_${subcommand} + declare -F $completions_func >/dev/null && $completions_func + return 0 + ;; + esac + (( counter++ )) + done + return 1 +} + +# suppress trailing whitespace +__docker_nospace() { + # compopt is not available in ancient bash versions + type compopt &>/dev/null && compopt -o nospace +} + +__docker_complete_resolved_hostname() { + command -v host >/dev/null 2>&1 || return + COMPREPLY=( $(host 2>/dev/null "${cur%:}" | awk '/has address/ {print $4}') ) +} + +__docker_complete_capabilities() { + # The list of capabilities is defined in types.go, ALL was added manually. + COMPREPLY=( $( compgen -W " + ALL + AUDIT_CONTROL + AUDIT_WRITE + AUDIT_READ + BLOCK_SUSPEND + CHOWN + DAC_OVERRIDE + DAC_READ_SEARCH + FOWNER + FSETID + IPC_LOCK + IPC_OWNER + KILL + LEASE + LINUX_IMMUTABLE + MAC_ADMIN + MAC_OVERRIDE + MKNOD + NET_ADMIN + NET_BIND_SERVICE + NET_BROADCAST + NET_RAW + SETFCAP + SETGID + SETPCAP + SETUID + SYS_ADMIN + SYS_BOOT + SYS_CHROOT + SYSLOG + SYS_MODULE + SYS_NICE + SYS_PACCT + SYS_PTRACE + SYS_RAWIO + SYS_RESOURCE + SYS_TIME + SYS_TTY_CONFIG + WAKE_ALARM + " -- "$cur" ) ) +} + +__docker_complete_isolation() { + COMPREPLY=( $( compgen -W "default hyperv process" -- "$cur" ) ) +} + +__docker_complete_log_drivers() { + COMPREPLY=( $( compgen -W " + awslogs + fluentd + gelf + journald + json-file + none + splunk + syslog + " -- "$cur" ) ) +} + +__docker_complete_log_options() { + # see docs/reference/logging/index.md + local awslogs_options="awslogs-region awslogs-group awslogs-stream" + local fluentd_options="env fluentd-address labels tag" + local gelf_options="env gelf-address labels tag" + local journald_options="env labels" + local json_file_options="env labels max-file max-size" + local syslog_options="syslog-address syslog-facility tag" + local splunk_options="env labels splunk-caname splunk-capath splunk-index splunk-insecureskipverify splunk-source splunk-sourcetype splunk-token splunk-url tag" + + local all_options="$fluentd_options $gelf_options $journald_options $json_file_options $syslog_options $splunk_options" + + case $(__docker_value_of_option --log-driver) in + '') + COMPREPLY=( $( compgen -W "$all_options" -S = -- "$cur" ) ) + ;; + awslogs) + COMPREPLY=( $( compgen -W "$awslogs_options" -S = -- "$cur" ) ) + ;; + fluentd) + COMPREPLY=( $( compgen -W "$fluentd_options" -S = -- "$cur" ) ) + ;; + gelf) + COMPREPLY=( $( compgen -W "$gelf_options" -S = -- "$cur" ) ) + ;; + journald) + COMPREPLY=( $( compgen -W "$journald_options" -S = -- "$cur" ) ) + ;; + json-file) + COMPREPLY=( $( compgen -W "$json_file_options" -S = -- "$cur" ) ) + ;; + syslog) + COMPREPLY=( $( compgen -W "$syslog_options" -S = -- "$cur" ) ) + ;; + splunk) + COMPREPLY=( $( compgen -W "$splunk_options" -S = -- "$cur" ) ) + ;; + *) + return + ;; + esac + + __docker_nospace +} + +__docker_complete_log_driver_options() { + # "=" gets parsed to a word and assigned to either $cur or $prev depending on whether + # it is the last character or not. So we search for "xxx=" in the the last two words. + case "${words[$cword-2]}$prev=" in + *gelf-address=*) + COMPREPLY=( $( compgen -W "udp" -S "://" -- "${cur#=}" ) ) + __docker_nospace + return + ;; + *syslog-address=*) + COMPREPLY=( $( compgen -W "tcp udp unix" -S "://" -- "${cur#=}" ) ) + __docker_nospace + return + ;; + *syslog-facility=*) + COMPREPLY=( $( compgen -W " + auth + authpriv + cron + daemon + ftp + kern + local0 + local1 + local2 + local3 + local4 + local5 + local6 + local7 + lpr + mail + news + syslog + user + uucp + " -- "${cur#=}" ) ) + return + ;; + *splunk-url=*) + COMPREPLY=( $( compgen -W "http:// https://" -- "${cur#=}" ) ) + compopt -o nospace + __ltrim_colon_completions "${cur}" + return + ;; + *splunk-insecureskipverify=*) + COMPREPLY=( $( compgen -W "true false" -- "${cur#=}" ) ) + compopt -o nospace + return + ;; + esac + return 1 +} + +__docker_complete_log_levels() { + COMPREPLY=( $( compgen -W "debug info warn error fatal" -- "$cur" ) ) +} + +# a selection of the available signals that is most likely of interest in the +# context of docker containers. +__docker_complete_signals() { + local signals=( + SIGCONT + SIGHUP + SIGINT + SIGKILL + SIGQUIT + SIGSTOP + SIGTERM + SIGUSR1 + SIGUSR2 + ) + COMPREPLY=( $( compgen -W "${signals[*]} ${signals[*]#SIG}" -- "$( echo $cur | tr '[:lower:]' '[:upper:]')" ) ) +} + +# global options that may appear after the docker command +_docker_docker() { + local boolean_options=" + $global_boolean_options + --help + --version -v + " + + case "$prev" in + --config) + _filedir -d + return + ;; + --log-level|-l) + __docker_complete_log_levels + return + ;; + $(__docker_to_extglob "$global_options_with_args") ) + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "$boolean_options $global_options_with_args" -- "$cur" ) ) + ;; + *) + local counter=$( __docker_pos_first_nonflag $(__docker_to_extglob "$global_options_with_args") ) + if [ $cword -eq $counter ]; then + COMPREPLY=( $( compgen -W "${commands[*]} help" -- "$cur" ) ) + fi + ;; + esac +} + +_docker_attach() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help --no-stdin --sig-proxy" -- "$cur" ) ) + ;; + *) + local counter="$(__docker_pos_first_nonflag)" + if [ $cword -eq $counter ]; then + __docker_complete_containers_running + fi + ;; + esac +} + +_docker_build() { + local options_with_args=" + --build-arg + --cgroup-parent + --cpuset-cpus + --cpuset-mems + --cpu-shares + --cpu-period + --cpu-quota + --file -f + --isolation + --memory -m + --memory-swap + --tag -t + --ulimit + " + + local boolean_options=" + --disable-content-trust=false + --force-rm + --help + --no-cache + --pull + --quiet -q + --rm + " + + local all_options="$options_with_args $boolean_options" + + case "$prev" in + --build-arg) + COMPREPLY=( $( compgen -e -- "$cur" ) ) + __docker_nospace + return + ;; + --file|-f) + _filedir + return + ;; + --isolation) + __docker_complete_isolation + return + ;; + --tag|-t) + __docker_complete_image_repos_and_tags + return + ;; + $(__docker_to_extglob "$options_with_args") ) + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) ) + ;; + *) + local counter=$( __docker_pos_first_nonflag $( __docker_to_alternatives "$options_with_args" ) ) + if [ $cword -eq $counter ]; then + _filedir -d + fi + ;; + esac +} + +_docker_commit() { + case "$prev" in + --author|-a|--change|-c|--message|-m) + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--author -a --change -c --help --message -m --pause -p" -- "$cur" ) ) + ;; + *) + local counter=$(__docker_pos_first_nonflag '--author|-a|--change|-c|--message|-m') + + if [ $cword -eq $counter ]; then + __docker_complete_containers_all + return + fi + (( counter++ )) + + if [ $cword -eq $counter ]; then + __docker_complete_image_repos_and_tags + return + fi + ;; + esac +} + +_docker_cp() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) + ;; + *) + local counter=$(__docker_pos_first_nonflag) + if [ $cword -eq $counter ]; then + case "$cur" in + *:) + return + ;; + *) + # combined container and filename completion + _filedir + local files=( ${COMPREPLY[@]} ) + + __docker_complete_containers_all + COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -S ':' ) ) + local containers=( ${COMPREPLY[@]} ) + + COMPREPLY=( $( compgen -W "${files[*]} ${containers[*]}" -- "$cur" ) ) + if [[ "$COMPREPLY" == *: ]]; then + __docker_nospace + fi + return + ;; + esac + fi + (( counter++ )) + + if [ $cword -eq $counter ]; then + if [ -e "$prev" ]; then + __docker_complete_containers_all + COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -S ':' ) ) + __docker_nospace + else + _filedir + fi + return + fi + ;; + esac +} + +_docker_create() { + _docker_run +} + +_docker_daemon() { + local boolean_options=" + $global_boolean_options + --disable-legacy-registry + --help + --icc=false + --ip-forward=false + --ip-masq=false + --iptables=false + --ipv6 + --selinux-enabled + --userland-proxy=false + " + local options_with_args=" + $global_options_with_args + --api-cors-header + --authz-plugin + --bip + --bridge -b + --cgroup-parent + --cluster-advertise + --cluster-store + --cluster-store-opt + --default-gateway + --default-gateway-v6 + --default-ulimit + --dns + --dns-search + --dns-opt + --exec-opt + --exec-root + --fixed-cidr + --fixed-cidr-v6 + --graph -g + --group -G + --insecure-registry + --ip + --label + --log-driver + --log-opt + --mtu + --pidfile -p + --registry-mirror + --storage-driver -s + --storage-opt + " + + case "$prev" in + --authz-plugin) + __docker_complete_plugins Authorization + return + ;; + --cluster-store) + COMPREPLY=( $( compgen -W "consul etcd zk" -S "://" -- "$cur" ) ) + __docker_nospace + return + ;; + --cluster-store-opt) + COMPREPLY=( $( compgen -W "kv.cacertfile kv.certfile kv.keyfile" -S = -- "$cur" ) ) + __docker_nospace + return + ;; + --exec-root|--graph|-g) + _filedir -d + return + ;; + --log-driver) + __docker_complete_log_drivers + return + ;; + --pidfile|-p|--tlscacert|--tlscert|--tlskey) + _filedir + return + ;; + --storage-driver|-s) + COMPREPLY=( $( compgen -W "aufs btrfs devicemapper overlay vfs zfs" -- "$(echo $cur | tr '[:upper:]' '[:lower:]')" ) ) + return + ;; + --storage-opt) + local devicemapper_options=" + dm.basesize + dm.blkdiscard + dm.blocksize + dm.fs + dm.loopdatasize + dm.loopmetadatasize + dm.mkfsarg + dm.mountopt + dm.override_udev_sync_check + dm.thinpooldev + dm.use_deferred_deletion + dm.use_deferred_removal + " + local zfs_options="zfs.fsname" + + case $(__docker_value_of_option '--storage-driver|-s') in + '') + COMPREPLY=( $( compgen -W "$devicemapper_options $zfs_options" -S = -- "$cur" ) ) + ;; + devicemapper) + COMPREPLY=( $( compgen -W "$devicemapper_options" -S = -- "$cur" ) ) + ;; + zfs) + COMPREPLY=( $( compgen -W "$zfs_options" -S = -- "$cur" ) ) + ;; + *) + return + ;; + esac + __docker_nospace + return + ;; + --log-level|-l) + __docker_complete_log_levels + return + ;; + --log-opt) + __docker_complete_log_options + return + ;; + $(__docker_to_extglob "$options_with_args") ) + return + ;; + esac + + __docker_complete_log_driver_options && return + + case "${words[$cword-2]}$prev=" in + # completions for --storage-opt + *dm.@(blkdiscard|override_udev_sync_check|use_deferred_@(removal|deletion))=*) + COMPREPLY=( $( compgen -W "false true" -- "${cur#=}" ) ) + return + ;; + *dm.fs=*) + COMPREPLY=( $( compgen -W "ext4 xfs" -- "${cur#=}" ) ) + return + ;; + *dm.thinpooldev=*) + _filedir + return + ;; + # completions for --cluster-store-opt + *kv.*file=*) + _filedir + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) ) + ;; + esac +} + +_docker_diff() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) + ;; + *) + local counter=$(__docker_pos_first_nonflag) + if [ $cword -eq $counter ]; then + __docker_complete_containers_all + fi + ;; + esac +} + +_docker_events() { + case "$prev" in + --filter|-f) + COMPREPLY=( $( compgen -S = -W "container event image" -- "$cur" ) ) + __docker_nospace + return + ;; + --since|--until) + return + ;; + esac + + case "${words[$cword-2]}$prev=" in + *container=*) + cur="${cur#=}" + __docker_complete_containers_all + return + ;; + *event=*) + COMPREPLY=( $( compgen -W " + attach + commit + copy + create + delete + destroy + die + exec_create + exec_start + export + import + kill + oom + pause + pull + push + rename + resize + restart + start + stop + tag + top + unpause + untag + " -- "${cur#=}" ) ) + return + ;; + *image=*) + cur="${cur#=}" + __docker_complete_images + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--filter -f --help --since --until" -- "$cur" ) ) + ;; + esac +} + +_docker_exec() { + case "$prev" in + --user|-u) + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--detach -d --help --interactive -i --privileged -t --tty -u --user" -- "$cur" ) ) + ;; + *) + __docker_complete_containers_running + ;; + esac +} + +_docker_export() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) + ;; + *) + local counter=$(__docker_pos_first_nonflag) + if [ $cword -eq $counter ]; then + __docker_complete_containers_all + fi + ;; + esac +} + +_docker_help() { + local counter=$(__docker_pos_first_nonflag) + if [ $cword -eq $counter ]; then + COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) ) + fi +} + +_docker_history() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help --no-trunc --quiet -q" -- "$cur" ) ) + ;; + *) + local counter=$(__docker_pos_first_nonflag) + if [ $cword -eq $counter ]; then + __docker_complete_images + fi + ;; + esac +} + +_docker_images() { + case "$prev" in + --filter|-f) + COMPREPLY=( $( compgen -W "dangling=true label=" -- "$cur" ) ) + if [ "$COMPREPLY" = "label=" ]; then + __docker_nospace + fi + return + ;; + --format) + return + ;; + esac + + case "${words[$cword-2]}$prev=" in + *dangling=*) + COMPREPLY=( $( compgen -W "true false" -- "${cur#=}" ) ) + return + ;; + *label=*) + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--all -a --digests --filter -f --format --help --no-trunc --quiet -q" -- "$cur" ) ) + ;; + =) + return + ;; + *) + __docker_complete_image_repos + ;; + esac +} + +_docker_import() { + case "$prev" in + --change|-c|--message|-m) + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--change -c --help --message -m" -- "$cur" ) ) + ;; + *) + local counter=$(__docker_pos_first_nonflag '--change|-c|--message|-m') + if [ $cword -eq $counter ]; then + return + fi + (( counter++ )) + + if [ $cword -eq $counter ]; then + __docker_complete_image_repos_and_tags + return + fi + ;; + esac +} + +_docker_info() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) + ;; + esac +} + +_docker_inspect() { + case "$prev" in + --format|-f) + return + ;; + --type) + COMPREPLY=( $( compgen -W "image container" -- "$cur" ) ) + return + ;; + + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--format -f --help --size -s --type" -- "$cur" ) ) + ;; + *) + case $(__docker_value_of_option --type) in + '') + __docker_complete_containers_and_images + ;; + container) + __docker_complete_containers_all + ;; + image) + __docker_complete_images + ;; + esac + esac +} + +_docker_kill() { + case "$prev" in + --signal|-s) + __docker_complete_signals + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help --signal -s" -- "$cur" ) ) + ;; + *) + __docker_complete_containers_running + ;; + esac +} + +_docker_load() { + case "$prev" in + --input|-i) + _filedir + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help --input -i" -- "$cur" ) ) + ;; + esac +} + +_docker_login() { + case "$prev" in + --email|-e|--password|-p|--username|-u) + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--email -e --help --password -p --username -u" -- "$cur" ) ) + ;; + esac +} + +_docker_logout() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) + ;; + esac +} + +_docker_logs() { + case "$prev" in + --since|--tail) + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--follow -f --help --since --tail --timestamps -t" -- "$cur" ) ) + ;; + *) + local counter=$(__docker_pos_first_nonflag '--tail') + if [ $cword -eq $counter ]; then + __docker_complete_containers_all + fi + ;; + esac +} + +_docker_network_connect() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) + ;; + *) + local counter=$(__docker_pos_first_nonflag) + if [ $cword -eq $counter ]; then + __docker_complete_networks + elif [ $cword -eq $(($counter + 1)) ]; then + __docker_complete_containers_running + fi + ;; + esac +} + +_docker_network_create() { + case "$prev" in + --aux-address|--gateway|--ip-range|--opt|-o|--subnet) + return + ;; + --ipam-driver) + COMPREPLY=( $( compgen -W "default" -- "$cur" ) ) + return + ;; + --driver|-d) + local plugins=" $(__docker_plugins Network) " + # remove drivers that allow one instance only + plugins=${plugins/ host / } + plugins=${plugins/ null / } + COMPREPLY=( $(compgen -W "$plugins" -- "$cur") ) + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--aux-address --driver -d --gateway --help --ip-range --ipam-driver --opt -o --subnet" -- "$cur" ) ) + ;; + esac +} + +_docker_network_disconnect() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) + ;; + *) + local counter=$(__docker_pos_first_nonflag) + if [ $cword -eq $counter ]; then + __docker_complete_networks + elif [ $cword -eq $(($counter + 1)) ]; then + __docker_complete_containers_in_network "$prev" + fi + ;; + esac +} + +_docker_network_inspect() { + case "$prev" in + --format|-f) + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) ) + ;; + *) + __docker_complete_networks + esac +} + +_docker_network_ls() { + case "$prev" in + --filter|-f) + COMPREPLY=( $( compgen -S = -W "id name type" -- "$cur" ) ) + __docker_nospace + return + ;; + esac + + case "${words[$cword-2]}$prev=" in + *id=*) + cur="${cur#=}" + __docker_complete_network_ids + return + ;; + *name=*) + cur="${cur#=}" + __docker_complete_network_names + return + ;; + *type=*) + COMPREPLY=( $( compgen -W "builtin custom" -- "${cur#=}" ) ) + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--filter -f --help --no-trunc --quiet -q" -- "$cur" ) ) + ;; + esac +} + +_docker_network_rm() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) + ;; + *) + __docker_complete_networks + esac +} + +_docker_network() { + local subcommands=" + connect + create + disconnect + inspect + ls + rm + " + __docker_subcommands "$subcommands" && return + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) + ;; + *) + COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) + ;; + esac +} + +_docker_pause() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) + ;; + *) + local counter=$(__docker_pos_first_nonflag) + if [ $cword -eq $counter ]; then + __docker_complete_containers_pauseable + fi + ;; + esac +} + +_docker_port() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) + ;; + *) + local counter=$(__docker_pos_first_nonflag) + if [ $cword -eq $counter ]; then + __docker_complete_containers_all + fi + ;; + esac +} + +_docker_ps() { + case "$prev" in + --before|--since) + __docker_complete_containers_all + ;; + --filter|-f) + COMPREPLY=( $( compgen -S = -W "ancestor exited id label name status" -- "$cur" ) ) + __docker_nospace + return + ;; + --format|-n) + return + ;; + esac + + case "${words[$cword-2]}$prev=" in + *ancestor=*) + cur="${cur#=}" + __docker_complete_images + return + ;; + *id=*) + cur="${cur#=}" + __docker_complete_container_ids + return + ;; + *name=*) + cur="${cur#=}" + __docker_complete_container_names + return + ;; + *status=*) + COMPREPLY=( $( compgen -W "exited paused restarting running" -- "${cur#=}" ) ) + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--all -a --before --filter -f --format --help --latest -l -n --no-trunc --quiet -q --size -s --since" -- "$cur" ) ) + ;; + esac +} + +_docker_pull() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--all-tags -a --help" -- "$cur" ) ) + ;; + *) + local counter=$(__docker_pos_first_nonflag) + if [ $cword -eq $counter ]; then + for arg in "${COMP_WORDS[@]}"; do + case "$arg" in + --all-tags|-a) + __docker_complete_image_repos + return + ;; + esac + done + __docker_complete_image_repos_and_tags + fi + ;; + esac +} + +_docker_push() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) + ;; + *) + local counter=$(__docker_pos_first_nonflag) + if [ $cword -eq $counter ]; then + __docker_complete_image_repos_and_tags + fi + ;; + esac +} + +_docker_rename() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) + ;; + *) + local counter=$(__docker_pos_first_nonflag) + if [ $cword -eq $counter ]; then + __docker_complete_containers_all + fi + ;; + esac +} + +_docker_restart() { + case "$prev" in + --time|-t) + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help --time -t" -- "$cur" ) ) + ;; + *) + __docker_complete_containers_all + ;; + esac +} + +_docker_rm() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--force -f --help --link -l --volumes -v" -- "$cur" ) ) + ;; + *) + for arg in "${COMP_WORDS[@]}"; do + case "$arg" in + --force|-f) + __docker_complete_containers_all + return + ;; + esac + done + __docker_complete_containers_stopped + ;; + esac +} + +_docker_rmi() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--force -f --help --no-prune" -- "$cur" ) ) + ;; + *) + __docker_complete_images + ;; + esac +} + +_docker_run() { + local options_with_args=" + --add-host + --attach -a + --blkio-weight + --blkio-weight-device + --cap-add + --cap-drop + --cgroup-parent + --cidfile + --cpu-period + --cpu-quota + --cpuset-cpus + --cpuset-mems + --cpu-shares + --device + --device-read-bps + --device-read-iops + --device-write-bps + --device-write-iops + --dns + --dns-opt + --dns-search + --entrypoint + --env -e + --env-file + --expose + --group-add + --hostname -h + --ipc + --isolation + --kernel-memory + --label-file + --label -l + --link + --log-driver + --log-opt + --mac-address + --memory -m + --memory-swap + --memory-swappiness + --memory-reservation + --name + --net + --oom-score-adj + --pid + --publish -p + --restart + --security-opt + --stop-signal + --tmpfs + --ulimit + --user -u + --uts + --volume-driver + --volumes-from + --volume -v + --workdir -w + " + + local boolean_options=" + --disable-content-trust=false + --help + --interactive -i + --oom-kill-disable + --privileged + --publish-all -P + --read-only + --tty -t + " + + local all_options="$options_with_args $boolean_options" + + [ "$command" = "run" ] && all_options="$all_options + --detach -d + --rm + --sig-proxy=false + " + + case "$prev" in + --add-host) + case "$cur" in + *:) + __docker_complete_resolved_hostname + return + ;; + esac + ;; + --attach|-a) + COMPREPLY=( $( compgen -W 'stdin stdout stderr' -- "$cur" ) ) + return + ;; + --cap-add|--cap-drop) + __docker_complete_capabilities + return + ;; + --cidfile|--env-file|--label-file) + _filedir + return + ;; + --device|--tmpfs|--volume|-v) + case "$cur" in + *:*) + # TODO somehow do _filedir for stuff inside the image, if it's already specified (which is also somewhat difficult to determine) + ;; + '') + COMPREPLY=( $( compgen -W '/' -- "$cur" ) ) + __docker_nospace + ;; + /*) + _filedir + __docker_nospace + ;; + esac + return + ;; + --env|-e) + COMPREPLY=( $( compgen -e -- "$cur" ) ) + __docker_nospace + return + ;; + --ipc) + case "$cur" in + *:*) + cur="${cur#*:}" + __docker_complete_containers_running + ;; + *) + COMPREPLY=( $( compgen -W 'host container:' -- "$cur" ) ) + if [ "$COMPREPLY" = "container:" ]; then + __docker_nospace + fi + ;; + esac + return + ;; + --isolation) + __docker_complete_isolation + return + ;; + --link) + case "$cur" in + *:*) + ;; + *) + __docker_complete_containers_running + COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -S ':' ) ) + __docker_nospace + ;; + esac + return + ;; + --log-driver) + __docker_complete_log_drivers + return + ;; + --log-opt) + __docker_complete_log_options + return + ;; + --net) + case "$cur" in + container:*) + local cur=${cur#*:} + __docker_complete_containers_all + ;; + *) + COMPREPLY=( $( compgen -W "$(__docker_plugins Network) $(__docker_networks) container:" -- "$cur") ) + if [ "${COMPREPLY[*]}" = "container:" ] ; then + __docker_nospace + fi + ;; + esac + return + ;; + --restart) + case "$cur" in + on-failure:*) + ;; + *) + COMPREPLY=( $( compgen -W "always no on-failure on-failure: unless-stopped" -- "$cur") ) + ;; + esac + return + ;; + --security-opt) + case "$cur" in + label:*:*) + ;; + label:*) + local cur=${cur##*:} + COMPREPLY=( $( compgen -W "user: role: type: level: disable" -- "$cur") ) + if [ "${COMPREPLY[*]}" != "disable" ] ; then + __docker_nospace + fi + ;; + *) + COMPREPLY=( $( compgen -W "label apparmor seccomp" -S ":" -- "$cur") ) + __docker_nospace + ;; + esac + return + ;; + --volume-driver) + __docker_complete_plugins Volume + return + ;; + --volumes-from) + __docker_complete_containers_all + return + ;; + $(__docker_to_extglob "$options_with_args") ) + return + ;; + esac + + __docker_complete_log_driver_options && return + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) ) + ;; + *) + local counter=$( __docker_pos_first_nonflag $( __docker_to_alternatives "$options_with_args" ) ) + if [ $cword -eq $counter ]; then + __docker_complete_images + fi + ;; + esac +} + +_docker_save() { + case "$prev" in + --output|-o) + _filedir + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help --output -o" -- "$cur" ) ) + ;; + *) + __docker_complete_images + ;; + esac +} + +_docker_search() { + case "$prev" in + --stars|-s) + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--automated --help --no-trunc --stars -s" -- "$cur" ) ) + ;; + esac +} + +_docker_start() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--attach -a --help --interactive -i" -- "$cur" ) ) + ;; + *) + __docker_complete_containers_stopped + ;; + esac +} + +_docker_stats() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--all -a --help --no-stream" -- "$cur" ) ) + ;; + *) + __docker_complete_containers_running + ;; + esac +} + +_docker_stop() { + case "$prev" in + --time|-t) + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help --time -t" -- "$cur" ) ) + ;; + *) + __docker_complete_containers_running + ;; + esac +} + +_docker_tag() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) ) + ;; + *) + local counter=$(__docker_pos_first_nonflag) + + if [ $cword -eq $counter ]; then + __docker_complete_image_repos_and_tags + return + fi + (( counter++ )) + + if [ $cword -eq $counter ]; then + __docker_complete_image_repos_and_tags + return + fi + ;; + esac +} + +_docker_unpause() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) + ;; + *) + local counter=$(__docker_pos_first_nonflag) + if [ $cword -eq $counter ]; then + __docker_complete_containers_unpauseable + fi + ;; + esac +} + +_docker_update() { + local options_with_args=" + --blkio-weight + --cpu-period + --cpu-quota + --cpuset-cpus + --cpuset-mems + --cpu-shares + --kernel-memory + --memory -m + --memory-reservation + --memory-swap + " + + local boolean_options=" + --help + " + + local all_options="$options_with_args $boolean_options" + + case "$prev" in + $(__docker_to_extglob "$options_with_args") ) + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) ) + ;; + *) + __docker_complete_containers_all + ;; + esac +} + +_docker_top() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) + ;; + *) + local counter=$(__docker_pos_first_nonflag) + if [ $cword -eq $counter ]; then + __docker_complete_containers_running + fi + ;; + esac +} + +_docker_version() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) + ;; + esac +} + +_docker_volume_create() { + case "$prev" in + --driver|-d) + __docker_complete_plugins Volume + return + ;; + --name|--opt|-o) + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--driver -d --help --name --opt -o" -- "$cur" ) ) + ;; + esac +} + +_docker_volume_inspect() { + case "$prev" in + --format|-f) + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) ) + ;; + *) + __docker_complete_volumes + ;; + esac +} + +_docker_volume_ls() { + case "$prev" in + --filter|-f) + COMPREPLY=( $( compgen -W "dangling=true" -- "$cur" ) ) + return + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--filter -f --help --quiet -q" -- "$cur" ) ) + ;; + esac +} + +_docker_volume_rm() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) + ;; + *) + __docker_complete_volumes + ;; + esac +} + +_docker_volume() { + local subcommands=" + create + inspect + ls + rm + " + __docker_subcommands "$subcommands" && return + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) + ;; + *) + COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) + ;; + esac +} + +_docker_wait() { + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) + ;; + *) + __docker_complete_containers_all + ;; + esac +} + +_docker() { + local previous_extglob_setting=$(shopt -p extglob) + shopt -s extglob + + local commands=( + attach + build + commit + cp + create + daemon + diff + events + exec + export + history + images + import + info + inspect + kill + load + login + logout + logs + network + pause + port + ps + pull + push + rename + restart + rm + rmi + run + save + search + start + stats + stop + tag + top + unpause + update + version + volume + wait + ) + + # These options are valid as global options for all client commands + # and valid as command options for `docker daemon` + local global_boolean_options=" + --debug -D + --tls + --tlsverify + " + local global_options_with_args=" + --config + --host -H + --log-level -l + --tlscacert + --tlscert + --tlskey + " + + local host config + + COMPREPLY=() + local cur prev words cword + _get_comp_words_by_ref -n : cur prev words cword + + local command='docker' command_pos=0 subcommand_pos + local counter=1 + while [ $counter -lt $cword ]; do + case "${words[$counter]}" in + # save host so that completion can use custom daemon + --host|-H) + (( counter++ )) + host="${words[$counter]}" + ;; + # save config so that completion can use custom configuration directories + --config) + (( counter++ )) + config="${words[$counter]}" + ;; + $(__docker_to_extglob "$global_options_with_args") ) + (( counter++ )) + ;; + -*) + ;; + =) + (( counter++ )) + ;; + *) + command="${words[$counter]}" + command_pos=$counter + break + ;; + esac + (( counter++ )) + done + + local completions_func=_docker_${command} + declare -F $completions_func >/dev/null && $completions_func + + eval "$previous_extglob_setting" + return 0 +} + +eval "$__docker_previous_extglob_setting" +unset __docker_previous_extglob_setting + +complete -F _docker docker From a742959058018cf142f4e5a44b8850c20f0b842b Mon Sep 17 00:00:00 2001 From: James Cuzella Date: Mon, 11 Jan 2016 12:09:00 -0700 Subject: [PATCH 118/216] Adding comments to summarize less arguments --- aliases/available/ag.aliases.bash | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/aliases/available/ag.aliases.bash b/aliases/available/ag.aliases.bash index e5318fc9..e3157f94 100644 --- a/aliases/available/ag.aliases.bash +++ b/aliases/available/ag.aliases.bash @@ -1,4 +1,12 @@ cite 'about-alias' about-alias 'the silver searcher (ag) aliases' +## Summary for args to less: +# less(1) +# -M (-M or --LONG-PROMPT) Prompt very verbosely +# -I (-I or --IGNORE-CASE) Searches with '/' ignore case +# -R (-R or --RAW-CONTROL-CHARS) For handling ANSI colors +# -F (-F or --quit-if-one-screen) Auto exit if <1 screen +# -X (-X or --no-init) Disable termcap init & deinit + alias ag='ag --smart-case --pager="less -MIRFX"' From 17d69dbc1a2a334f19c24e1584a3bd9ecd062ced Mon Sep 17 00:00:00 2001 From: Tyler Freeman Date: Wed, 13 Jan 2016 18:31:10 -0800 Subject: [PATCH 119/216] Added Primer (minimal time) theme, based off of the candy theme. --- themes/primer/primer.theme.bash | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 themes/primer/primer.theme.bash diff --git a/themes/primer/primer.theme.bash b/themes/primer/primer.theme.bash new file mode 100644 index 00000000..0b01088e --- /dev/null +++ b/themes/primer/primer.theme.bash @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# based of the candy theme, but minimized by odbol +function prompt_command() { + PS1="${blue}\T ${reset_color}${white}\w${reset_color}$(scm_prompt_info)${blue} →${bold_blue} ${reset_color} "; +} + +PROMPT_COMMAND=prompt_command; \ No newline at end of file From b422d756b053a3aafdf01c1e6706aff18eb23139 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Thu, 14 Jan 2016 08:21:10 +0100 Subject: [PATCH 120/216] Added reference to EditorConfig --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ca8688b2..b9bd7d91 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,7 +18,7 @@ When contributing a new feature, a bug fix, a new theme, or any other change to ## Code Style * Try to stick to the existing code style. Please don't reformat or change the syntax of existing code simply because you don't like that style. -* Indentation is using spaces, not tabs. Most of the code is indented with 2 spaces, some with 4 spaces. Please try to stick to 2 spaces. +* Indentation is using spaces, not tabs. Most of the code is indented with 2 spaces, some with 4 spaces. Please try to stick to 2 spaces. If you're using an editor that supports [EditorConfig](http://EditorConfig.org), the editor should automatically use the settings defined in Bash-it's [.editorconfig file](.editorconfig). * When creating new functions, please use a dash ("-") to separate the words of the function's name, e.g. `my-new-function`. Don't use underscores, e.g. `my_new_function`. * Internal functions that aren't to be used by the end user should start with an underscore, e.g. `_my-new-internal-function`. * Use the provided meta functions to document your code, e.g. `about-plugin`, `about`, `group`, `param`, `example`. This will make it easier for other people to use your new functionality. Take a look at the existing code for an example (e.g. [the base plugin](plugins/available/base.plugin.bash)). From 3fa088128157d99aebad87674196c46397817924 Mon Sep 17 00:00:00 2001 From: Christophe Aguettaz Date: Mon, 25 Jan 2016 20:02:50 +0100 Subject: [PATCH 121/216] [bugfix] Fixed performance issue with git prompt The git prompt would could bash to use 100% CPU for large amounts of time when dealing with long `git status` outputs. --- themes/base.theme.bash | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index c491e5e5..962df15a 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -92,19 +92,48 @@ function scm_prompt_info { [[ $SCM == $SCM_SVN ]] && svn_prompt_info && return } +function git_status_summary { + awk ' + { + if (!after_first && $0 ~ /^##.+/) { + print $0 + seen_header = 1 + } else if ($0 ~ /^\?\? .+/) { + untracked += 1 + } else { + if ($0 ~ /^.[^ ] .+/) { + unstaged += 1 + } + if ($0 ~ /^[^ ]. .+/) { + staged += 1 + } + } + after_first = 1 + } + END { + if (!seen_header) { + print + } + print untracked + print unstaged + print staged + }' +} + function git_prompt_vars { local details='' SCM_STATE=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} if [[ "$(git config --get bash-it.hide-status)" != "1" ]]; then [[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && local git_status_flags='-uno' - local status="$(git status -b --porcelain ${git_status_flags} 2> /dev/null || - git status --porcelain ${git_status_flags} 2> /dev/null)" - if [[ -n "${status}" ]] && [[ "${status}" != "\n" ]] && [[ -n "$(grep -v ^# <<< "${status}")" ]]; then + readarray -t status_lines < <((git status --porcelain ${git_status_flags} -b 2> /dev/null || + git status --porcelain ${git_status_flags} 2> /dev/null) | git_status_summary ) + local status="${status_lines[0]}" + local untracked_count="${status_lines[1]}" + local unstaged_count="${status_lines[2]}" + local staged_count="${status_lines[3]}" + if [[ "${untracked_count}" -gt 0 || "${unstaged_count}" -gt 0 || "${staged_count}" -gt 0 ]]; then SCM_DIRTY=1 if [[ "${SCM_GIT_SHOW_DETAILS}" = "true" ]]; then - local untracked_count="$(egrep -c '^\?\? .+' <<< "${status}")" - local unstaged_count="$(egrep -c '^.[^ ?#] .+' <<< "${status}")" - local staged_count="$(egrep -c '^[^ ?#]. .+' <<< "${status}")" [[ "${staged_count}" -gt 0 ]] && details+=" ${SCM_GIT_STAGED_CHAR}${staged_count}" && SCM_DIRTY=3 [[ "${unstaged_count}" -gt 0 ]] && details+=" ${SCM_GIT_UNSTAGED_CHAR}${unstaged_count}" && SCM_DIRTY=2 [[ "${untracked_count}" -gt 0 ]] && details+=" ${SCM_GIT_UNTRACKED_CHAR}${untracked_count}" && SCM_DIRTY=1 From eb92e2f84517bd872bef51c5094e8f7a80f94613 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Sat, 31 Oct 2015 23:53:52 +0100 Subject: [PATCH 122/216] Add support to change the order of the prompt info in the Powerline Multiline theme --- .../powerline-multiline.theme.bash | 75 +++++++++++-------- 1 file changed, 44 insertions(+), 31 deletions(-) diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index 7b690683..7ec80335 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -72,7 +72,7 @@ function powerline_shell_prompt { else SHELL_PROMPT="${USER}" fi - RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#SHELL_PROMPT} + 2 )) + RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#SHELL_PROMPT} + 3 )) SHELL_PROMPT="$(set_rgb_color - ${SHELL_PROMPT_COLOR}) ${SHELL_PROMPT} ${normal}" LAST_THEME_COLOR=${SHELL_PROMPT_COLOR} (( SEGMENT_AT_RIGHT += 1 )) @@ -80,7 +80,7 @@ function powerline_shell_prompt { "sudo") if [[ "${SHELL_PROMPT_COLOR}" == "${SHELL_THEME_PROMPT_COLOR_SUDO}" ]]; then SHELL_PROMPT="!" - RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#SHELL_PROMPT} + 2 )) + RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#SHELL_PROMPT} + 3 )) SHELL_PROMPT="$(set_rgb_color - ${SHELL_PROMPT_COLOR}) ${SHELL_PROMPT} ${normal}" LAST_THEME_COLOR=${SHELL_PROMPT_COLOR} (( SEGMENT_AT_RIGHT += 1 )) @@ -90,46 +90,46 @@ function powerline_shell_prompt { } function powerline_rvm_prompt { - local environ="" + local RVM_PROMPT="" if command_exists rvm; then - rvm_prompt=$(rvm_version_prompt) - if [[ "${rvm_prompt}" != $(rvm strings default) ]]; then - RVM_PROMPT="$(set_rgb_color - ${RVM_THEME_PROMPT_COLOR}) ${RVM_CHAR}${rvm_prompt} ${normal}" + RVM_PROMPT=$(rvm_version_prompt) + if [[ "${RVM_PROMPT}" != $(rvm strings default) ]]; then + RVM_PROMPT="$(set_rgb_color - ${RVM_THEME_PROMPT_COLOR}) ${RVM_CHAR}${RVM_PROMPT} ${normal}" if [[ "${SEGMENT_AT_LEFT}" -gt 0 ]]; then RVM_PROMPT=$(set_rgb_color ${LAST_THEME_COLOR} ${RVM_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}${RVM_PROMPT} fi LAST_THEME_COLOR=${RVM_THEME_PROMPT_COLOR} + LEFT_PROMPT+="${RVM_PROMPT}" (( SEGMENT_AT_LEFT += 1 )) - else - RVM_PROMPT="" fi fi } function powerline_virtualenv_prompt { - local environ="" + local VIRTUALENV_PROMPT="" if [[ -n "$CONDA_DEFAULT_ENV" ]]; then - environ="$CONDA_DEFAULT_ENV" + VIRTUALENV_PROMPT="$CONDA_DEFAULT_ENV" VIRTUALENV_CHAR=${CONDA_VIRTUALENV_CHAR} elif [[ -n "$VIRTUAL_ENV" ]]; then - environ=$(basename "$VIRTUAL_ENV") + VIRTUALENV_PROMPT=$(basename "$VIRTUAL_ENV") fi - if [[ -n "$environ" ]]; then - VIRTUALENV_PROMPT="$(set_rgb_color - ${VIRTUALENV_THEME_PROMPT_COLOR}) ${VIRTUALENV_CHAR}$environ ${normal}" + if [[ -n "$VIRTUALENV_PROMPT" ]]; then + VIRTUALENV_PROMPT="$(set_rgb_color - ${VIRTUALENV_THEME_PROMPT_COLOR}) ${VIRTUALENV_CHAR}${VIRTUALENV_PROMPT} ${normal}" if [[ "${SEGMENT_AT_LEFT}" -gt 0 ]]; then VIRTUALENV_PROMPT=$(set_rgb_color ${LAST_THEME_COLOR} ${VIRTUALENV_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}${VIRTUALENV_PROMPT} fi LAST_THEME_COLOR=${VIRTUALENV_THEME_PROMPT_COLOR} + LEFT_PROMPT+="${VIRTUALENV_PROMPT}" (( SEGMENT_AT_LEFT += 1 )) - else - VIRTUALENV_PROMPT="" fi } function powerline_scm_prompt { + local SCM_PROMPT="" + scm_prompt_vars if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]]; then if [[ "${SCM_DIRTY}" -eq 3 ]]; then @@ -142,23 +142,28 @@ function powerline_scm_prompt { SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR} fi if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then - SCM_PROMPT=" ${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" + SCM_PROMPT+=" ${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" fi SCM_PROMPT="$(set_rgb_color - ${SCM_THEME_PROMPT_COLOR})${SCM_PROMPT} ${normal}" + if [[ "${SEGMENT_AT_LEFT}" -gt 0 ]]; then + SCM_PROMPT=$(set_rgb_color ${LAST_THEME_COLOR} ${SCM_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}${SCM_PROMPT} + fi + LEFT_PROMPT+="${SCM_PROMPT}" LAST_THEME_COLOR=${SCM_THEME_PROMPT_COLOR} (( SEGMENT_AT_LEFT += 1 )) - else - SCM_PROMPT="" fi } function powerline_cwd_prompt { - CWD_PROMPT="$(set_rgb_color - ${CWD_THEME_PROMPT_COLOR}) \w ${normal}$(set_rgb_color ${CWD_THEME_PROMPT_COLOR} -)${normal}$(set_rgb_color ${CWD_THEME_PROMPT_COLOR} -)${THEME_PROMPT_SEPARATOR}${normal}" + local CWD_PROMPT="" + #CWD_PROMPT="$(set_rgb_color - ${CWD_THEME_PROMPT_COLOR}) \w ${normal}$(set_rgb_color ${CWD_THEME_PROMPT_COLOR} -)${normal}$(set_rgb_color ${CWD_THEME_PROMPT_COLOR} -)${THEME_PROMPT_SEPARATOR}${normal}" + CWD_PROMPT="$(set_rgb_color - ${CWD_THEME_PROMPT_COLOR}) \w ${normal}$(set_rgb_color ${CWD_THEME_PROMPT_COLOR} -)${normal}" if [[ "${SEGMENT_AT_LEFT}" -gt 0 ]]; then CWD_PROMPT=$(set_rgb_color ${LAST_THEME_COLOR} ${CWD_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}${CWD_PROMPT} - SEGMENT_AT_LEFT=0 fi LAST_THEME_COLOR=${CWD_THEME_PROMPT_COLOR} + LEFT_PROMPT+="${CWD_PROMPT}" + (( SEGMENT_AT_LEFT += 1 )) } function powerline_last_status_prompt { @@ -204,7 +209,7 @@ function powerline_battery_status_prompt { BATTERY_PROMPT+=$(set_rgb_color ${LAST_THEME_COLOR} ${BATTERY_STATUS_THEME_PROMPT_COLOR})${THEME_PROMPT_LEFT_SEPARATOR}${normal} (( RIGHT_PROMPT_LENGTH += SEGMENT_AT_RIGHT )) else - BATTERY_STATUS+=" " + BATTERY_STATUS+=" " fi RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#BATTERY_STATUS} + 2 )) LAST_THEME_COLOR=${BATTERY_STATUS_THEME_PROMPT_COLOR} @@ -231,22 +236,28 @@ function powerline_in_vim_prompt { function powerline_prompt_command() { local LAST_STATUS="$?" local MOVE_CURSOR_RIGHTMOST='\033[500C' + + LEFT_PROMPT="" + RIGHT_PROMPT="" SEGMENT_AT_LEFT=0 SEGMENT_AT_RIGHT=0 - RIGHT_PROMPT_LENGTH=1 - RIGHT_PROMPT="" + RIGHT_PROMPT_LENGTH=0 + LAST_THEME_COLOR="" ## left prompt ## - powerline_scm_prompt - powerline_virtualenv_prompt - powerline_rvm_prompt - powerline_cwd_prompt - powerline_last_status_prompt LAST_STATUS - - LEFT_PROMPT="${SCM_PROMPT}${VIRTUALENV_PROMPT}${RVM_PROMPT}${CWD_PROMPT}${MOVE_CURSOR_RIGHTMOST}" + if [[ -z "${THEME_RIGHT_SEGMENTS}" ]]; then + powerline_scm_prompt + powerline_virtualenv_prompt + powerline_rvm_prompt + powerline_cwd_prompt + else + for f in $THEME_RIGHT_SEGMENTS; do + $f + done + fi + [[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="$(set_rgb_color ${LAST_THEME_COLOR} -)${THEME_PROMPT_SEPARATOR}${normal}" ## right prompt ## - LAST_THEME_COLOR="-" powerline_shell_prompt powerline_battery_status_prompt powerline_clock_prompt @@ -259,6 +270,8 @@ function powerline_prompt_command() { RIGHT_PROMPT+="${IN_VIM_PROMPT}${CLOCK_PROMPT}${BATTERY_PROMPT}${SHELL_PROMPT}${normal}" fi + powerline_last_status_prompt LAST_STATUS + PS1="${LEFT_PROMPT}${RIGHT_PROMPT}\n${LAST_STATUS_PROMPT}${PROMPT_CHAR} " } From 51f5614de58e30eb8e5ad5d792b817f51d0f8b60 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Sat, 23 Jan 2016 21:02:07 +0100 Subject: [PATCH 123/216] Add support to change the segment order of the left and right prompt --- .../powerline-multiline.theme.bash | 155 +++++++++--------- 1 file changed, 81 insertions(+), 74 deletions(-) diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index 7ec80335..28887ea4 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -3,9 +3,9 @@ THEME_PROMPT_SEPARATOR="" THEME_PROMPT_LEFT_SEPARATOR="" -SHELL_SSH_CHAR=${SHELL_SSH_CHAR:=" "} -SHELL_THEME_PROMPT_COLOR=32 -SHELL_THEME_PROMPT_COLOR_SUDO=202 +USER_INFO_SSH_CHAR=${USER_INFO_SSH_CHAR:=" "} +USER_INFO_THEME_PROMPT_COLOR=32 +USER_INFO_THEME_PROMPT_COLOR_SUDO=202 VIRTUALENV_CHAR=${POWERLINE_VIRTUALENV_CHAR:="❲p❳ "} CONDA_VIRTUALENV_CHAR=${POWERLINE_CONDA_VIRTUALENV_CHAR:="❲c❳ "} @@ -42,11 +42,12 @@ BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=160 THEME_PROMPT_CLOCK_FORMAT=${THEME_PROMPT_CLOCK_FORMAT:="%H:%M:%S"} -THEME_PROMPT_USERINFO_MODE=${THEME_PROMPT_USERINFO_MODE:="default"} - IN_VIM_PROMPT_COLOR=35 IN_VIM_PROMPT_TEXT="vim" +THEME_LEFT_SEGMENTS="scm virtualenv rvm cwd" +THEME_RIGHT_SEGMENTS="in_vim clock battery user_info" + function set_rgb_color { if [[ "${1}" != "-" ]]; then @@ -59,34 +60,41 @@ function set_rgb_color { echo -e "\[\033[${fg}${bg}m\]" } -function powerline_shell_prompt { - SHELL_PROMPT="" - SHELL_PROMPT_COLOR=${SHELL_THEME_PROMPT_COLOR} +function powerline_user_info_prompt { + local offset=2 + local USER_INFO="" + local USER_INFO_PROMPT="" + USER_INFO_PROMPT_COLOR=${USER_INFO_THEME_PROMPT_COLOR} if sudo -n uptime 2>&1 | grep -q "load"; then - SHELL_PROMPT_COLOR=${SHELL_THEME_PROMPT_COLOR_SUDO} + USER_INFO_PROMPT_COLOR=${USER_INFO_THEME_PROMPT_COLOR_SUDO} fi - case "${THEME_PROMPT_USERINFO_MODE}" in - "default") - if [[ -n "${SSH_CLIENT}" ]]; then - SHELL_PROMPT="${SHELL_SSH_CHAR}${USER}@${HOSTNAME}" - else - SHELL_PROMPT="${USER}" - fi - RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#SHELL_PROMPT} + 3 )) - SHELL_PROMPT="$(set_rgb_color - ${SHELL_PROMPT_COLOR}) ${SHELL_PROMPT} ${normal}" - LAST_THEME_COLOR=${SHELL_PROMPT_COLOR} - (( SEGMENT_AT_RIGHT += 1 )) - ;; + case "${THEME_PROMPT_USER_INFO_MODE}" in "sudo") - if [[ "${SHELL_PROMPT_COLOR}" == "${SHELL_THEME_PROMPT_COLOR_SUDO}" ]]; then - SHELL_PROMPT="!" - RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#SHELL_PROMPT} + 3 )) - SHELL_PROMPT="$(set_rgb_color - ${SHELL_PROMPT_COLOR}) ${SHELL_PROMPT} ${normal}" - LAST_THEME_COLOR=${SHELL_PROMPT_COLOR} - (( SEGMENT_AT_RIGHT += 1 )) + if [[ "${USER_INFO_PROMPT_COLOR}" == "${USER_INFO_THEME_PROMPT_COLOR_SUDO}" ]]; then + USER_INFO="!" + fi + ;; + *) + if [[ -n "${SSH_CLIENT}" ]]; then + USER_INFO="${USER_INFO_SSH_CHAR}${USER}@${HOSTNAME}" + else + USER_INFO="${USER}" fi ;; esac + if [[ -n "${USER_INFO}" ]]; then + if [[ "${SEGMENT_AT_RIGHT}" -eq 0 ]]; then + USER_INFO_PROMPT="$(set_rgb_color ${USER_INFO_PROMPT_COLOR} -)${THEME_PROMPT_LEFT_SEPARATOR}${normal}" + else + USER_INFO_PROMPT="$(set_rgb_color ${USER_INFO_PROMPT_COLOR} ${LAST_THEME_COLOR})${THEME_PROMPT_LEFT_SEPARATOR}${normal}" + (( offset += 1 )) + fi + USER_INFO_PROMPT+="$(set_rgb_color - ${USER_INFO_PROMPT_COLOR}) ${USER_INFO} ${normal}" + RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#USER_INFO} + ${offset} )) + LAST_THEME_COLOR=${USER_INFO_PROMPT_COLOR} + RIGHT_PROMPT+="${USER_INFO_PROMPT}" + (( SEGMENT_AT_RIGHT += 1 )) + fi } function powerline_rvm_prompt { @@ -175,59 +183,69 @@ function powerline_last_status_prompt { } function powerline_clock_prompt { - if [[ -z "${THEME_PROMPT_CLOCK_FORMAT}" ]]; then - CLOCK_PROMPT="" - else - local CLOCK=" $(date +"${THEME_PROMPT_CLOCK_FORMAT}") " - - CLOCK_PROMPT=$(set_rgb_color - ${CLOCK_THEME_PROMPT_COLOR})${CLOCK}${normal} - if [[ "${SEGMENT_AT_RIGHT}" -gt 0 ]]; then - CLOCK_PROMPT+=$(set_rgb_color ${LAST_THEME_COLOR} ${CLOCK_THEME_PROMPT_COLOR})${THEME_PROMPT_LEFT_SEPARATOR}${normal} - (( RIGHT_PROMPT_LENGTH += SEGMENT_AT_RIGHT - 1 )) - fi + local offset=0 + local CLOCK=" $(date +"${THEME_PROMPT_CLOCK_FORMAT}") " + + if [[ $? -eq 0 ]]; then + local CLOCK_PROMPT="" RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#CLOCK} )) + if [[ "${SEGMENT_AT_RIGHT}" -eq 0 ]]; then + CLOCK_PROMPT=$(set_rgb_color ${CLOCK_THEME_PROMPT_COLOR} -) + else + CLOCK_PROMPT=$(set_rgb_color ${CLOCK_THEME_PROMPT_COLOR} ${LAST_THEME_COLOR}) + (( offset += 1 )) + fi + CLOCK_PROMPT+=${THEME_PROMPT_LEFT_SEPARATOR}${normal}$(set_rgb_color - ${CLOCK_THEME_PROMPT_COLOR})${CLOCK}${normal} LAST_THEME_COLOR=${CLOCK_THEME_PROMPT_COLOR} + RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${offset} )) + RIGHT_PROMPT+="${CLOCK_PROMPT}" (( SEGMENT_AT_RIGHT += 1 )) fi } -function powerline_battery_status_prompt { - BATTERY_STATUS="$(battery_percentage 2> /dev/null)" +function powerline_battery_prompt { + local offset=3 + local BATTERY_STATUS="$(battery_percentage 2> /dev/null)" if [[ -z "${BATTERY_STATUS}" ]] || [[ "${BATTERY_STATUS}" = "-1" ]] || [[ "${BATTERY_STATUS}" = "no" ]]; then - BATTERY_PROMPT="" + true else + local BATTERY_PROMPT="" if [[ "$((10#${BATTERY_STATUS}))" -le 5 ]]; then - BATTERY_STATUS_THEME_PROMPT_COLOR="${BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR}" + BATTERY_STATUS_THEME_PROMPT_COLOR="${BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR}" elif [[ "$((10#${BATTERY_STATUS}))" -le 25 ]]; then BATTERY_STATUS_THEME_PROMPT_COLOR="${BATTERY_STATUS_THEME_PROMPT_LOW_COLOR}" else BATTERY_STATUS_THEME_PROMPT_COLOR="${BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR}" fi [[ "$(ac_adapter_connected)" ]] && BATTERY_STATUS="${BATTERY_AC_CHAR}${BATTERY_STATUS}" - BATTERY_PROMPT="$(set_rgb_color - ${BATTERY_STATUS_THEME_PROMPT_COLOR}) ${BATTERY_STATUS}% " - if [[ "${SEGMENT_AT_RIGHT}" -gt 0 ]]; then - BATTERY_PROMPT+=$(set_rgb_color ${LAST_THEME_COLOR} ${BATTERY_STATUS_THEME_PROMPT_COLOR})${THEME_PROMPT_LEFT_SEPARATOR}${normal} - (( RIGHT_PROMPT_LENGTH += SEGMENT_AT_RIGHT )) + if [[ "${SEGMENT_AT_RIGHT}" -eq 0 ]]; then + BATTERY_PROMPT=$(set_rgb_color ${BATTERY_STATUS_THEME_PROMPT_COLOR} -)${THEME_PROMPT_LEFT_SEPARATOR}${normal} else - BATTERY_STATUS+=" " + BATTERY_PROMPT=$(set_rgb_color ${BATTERY_STATUS_THEME_PROMPT_COLOR} ${LAST_THEME_COLOR})${THEME_PROMPT_LEFT_SEPARATOR}${normal} + (( offset +=1 )) fi - RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#BATTERY_STATUS} + 2 )) + BATTERY_PROMPT+="$(set_rgb_color - ${BATTERY_STATUS_THEME_PROMPT_COLOR}) ${BATTERY_STATUS}% ${normal}" + RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#BATTERY_STATUS} + ${offset} )) LAST_THEME_COLOR=${BATTERY_STATUS_THEME_PROMPT_COLOR} + RIGHT_PROMPT+="${BATTERY_PROMPT}" (( SEGMENT_AT_RIGHT += 1 )) fi } function powerline_in_vim_prompt { - if [ -z "$VIMRUNTIME" ]; then - IN_VIM_PROMPT="" - else - IN_VIM_PROMPT="$(set_rgb_color - ${IN_VIM_PROMPT_COLOR}) ${IN_VIM_PROMPT_TEXT} " - if [[ "${SEGMENT_AT_RIGHT}" -gt 0 ]]; then - IN_VIM_PROMPT+=$(set_rgb_color ${LAST_THEME_COLOR} ${IN_VIM_PROMPT_COLOR})${THEME_PROMPT_LEFT_SEPARATOR}${normal} - (( RIGHT_PROMPT_LENGTH += SEGMENT_AT_RIGHT )) + local offset=2 + local IN_VIM_PROMPT="" + if [ -n "$VIMRUNTIME" ]; then + if [[ "${SEGMENT_AT_RIGHT}" -eq 0 ]]; then + IN_VIM_PROMPT+=$(set_rgb_color ${IN_VIM_PROMPT_COLOR} -)${THEME_PROMPT_LEFT_SEPARATOR}${normal} + else + IN_VIM_PROMPT+=$(set_rgb_color ${IN_VIM_PROMPT_COLOR} ${LAST_THEME_COLOR})${THEME_PROMPT_LEFT_SEPARATOR}${normal} + (( offset += 1 )) fi - RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#IN_VIM_PROMPT_TEXT} )) + IN_VIM_PROMPT+="$(set_rgb_color - ${IN_VIM_PROMPT_COLOR}) ${IN_VIM_PROMPT_TEXT} ${normal}" + RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#IN_VIM_PROMPT_TEXT} + ${offset})) LAST_THEME_COLOR=${IN_VIM_PROMPT_COLOR} + RIGHT_PROMPT+="${IN_VIM_PROMPT}" (( SEGMENT_AT_RIGHT += 1 )) fi } @@ -245,29 +263,18 @@ function powerline_prompt_command() { LAST_THEME_COLOR="" ## left prompt ## - if [[ -z "${THEME_RIGHT_SEGMENTS}" ]]; then - powerline_scm_prompt - powerline_virtualenv_prompt - powerline_rvm_prompt - powerline_cwd_prompt - else - for f in $THEME_RIGHT_SEGMENTS; do - $f - done - fi + for segment in $THEME_LEFT_SEGMENTS; do + "powerline_${segment}_prompt" + done [[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="$(set_rgb_color ${LAST_THEME_COLOR} -)${THEME_PROMPT_SEPARATOR}${normal}" ## right prompt ## - powerline_shell_prompt - powerline_battery_status_prompt - powerline_clock_prompt - powerline_in_vim_prompt - - if [[ "${SEGMENT_AT_RIGHT}" -gt 0 ]]; then + if [[ -n "${THEME_RIGHT_SEGMENTS}" ]]; then LEFT_PROMPT+="${MOVE_CURSOR_RIGHTMOST}" - [[ "${SEGMENT_AT_RIGHT}" -eq 1 ]] && (( RIGHT_PROMPT_LENGTH-=1 )) - RIGHT_PROMPT="\033[${RIGHT_PROMPT_LENGTH}D$(set_rgb_color ${LAST_THEME_COLOR} -)${THEME_PROMPT_LEFT_SEPARATOR}${normal}" - RIGHT_PROMPT+="${IN_VIM_PROMPT}${CLOCK_PROMPT}${BATTERY_PROMPT}${SHELL_PROMPT}${normal}" + for segment in $THEME_RIGHT_SEGMENTS; do + "powerline_${segment}_prompt" + done + LEFT_PROMPT+="\033[${RIGHT_PROMPT_LENGTH}D" fi powerline_last_status_prompt LAST_STATUS From 1009b2372459c05ccfbe88be04f79424f7fababd Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Mon, 25 Jan 2016 20:01:00 +0100 Subject: [PATCH 124/216] Minor fixes --- themes/powerline-multiline/powerline-multiline.theme.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index 28887ea4..cb63f1e9 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -42,7 +42,7 @@ BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=160 THEME_PROMPT_CLOCK_FORMAT=${THEME_PROMPT_CLOCK_FORMAT:="%H:%M:%S"} -IN_VIM_PROMPT_COLOR=35 +IN_VIM_PROMPT_COLOR=245 IN_VIM_PROMPT_TEXT="vim" THEME_LEFT_SEGMENTS="scm virtualenv rvm cwd" @@ -185,7 +185,7 @@ function powerline_last_status_prompt { function powerline_clock_prompt { local offset=0 local CLOCK=" $(date +"${THEME_PROMPT_CLOCK_FORMAT}") " - + if [[ $? -eq 0 ]]; then local CLOCK_PROMPT="" RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#CLOCK} )) @@ -237,7 +237,7 @@ function powerline_in_vim_prompt { local IN_VIM_PROMPT="" if [ -n "$VIMRUNTIME" ]; then if [[ "${SEGMENT_AT_RIGHT}" -eq 0 ]]; then - IN_VIM_PROMPT+=$(set_rgb_color ${IN_VIM_PROMPT_COLOR} -)${THEME_PROMPT_LEFT_SEPARATOR}${normal} + IN_VIM_PROMPT+="$(set_rgb_color ${IN_VIM_PROMPT_COLOR} -)${THEME_PROMPT_LEFT_SEPARATOR}${normal}" else IN_VIM_PROMPT+=$(set_rgb_color ${IN_VIM_PROMPT_COLOR} ${LAST_THEME_COLOR})${THEME_PROMPT_LEFT_SEPARATOR}${normal} (( offset += 1 )) From 64e6f354dcd37fe0a2e350736d4536ef4a7be905 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Mon, 25 Jan 2016 20:01:37 +0100 Subject: [PATCH 125/216] Add Powerline Multiline theme README.md --- themes/powerline-multiline/README.md | 63 ++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 themes/powerline-multiline/README.md diff --git a/themes/powerline-multiline/README.md b/themes/powerline-multiline/README.md new file mode 100644 index 00000000..d0f6bfb8 --- /dev/null +++ b/themes/powerline-multiline/README.md @@ -0,0 +1,63 @@ +# Powerline Multiline Theme + +Colorfull multiline theme, the first line shows information about your shell session (divided into two parts, left and right), the second one is where the shell commands are introduced. + +## Information provided + +* Current path +* Current username and hostname +* An indicator when connected by SSH +* An indicator when sudo has the credentials cached (see the sudo manpage for more info about this) +* An indicator when the current shell is inside the Vim editor +* Battery charging status (depends on the battery plugin) +* Repository status +* The current Python enviroment (Virtualenv, venv, and Conda are supported) in use +* The current Ruby enviroment (RVM) in use +* Last command exit code (only shown when the exit code is greater than 0) + +## Configuration + +This theme is pretty configurable, all the configuration is done by setting environment variables. + +### User information + +By default, the username and hostname are shown at the right side, but you can change this behavior setting the value of the following variable: + + THEME_PROMPT_USER_INFO_MODE + +for now, the only supported value is `sudo`, that hides the username and hostname, and shows an indicator when the sudo has the credentials cached. Any other value has no effect. + +### Clock format + +By default, the current time is shown at the right side, you can change the format with the variable: + + THEME_PROMPT_CLOCK_FORMAT="%H:%M:%S" + +the date is printed by the `date` command, so refer to its man page to change the format. + +### Segment order + +Both prompt sides can be "reordered", all the "segments" (every piece of information) can take any place, the only restriction (for now), is that some segments only can be placed at left, and others only at right. + +Current available left "segments": + +* scm +* virtualenv +* rvm +* cwd + +Current available right "segments": + +* in_vim +* clock +* battery +* user_info + +Two variables can be defined to set the order of the prompt segments: + + THEME_LEFT_SEGMENTS="scm virtualenv rvm cwd" + THEME_RIGHT_SEGMENTS="in_vim clock battery user_info" + +if you want to remove something else from the prompt, simply remove the "string" that represents the segment from the corresponding variable. + + From dfbd065bc1e8ca2fa31da53f239d719796c3c1a6 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Mon, 25 Jan 2016 21:49:50 +0100 Subject: [PATCH 126/216] Fix indentation --- .../powerline-multiline.theme.bash | 355 +++++++++--------- 1 file changed, 177 insertions(+), 178 deletions(-) diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index cb63f1e9..33640057 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -50,236 +50,235 @@ THEME_RIGHT_SEGMENTS="in_vim clock battery user_info" function set_rgb_color { - if [[ "${1}" != "-" ]]; then - fg="38;5;${1}" - fi - if [[ "${2}" != "-" ]]; then - bg="48;5;${2}" - [[ -n "${fg}" ]] && bg=";${bg}" - fi - echo -e "\[\033[${fg}${bg}m\]" + if [[ "${1}" != "-" ]]; then + fg="38;5;${1}" + fi + if [[ "${2}" != "-" ]]; then + bg="48;5;${2}" + [[ -n "${fg}" ]] && bg=";${bg}" + fi + echo -e "\[\033[${fg}${bg}m\]" } function powerline_user_info_prompt { - local offset=2 - local USER_INFO="" - local USER_INFO_PROMPT="" - USER_INFO_PROMPT_COLOR=${USER_INFO_THEME_PROMPT_COLOR} - if sudo -n uptime 2>&1 | grep -q "load"; then - USER_INFO_PROMPT_COLOR=${USER_INFO_THEME_PROMPT_COLOR_SUDO} - fi - case "${THEME_PROMPT_USER_INFO_MODE}" in - "sudo") - if [[ "${USER_INFO_PROMPT_COLOR}" == "${USER_INFO_THEME_PROMPT_COLOR_SUDO}" ]]; then - USER_INFO="!" - fi - ;; - *) - if [[ -n "${SSH_CLIENT}" ]]; then - USER_INFO="${USER_INFO_SSH_CHAR}${USER}@${HOSTNAME}" - else - USER_INFO="${USER}" - fi - ;; - esac - if [[ -n "${USER_INFO}" ]]; then - if [[ "${SEGMENT_AT_RIGHT}" -eq 0 ]]; then - USER_INFO_PROMPT="$(set_rgb_color ${USER_INFO_PROMPT_COLOR} -)${THEME_PROMPT_LEFT_SEPARATOR}${normal}" - else - USER_INFO_PROMPT="$(set_rgb_color ${USER_INFO_PROMPT_COLOR} ${LAST_THEME_COLOR})${THEME_PROMPT_LEFT_SEPARATOR}${normal}" - (( offset += 1 )) - fi - USER_INFO_PROMPT+="$(set_rgb_color - ${USER_INFO_PROMPT_COLOR}) ${USER_INFO} ${normal}" - RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#USER_INFO} + ${offset} )) - LAST_THEME_COLOR=${USER_INFO_PROMPT_COLOR} - RIGHT_PROMPT+="${USER_INFO_PROMPT}" - (( SEGMENT_AT_RIGHT += 1 )) + local offset=2 + local USER_INFO="" + local USER_INFO_PROMPT="" + USER_INFO_PROMPT_COLOR=${USER_INFO_THEME_PROMPT_COLOR} + if sudo -n uptime 2>&1 | grep -q "load"; then + USER_INFO_PROMPT_COLOR=${USER_INFO_THEME_PROMPT_COLOR_SUDO} + fi + case "${THEME_PROMPT_USER_INFO_MODE}" in + "sudo") + if [[ "${USER_INFO_PROMPT_COLOR}" == "${USER_INFO_THEME_PROMPT_COLOR_SUDO}" ]]; then + USER_INFO="!" + fi + ;; + *) + if [[ -n "${SSH_CLIENT}" ]]; then + USER_INFO="${USER_INFO_SSH_CHAR}${USER}@${HOSTNAME}" + else + USER_INFO="${USER}" + fi + ;; + esac + if [[ -n "${USER_INFO}" ]]; then + if [[ "${SEGMENT_AT_RIGHT}" -eq 0 ]]; then + USER_INFO_PROMPT="$(set_rgb_color ${USER_INFO_PROMPT_COLOR} -)${THEME_PROMPT_LEFT_SEPARATOR}${normal}" + else + USER_INFO_PROMPT="$(set_rgb_color ${USER_INFO_PROMPT_COLOR} ${LAST_THEME_COLOR})${THEME_PROMPT_LEFT_SEPARATOR}${normal}" + (( offset += 1 )) fi + USER_INFO_PROMPT+="$(set_rgb_color - ${USER_INFO_PROMPT_COLOR}) ${USER_INFO} ${normal}" + RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#USER_INFO} + ${offset} )) + LAST_THEME_COLOR=${USER_INFO_PROMPT_COLOR} + RIGHT_PROMPT+="${USER_INFO_PROMPT}" + (( SEGMENT_AT_RIGHT += 1 )) + fi } function powerline_rvm_prompt { - local RVM_PROMPT="" + local RVM_PROMPT="" - if command_exists rvm; then - RVM_PROMPT=$(rvm_version_prompt) - if [[ "${RVM_PROMPT}" != $(rvm strings default) ]]; then - RVM_PROMPT="$(set_rgb_color - ${RVM_THEME_PROMPT_COLOR}) ${RVM_CHAR}${RVM_PROMPT} ${normal}" - if [[ "${SEGMENT_AT_LEFT}" -gt 0 ]]; then - RVM_PROMPT=$(set_rgb_color ${LAST_THEME_COLOR} ${RVM_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}${RVM_PROMPT} - fi - LAST_THEME_COLOR=${RVM_THEME_PROMPT_COLOR} - LEFT_PROMPT+="${RVM_PROMPT}" - (( SEGMENT_AT_LEFT += 1 )) - fi + if command_exists rvm; then + RVM_PROMPT=$(rvm_version_prompt) + if [[ "${RVM_PROMPT}" != $(rvm strings default) ]]; then + RVM_PROMPT="$(set_rgb_color - ${RVM_THEME_PROMPT_COLOR}) ${RVM_CHAR}${RVM_PROMPT} ${normal}" + if [[ "${SEGMENT_AT_LEFT}" -gt 0 ]]; then + RVM_PROMPT=$(set_rgb_color ${LAST_THEME_COLOR} ${RVM_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}${RVM_PROMPT} + fi + LAST_THEME_COLOR=${RVM_THEME_PROMPT_COLOR} + LEFT_PROMPT+="${RVM_PROMPT}" + (( SEGMENT_AT_LEFT += 1 )) fi + fi } function powerline_virtualenv_prompt { - local VIRTUALENV_PROMPT="" + local VIRTUALENV_PROMPT="" - if [[ -n "$CONDA_DEFAULT_ENV" ]]; then - VIRTUALENV_PROMPT="$CONDA_DEFAULT_ENV" - VIRTUALENV_CHAR=${CONDA_VIRTUALENV_CHAR} - elif [[ -n "$VIRTUAL_ENV" ]]; then - VIRTUALENV_PROMPT=$(basename "$VIRTUAL_ENV") - fi + if [[ -n "$CONDA_DEFAULT_ENV" ]]; then + VIRTUALENV_PROMPT="$CONDA_DEFAULT_ENV" + VIRTUALENV_CHAR=${CONDA_VIRTUALENV_CHAR} + elif [[ -n "$VIRTUAL_ENV" ]]; then + VIRTUALENV_PROMPT=$(basename "$VIRTUAL_ENV") + fi - if [[ -n "$VIRTUALENV_PROMPT" ]]; then - VIRTUALENV_PROMPT="$(set_rgb_color - ${VIRTUALENV_THEME_PROMPT_COLOR}) ${VIRTUALENV_CHAR}${VIRTUALENV_PROMPT} ${normal}" - if [[ "${SEGMENT_AT_LEFT}" -gt 0 ]]; then - VIRTUALENV_PROMPT=$(set_rgb_color ${LAST_THEME_COLOR} ${VIRTUALENV_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}${VIRTUALENV_PROMPT} - fi - LAST_THEME_COLOR=${VIRTUALENV_THEME_PROMPT_COLOR} - LEFT_PROMPT+="${VIRTUALENV_PROMPT}" - (( SEGMENT_AT_LEFT += 1 )) + if [[ -n "$VIRTUALENV_PROMPT" ]]; then + VIRTUALENV_PROMPT="$(set_rgb_color - ${VIRTUALENV_THEME_PROMPT_COLOR}) ${VIRTUALENV_CHAR}${VIRTUALENV_PROMPT} ${normal}" + if [[ "${SEGMENT_AT_LEFT}" -gt 0 ]]; then + VIRTUALENV_PROMPT=$(set_rgb_color ${LAST_THEME_COLOR} ${VIRTUALENV_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}${VIRTUALENV_PROMPT} fi + LAST_THEME_COLOR=${VIRTUALENV_THEME_PROMPT_COLOR} + LEFT_PROMPT+="${VIRTUALENV_PROMPT}" + (( SEGMENT_AT_LEFT += 1 )) + fi } function powerline_scm_prompt { - local SCM_PROMPT="" + local SCM_PROMPT="" - scm_prompt_vars - if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]]; then - if [[ "${SCM_DIRTY}" -eq 3 ]]; then - SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_STAGED_COLOR} - elif [[ "${SCM_DIRTY}" -eq 2 ]]; then - SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_UNSTAGED_COLOR} - elif [[ "${SCM_DIRTY}" -eq 1 ]]; then - SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_DIRTY_COLOR} - else - SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR} - fi - if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then - SCM_PROMPT+=" ${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" - fi - SCM_PROMPT="$(set_rgb_color - ${SCM_THEME_PROMPT_COLOR})${SCM_PROMPT} ${normal}" - if [[ "${SEGMENT_AT_LEFT}" -gt 0 ]]; then - SCM_PROMPT=$(set_rgb_color ${LAST_THEME_COLOR} ${SCM_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}${SCM_PROMPT} - fi - LEFT_PROMPT+="${SCM_PROMPT}" - LAST_THEME_COLOR=${SCM_THEME_PROMPT_COLOR} - (( SEGMENT_AT_LEFT += 1 )) + scm_prompt_vars + if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]]; then + if [[ "${SCM_DIRTY}" -eq 3 ]]; then + SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_STAGED_COLOR} + elif [[ "${SCM_DIRTY}" -eq 2 ]]; then + SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_UNSTAGED_COLOR} + elif [[ "${SCM_DIRTY}" -eq 1 ]]; then + SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_DIRTY_COLOR} + else + SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR} fi + if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then + SCM_PROMPT+=" ${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" + fi + SCM_PROMPT="$(set_rgb_color - ${SCM_THEME_PROMPT_COLOR})${SCM_PROMPT} ${normal}" + if [[ "${SEGMENT_AT_LEFT}" -gt 0 ]]; then + SCM_PROMPT=$(set_rgb_color ${LAST_THEME_COLOR} ${SCM_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}${SCM_PROMPT} + fi + LEFT_PROMPT+="${SCM_PROMPT}" + LAST_THEME_COLOR=${SCM_THEME_PROMPT_COLOR} + (( SEGMENT_AT_LEFT += 1 )) + fi } function powerline_cwd_prompt { - local CWD_PROMPT="" - #CWD_PROMPT="$(set_rgb_color - ${CWD_THEME_PROMPT_COLOR}) \w ${normal}$(set_rgb_color ${CWD_THEME_PROMPT_COLOR} -)${normal}$(set_rgb_color ${CWD_THEME_PROMPT_COLOR} -)${THEME_PROMPT_SEPARATOR}${normal}" - CWD_PROMPT="$(set_rgb_color - ${CWD_THEME_PROMPT_COLOR}) \w ${normal}$(set_rgb_color ${CWD_THEME_PROMPT_COLOR} -)${normal}" - if [[ "${SEGMENT_AT_LEFT}" -gt 0 ]]; then - CWD_PROMPT=$(set_rgb_color ${LAST_THEME_COLOR} ${CWD_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}${CWD_PROMPT} - fi - LAST_THEME_COLOR=${CWD_THEME_PROMPT_COLOR} - LEFT_PROMPT+="${CWD_PROMPT}" - (( SEGMENT_AT_LEFT += 1 )) + local CWD_PROMPT="" + CWD_PROMPT="$(set_rgb_color - ${CWD_THEME_PROMPT_COLOR}) \w ${normal}$(set_rgb_color ${CWD_THEME_PROMPT_COLOR} -)${normal}" + if [[ "${SEGMENT_AT_LEFT}" -gt 0 ]]; then + CWD_PROMPT=$(set_rgb_color ${LAST_THEME_COLOR} ${CWD_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}${CWD_PROMPT} + fi + LAST_THEME_COLOR=${CWD_THEME_PROMPT_COLOR} + LEFT_PROMPT+="${CWD_PROMPT}" + (( SEGMENT_AT_LEFT += 1 )) } function powerline_last_status_prompt { - if [[ "$1" -eq 0 ]]; then - LAST_STATUS_PROMPT="" - else - LAST_STATUS_PROMPT="$(set_rgb_color ${LAST_STATUS_THEME_PROMPT_COLOR} -) ${LAST_STATUS} ${normal}" - fi + if [[ "$1" -eq 0 ]]; then + LAST_STATUS_PROMPT="" + else + LAST_STATUS_PROMPT="$(set_rgb_color ${LAST_STATUS_THEME_PROMPT_COLOR} -) ${LAST_STATUS} ${normal}" + fi } function powerline_clock_prompt { - local offset=0 - local CLOCK=" $(date +"${THEME_PROMPT_CLOCK_FORMAT}") " + local offset=0 + local CLOCK=" $(date +"${THEME_PROMPT_CLOCK_FORMAT}") " - if [[ $? -eq 0 ]]; then - local CLOCK_PROMPT="" - RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#CLOCK} )) - if [[ "${SEGMENT_AT_RIGHT}" -eq 0 ]]; then - CLOCK_PROMPT=$(set_rgb_color ${CLOCK_THEME_PROMPT_COLOR} -) - else - CLOCK_PROMPT=$(set_rgb_color ${CLOCK_THEME_PROMPT_COLOR} ${LAST_THEME_COLOR}) - (( offset += 1 )) - fi - CLOCK_PROMPT+=${THEME_PROMPT_LEFT_SEPARATOR}${normal}$(set_rgb_color - ${CLOCK_THEME_PROMPT_COLOR})${CLOCK}${normal} - LAST_THEME_COLOR=${CLOCK_THEME_PROMPT_COLOR} - RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${offset} )) - RIGHT_PROMPT+="${CLOCK_PROMPT}" - (( SEGMENT_AT_RIGHT += 1 )) + if [[ $? -eq 0 ]]; then + local CLOCK_PROMPT="" + RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#CLOCK} )) + if [[ "${SEGMENT_AT_RIGHT}" -eq 0 ]]; then + CLOCK_PROMPT=$(set_rgb_color ${CLOCK_THEME_PROMPT_COLOR} -) + else + CLOCK_PROMPT=$(set_rgb_color ${CLOCK_THEME_PROMPT_COLOR} ${LAST_THEME_COLOR}) + (( offset += 1 )) fi + CLOCK_PROMPT+=${THEME_PROMPT_LEFT_SEPARATOR}${normal}$(set_rgb_color - ${CLOCK_THEME_PROMPT_COLOR})${CLOCK}${normal} + LAST_THEME_COLOR=${CLOCK_THEME_PROMPT_COLOR} + RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${offset} )) + RIGHT_PROMPT+="${CLOCK_PROMPT}" + (( SEGMENT_AT_RIGHT += 1 )) + fi } function powerline_battery_prompt { - local offset=3 - local BATTERY_STATUS="$(battery_percentage 2> /dev/null)" - if [[ -z "${BATTERY_STATUS}" ]] || [[ "${BATTERY_STATUS}" = "-1" ]] || [[ "${BATTERY_STATUS}" = "no" ]]; then - true + local offset=3 + local BATTERY_STATUS="$(battery_percentage 2> /dev/null)" + if [[ -z "${BATTERY_STATUS}" ]] || [[ "${BATTERY_STATUS}" = "-1" ]] || [[ "${BATTERY_STATUS}" = "no" ]]; then + true + else + local BATTERY_PROMPT="" + if [[ "$((10#${BATTERY_STATUS}))" -le 5 ]]; then + BATTERY_STATUS_THEME_PROMPT_COLOR="${BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR}" + elif [[ "$((10#${BATTERY_STATUS}))" -le 25 ]]; then + BATTERY_STATUS_THEME_PROMPT_COLOR="${BATTERY_STATUS_THEME_PROMPT_LOW_COLOR}" else - local BATTERY_PROMPT="" - if [[ "$((10#${BATTERY_STATUS}))" -le 5 ]]; then - BATTERY_STATUS_THEME_PROMPT_COLOR="${BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR}" - elif [[ "$((10#${BATTERY_STATUS}))" -le 25 ]]; then - BATTERY_STATUS_THEME_PROMPT_COLOR="${BATTERY_STATUS_THEME_PROMPT_LOW_COLOR}" - else - BATTERY_STATUS_THEME_PROMPT_COLOR="${BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR}" - fi - [[ "$(ac_adapter_connected)" ]] && BATTERY_STATUS="${BATTERY_AC_CHAR}${BATTERY_STATUS}" - if [[ "${SEGMENT_AT_RIGHT}" -eq 0 ]]; then - BATTERY_PROMPT=$(set_rgb_color ${BATTERY_STATUS_THEME_PROMPT_COLOR} -)${THEME_PROMPT_LEFT_SEPARATOR}${normal} - else - BATTERY_PROMPT=$(set_rgb_color ${BATTERY_STATUS_THEME_PROMPT_COLOR} ${LAST_THEME_COLOR})${THEME_PROMPT_LEFT_SEPARATOR}${normal} - (( offset +=1 )) - fi - BATTERY_PROMPT+="$(set_rgb_color - ${BATTERY_STATUS_THEME_PROMPT_COLOR}) ${BATTERY_STATUS}% ${normal}" - RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#BATTERY_STATUS} + ${offset} )) - LAST_THEME_COLOR=${BATTERY_STATUS_THEME_PROMPT_COLOR} - RIGHT_PROMPT+="${BATTERY_PROMPT}" - (( SEGMENT_AT_RIGHT += 1 )) + BATTERY_STATUS_THEME_PROMPT_COLOR="${BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR}" fi + [[ "$(ac_adapter_connected)" ]] && BATTERY_STATUS="${BATTERY_AC_CHAR}${BATTERY_STATUS}" + if [[ "${SEGMENT_AT_RIGHT}" -eq 0 ]]; then + BATTERY_PROMPT=$(set_rgb_color ${BATTERY_STATUS_THEME_PROMPT_COLOR} -)${THEME_PROMPT_LEFT_SEPARATOR}${normal} + else + BATTERY_PROMPT=$(set_rgb_color ${BATTERY_STATUS_THEME_PROMPT_COLOR} ${LAST_THEME_COLOR})${THEME_PROMPT_LEFT_SEPARATOR}${normal} + (( offset +=1 )) + fi + BATTERY_PROMPT+="$(set_rgb_color - ${BATTERY_STATUS_THEME_PROMPT_COLOR}) ${BATTERY_STATUS}% ${normal}" + RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#BATTERY_STATUS} + ${offset} )) + LAST_THEME_COLOR=${BATTERY_STATUS_THEME_PROMPT_COLOR} + RIGHT_PROMPT+="${BATTERY_PROMPT}" + (( SEGMENT_AT_RIGHT += 1 )) + fi } function powerline_in_vim_prompt { local offset=2 local IN_VIM_PROMPT="" if [ -n "$VIMRUNTIME" ]; then - if [[ "${SEGMENT_AT_RIGHT}" -eq 0 ]]; then - IN_VIM_PROMPT+="$(set_rgb_color ${IN_VIM_PROMPT_COLOR} -)${THEME_PROMPT_LEFT_SEPARATOR}${normal}" - else - IN_VIM_PROMPT+=$(set_rgb_color ${IN_VIM_PROMPT_COLOR} ${LAST_THEME_COLOR})${THEME_PROMPT_LEFT_SEPARATOR}${normal} - (( offset += 1 )) - fi - IN_VIM_PROMPT+="$(set_rgb_color - ${IN_VIM_PROMPT_COLOR}) ${IN_VIM_PROMPT_TEXT} ${normal}" - RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#IN_VIM_PROMPT_TEXT} + ${offset})) - LAST_THEME_COLOR=${IN_VIM_PROMPT_COLOR} - RIGHT_PROMPT+="${IN_VIM_PROMPT}" - (( SEGMENT_AT_RIGHT += 1 )) + if [[ "${SEGMENT_AT_RIGHT}" -eq 0 ]]; then + IN_VIM_PROMPT+="$(set_rgb_color ${IN_VIM_PROMPT_COLOR} -)${THEME_PROMPT_LEFT_SEPARATOR}${normal}" + else + IN_VIM_PROMPT+=$(set_rgb_color ${IN_VIM_PROMPT_COLOR} ${LAST_THEME_COLOR})${THEME_PROMPT_LEFT_SEPARATOR}${normal} + (( offset += 1 )) + fi + IN_VIM_PROMPT+="$(set_rgb_color - ${IN_VIM_PROMPT_COLOR}) ${IN_VIM_PROMPT_TEXT} ${normal}" + RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#IN_VIM_PROMPT_TEXT} + ${offset})) + LAST_THEME_COLOR=${IN_VIM_PROMPT_COLOR} + RIGHT_PROMPT+="${IN_VIM_PROMPT}" + (( SEGMENT_AT_RIGHT += 1 )) fi } function powerline_prompt_command() { - local LAST_STATUS="$?" - local MOVE_CURSOR_RIGHTMOST='\033[500C' + local LAST_STATUS="$?" + local MOVE_CURSOR_RIGHTMOST='\033[500C' - LEFT_PROMPT="" - RIGHT_PROMPT="" - SEGMENT_AT_LEFT=0 - SEGMENT_AT_RIGHT=0 - RIGHT_PROMPT_LENGTH=0 - LAST_THEME_COLOR="" + LEFT_PROMPT="" + RIGHT_PROMPT="" + SEGMENT_AT_LEFT=0 + SEGMENT_AT_RIGHT=0 + RIGHT_PROMPT_LENGTH=0 + LAST_THEME_COLOR="" - ## left prompt ## - for segment in $THEME_LEFT_SEGMENTS; do - "powerline_${segment}_prompt" + ## left prompt ## + for segment in $THEME_LEFT_SEGMENTS; do + "powerline_${segment}_prompt" + done + [[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="$(set_rgb_color ${LAST_THEME_COLOR} -)${THEME_PROMPT_SEPARATOR}${normal}" + + ## right prompt ## + if [[ -n "${THEME_RIGHT_SEGMENTS}" ]]; then + LEFT_PROMPT+="${MOVE_CURSOR_RIGHTMOST}" + for segment in $THEME_RIGHT_SEGMENTS; do + "powerline_${segment}_prompt" done - [[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="$(set_rgb_color ${LAST_THEME_COLOR} -)${THEME_PROMPT_SEPARATOR}${normal}" + LEFT_PROMPT+="\033[${RIGHT_PROMPT_LENGTH}D" + fi - ## right prompt ## - if [[ -n "${THEME_RIGHT_SEGMENTS}" ]]; then - LEFT_PROMPT+="${MOVE_CURSOR_RIGHTMOST}" - for segment in $THEME_RIGHT_SEGMENTS; do - "powerline_${segment}_prompt" - done - LEFT_PROMPT+="\033[${RIGHT_PROMPT_LENGTH}D" - fi + powerline_last_status_prompt LAST_STATUS - powerline_last_status_prompt LAST_STATUS - - PS1="${LEFT_PROMPT}${RIGHT_PROMPT}\n${LAST_STATUS_PROMPT}${PROMPT_CHAR} " + PS1="${LEFT_PROMPT}${RIGHT_PROMPT}\n${LAST_STATUS_PROMPT}${PROMPT_CHAR} " } PROMPT_COMMAND=powerline_prompt_command From a2ac5b0096c41212730995b5d0e67d8713655e8f Mon Sep 17 00:00:00 2001 From: Christophe Aguettaz Date: Tue, 26 Jan 2016 20:05:47 +0100 Subject: [PATCH 127/216] Fixed compatibility with older bash versions. Older versions (like 3.2, current default on MacOS X) don't implement readarray. --- themes/base.theme.bash | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 962df15a..ee906dee 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -114,9 +114,7 @@ function git_status_summary { if (!seen_header) { print } - print untracked - print unstaged - print staged + print untracked "\t" unstaged "\t" staged }' } @@ -125,12 +123,11 @@ function git_prompt_vars { SCM_STATE=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} if [[ "$(git config --get bash-it.hide-status)" != "1" ]]; then [[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && local git_status_flags='-uno' - readarray -t status_lines < <((git status --porcelain ${git_status_flags} -b 2> /dev/null || - git status --porcelain ${git_status_flags} 2> /dev/null) | git_status_summary ) - local status="${status_lines[0]}" - local untracked_count="${status_lines[1]}" - local unstaged_count="${status_lines[2]}" - local staged_count="${status_lines[3]}" + local status_lines=$((git status --porcelain ${git_status_flags} -b 2> /dev/null || + git status --porcelain ${git_status_flags} 2> /dev/null) | git_status_summary) + local status=$(awk 'NR==1' <<< "$status_lines") + local counts=$(awk 'NR==2' <<< "$status_lines") + IFS=$'\t' read untracked_count unstaged_count staged_count <<< "$counts" if [[ "${untracked_count}" -gt 0 || "${unstaged_count}" -gt 0 || "${staged_count}" -gt 0 ]]; then SCM_DIRTY=1 if [[ "${SCM_GIT_SHOW_DETAILS}" = "true" ]]; then From 6d4923aca81b443826d7a2593839b00afa8ea83e Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Wed, 27 Jan 2016 01:07:14 +0100 Subject: [PATCH 128/216] Now, segments can be placed at left or at right - Code refactor - Print code converted into functions - Remove unused variables - Improved conistence in naming, variable and functions --- .../powerline-multiline.theme.bash | 292 ++++++++---------- 1 file changed, 128 insertions(+), 164 deletions(-) diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index 33640057..edd7b82d 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -1,15 +1,12 @@ #!/usr/bin/env bash -THEME_PROMPT_SEPARATOR="" -THEME_PROMPT_LEFT_SEPARATOR="" - -USER_INFO_SSH_CHAR=${USER_INFO_SSH_CHAR:=" "} +USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:=" "} USER_INFO_THEME_PROMPT_COLOR=32 USER_INFO_THEME_PROMPT_COLOR_SUDO=202 -VIRTUALENV_CHAR=${POWERLINE_VIRTUALENV_CHAR:="❲p❳ "} -CONDA_VIRTUALENV_CHAR=${POWERLINE_CONDA_VIRTUALENV_CHAR:="❲c❳ "} -VIRTUALENV_THEME_PROMPT_COLOR=35 +PYTHON_VENV_CHAR=${POWERLINE_PYTHON_VENV_CHAR:="❲p❳ "} +CONDA_PYTHON_VENV_CHAR=${POWERLINE_CONDA_PYTHON_VENV_CHAR:="❲c❳ "} +PYTHON_VENV_THEME_PROMPT_COLOR=35 SCM_NONE_CHAR="" SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "} @@ -40,13 +37,13 @@ BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR=70 BATTERY_STATUS_THEME_PROMPT_LOW_COLOR=208 BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=160 -THEME_PROMPT_CLOCK_FORMAT=${THEME_PROMPT_CLOCK_FORMAT:="%H:%M:%S"} +THEME_PROMPT_CLOCK_FORMAT=${POWERLINE_PROMPT_CLOCK_FORMAT:="%H:%M:%S"} -IN_VIM_PROMPT_COLOR=245 -IN_VIM_PROMPT_TEXT="vim" +IN_VIM_THEME_PROMPT_COLOR=245 +IN_VIM_THEME_PROMPT_TEXT="vim" -THEME_LEFT_SEGMENTS="scm virtualenv rvm cwd" -THEME_RIGHT_SEGMENTS="in_vim clock battery user_info" +POWERLINE_LEFT_PROMPT="scm python_venv rvm cwd" +POWERLINE_RIGHT_PROMPT="in_vim clock battery user_info" function set_rgb_color { @@ -60,225 +57,192 @@ function set_rgb_color { echo -e "\[\033[${fg}${bg}m\]" } -function powerline_user_info_prompt { - local offset=2 - local USER_INFO="" - local USER_INFO_PROMPT="" - USER_INFO_PROMPT_COLOR=${USER_INFO_THEME_PROMPT_COLOR} +function __powerline_user_info_prompt { + local user_info="" + local color=${USER_INFO_THEME_PROMPT_COLOR} + if sudo -n uptime 2>&1 | grep -q "load"; then - USER_INFO_PROMPT_COLOR=${USER_INFO_THEME_PROMPT_COLOR_SUDO} + COLOR=${USER_INFO_THEME_PROMPT_COLOR_SUDO} fi - case "${THEME_PROMPT_USER_INFO_MODE}" in + case "${POWERLINE_PROMPT_USER_INFO_MODE}" in "sudo") - if [[ "${USER_INFO_PROMPT_COLOR}" == "${USER_INFO_THEME_PROMPT_COLOR_SUDO}" ]]; then - USER_INFO="!" + if [[ "${COLOR}" == "${USER_INFO_THEME_PROMPT_COLOR_SUDO}" ]]; then + user_info="!" fi ;; *) if [[ -n "${SSH_CLIENT}" ]]; then - USER_INFO="${USER_INFO_SSH_CHAR}${USER}@${HOSTNAME}" + user_info="${USER_INFO_SSH_CHAR}${USER}@${HOSTNAME}" else - USER_INFO="${USER}" + user_info="${USER}" fi ;; esac - if [[ -n "${USER_INFO}" ]]; then - if [[ "${SEGMENT_AT_RIGHT}" -eq 0 ]]; then - USER_INFO_PROMPT="$(set_rgb_color ${USER_INFO_PROMPT_COLOR} -)${THEME_PROMPT_LEFT_SEPARATOR}${normal}" - else - USER_INFO_PROMPT="$(set_rgb_color ${USER_INFO_PROMPT_COLOR} ${LAST_THEME_COLOR})${THEME_PROMPT_LEFT_SEPARATOR}${normal}" - (( offset += 1 )) - fi - USER_INFO_PROMPT+="$(set_rgb_color - ${USER_INFO_PROMPT_COLOR}) ${USER_INFO} ${normal}" - RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#USER_INFO} + ${offset} )) - LAST_THEME_COLOR=${USER_INFO_PROMPT_COLOR} - RIGHT_PROMPT+="${USER_INFO_PROMPT}" - (( SEGMENT_AT_RIGHT += 1 )) - fi + [[ -n "${user_info}" ]] && echo "${user_info}|${COLOR}" } -function powerline_rvm_prompt { - local RVM_PROMPT="" +function __powerline_rvm_prompt { + local RVM="" if command_exists rvm; then - RVM_PROMPT=$(rvm_version_prompt) - if [[ "${RVM_PROMPT}" != $(rvm strings default) ]]; then - RVM_PROMPT="$(set_rgb_color - ${RVM_THEME_PROMPT_COLOR}) ${RVM_CHAR}${RVM_PROMPT} ${normal}" - if [[ "${SEGMENT_AT_LEFT}" -gt 0 ]]; then - RVM_PROMPT=$(set_rgb_color ${LAST_THEME_COLOR} ${RVM_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}${RVM_PROMPT} - fi - LAST_THEME_COLOR=${RVM_THEME_PROMPT_COLOR} - LEFT_PROMPT+="${RVM_PROMPT}" - (( SEGMENT_AT_LEFT += 1 )) - fi + RVM="$(rvm_version_prompt)" + [[ -n "${RVM}" ]] && echo "${RVM}|${RVM_THEME_PROMPT_COLOR}" fi } -function powerline_virtualenv_prompt { - local VIRTUALENV_PROMPT="" +function __powerline_python_venv_prompt { + local python_venv="" - if [[ -n "$CONDA_DEFAULT_ENV" ]]; then - VIRTUALENV_PROMPT="$CONDA_DEFAULT_ENV" - VIRTUALENV_CHAR=${CONDA_VIRTUALENV_CHAR} - elif [[ -n "$VIRTUAL_ENV" ]]; then - VIRTUALENV_PROMPT=$(basename "$VIRTUAL_ENV") + if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then + python_venv="${CONDA_DEFAULT_ENV}" + PYTHONV_VENV_CHAR=${CONDA_PYTHONVENV_CHAR} + elif [[ -n "${VIRTUAL_ENV}" ]]; then + python_venv=$(basename "${VIRTUAL_ENV}") fi - if [[ -n "$VIRTUALENV_PROMPT" ]]; then - VIRTUALENV_PROMPT="$(set_rgb_color - ${VIRTUALENV_THEME_PROMPT_COLOR}) ${VIRTUALENV_CHAR}${VIRTUALENV_PROMPT} ${normal}" - if [[ "${SEGMENT_AT_LEFT}" -gt 0 ]]; then - VIRTUALENV_PROMPT=$(set_rgb_color ${LAST_THEME_COLOR} ${VIRTUALENV_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}${VIRTUALENV_PROMPT} - fi - LAST_THEME_COLOR=${VIRTUALENV_THEME_PROMPT_COLOR} - LEFT_PROMPT+="${VIRTUALENV_PROMPT}" - (( SEGMENT_AT_LEFT += 1 )) - fi + [[ -n "${PYTHON_VENV}" ]] && echo "${python_venv}|${PYTHON_VENV_THEME_PROMPT_COLOR}" } -function powerline_scm_prompt { +function __powerline_scm_prompt { + local color="" local SCM_PROMPT="" scm_prompt_vars + if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]]; then if [[ "${SCM_DIRTY}" -eq 3 ]]; then - SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_STAGED_COLOR} + COLOR=${SCM_THEME_PROMPT_STAGED_COLOR} elif [[ "${SCM_DIRTY}" -eq 2 ]]; then - SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_UNSTAGED_COLOR} + COLOR=${SCM_THEME_PROMPT_UNSTAGED_COLOR} elif [[ "${SCM_DIRTY}" -eq 1 ]]; then - SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_DIRTY_COLOR} + COLOR=${SCM_THEME_PROMPT_DIRTY_COLOR} else - SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR} + COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR} fi if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then - SCM_PROMPT+=" ${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" + SCM_PROMPT+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" fi - SCM_PROMPT="$(set_rgb_color - ${SCM_THEME_PROMPT_COLOR})${SCM_PROMPT} ${normal}" - if [[ "${SEGMENT_AT_LEFT}" -gt 0 ]]; then - SCM_PROMPT=$(set_rgb_color ${LAST_THEME_COLOR} ${SCM_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}${SCM_PROMPT} - fi - LEFT_PROMPT+="${SCM_PROMPT}" - LAST_THEME_COLOR=${SCM_THEME_PROMPT_COLOR} - (( SEGMENT_AT_LEFT += 1 )) + echo "${SCM_PROMPT}|${COLOR}" fi } -function powerline_cwd_prompt { - local CWD_PROMPT="" - CWD_PROMPT="$(set_rgb_color - ${CWD_THEME_PROMPT_COLOR}) \w ${normal}$(set_rgb_color ${CWD_THEME_PROMPT_COLOR} -)${normal}" - if [[ "${SEGMENT_AT_LEFT}" -gt 0 ]]; then - CWD_PROMPT=$(set_rgb_color ${LAST_THEME_COLOR} ${CWD_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}${CWD_PROMPT} - fi - LAST_THEME_COLOR=${CWD_THEME_PROMPT_COLOR} - LEFT_PROMPT+="${CWD_PROMPT}" - (( SEGMENT_AT_LEFT += 1 )) +function __powerline_cwd_prompt { + echo "$(pwd | sed "s|^${HOME}|~|")|${CWD_THEME_PROMPT_COLOR}" } -function powerline_last_status_prompt { +function __powerline_clock_prompt { + echo "$(date +"${THEME_PROMPT_CLOCK_FORMAT}")|${CLOCK_THEME_PROMPT_COLOR}" +} + +function __powerline_battery_prompt { + local color="" + local battery_status="$(battery_percentage 2> /dev/null)" + + if [[ -z "${battery_status}" ]] || [[ "${battery_status}" = "-1" ]] || [[ "${battery_status}" = "no" ]]; then + true + else + if [[ "$((10#${battery_status}))" -le 5 ]]; then + color="${BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR}" + elif [[ "$((10#${battery_status}))" -le 25 ]]; then + color="${BATTERY_STATUS_THEME_PROMPT_LOW_COLOR}" + else + color="${BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR}" + fi + [[ "$(ac_adapter_connected)" ]] && battery_status="${BATTERY_AC_CHAR}${battery_status}" + echo "${battery_status}%|${color}" + fi +} + +function __powerline_in_vim_prompt { + if [ -n "$VIMRUNTIME" ]; then + echo "${IN_VIM_THEME_PROMPT_TEXT}|${IN_VIM_THEME_PROMPT_COLOR}" + fi +} + +function __powerline_last_status_prompt { if [[ "$1" -eq 0 ]]; then LAST_STATUS_PROMPT="" else - LAST_STATUS_PROMPT="$(set_rgb_color ${LAST_STATUS_THEME_PROMPT_COLOR} -) ${LAST_STATUS} ${normal}" + LAST_STATUS_PROMPT="$(set_rgb_color ${LAST_STATUS_THEME_PROMPT_COLOR} -) ${1} ${normal}" fi } -function powerline_clock_prompt { - local offset=0 - local CLOCK=" $(date +"${THEME_PROMPT_CLOCK_FORMAT}") " +function __powerline_left_segment { + local OLD_IFS="${IFS}"; IFS="|" + local params=( $1 ) + IFS="${OLD_IFS}" + local separator_char="" + local separator="" - if [[ $? -eq 0 ]]; then - local CLOCK_PROMPT="" - RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#CLOCK} )) - if [[ "${SEGMENT_AT_RIGHT}" -eq 0 ]]; then - CLOCK_PROMPT=$(set_rgb_color ${CLOCK_THEME_PROMPT_COLOR} -) - else - CLOCK_PROMPT=$(set_rgb_color ${CLOCK_THEME_PROMPT_COLOR} ${LAST_THEME_COLOR}) - (( offset += 1 )) - fi - CLOCK_PROMPT+=${THEME_PROMPT_LEFT_SEPARATOR}${normal}$(set_rgb_color - ${CLOCK_THEME_PROMPT_COLOR})${CLOCK}${normal} - LAST_THEME_COLOR=${CLOCK_THEME_PROMPT_COLOR} - RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${offset} )) - RIGHT_PROMPT+="${CLOCK_PROMPT}" - (( SEGMENT_AT_RIGHT += 1 )) + if [[ "${SEGMENTS_AT_LEFT}" -gt 0 ]]; then + separator="$(set_rgb_color ${LAST_SEGMENT_COLOR} ${params[1]})${separator_char}${normal}${normal}" fi + LEFT_PROMPT+="${separator}$(set_rgb_color - ${params[1]}) ${params[0]} ${normal}" + LAST_SEGMENT_COLOR=${params[1]} + (( SEGMENTS_AT_LEFT += 1 )) } -function powerline_battery_prompt { - local offset=3 - local BATTERY_STATUS="$(battery_percentage 2> /dev/null)" - if [[ -z "${BATTERY_STATUS}" ]] || [[ "${BATTERY_STATUS}" = "-1" ]] || [[ "${BATTERY_STATUS}" = "no" ]]; then - true +function __powerline_right_segment { + local OLD_IFS="${IFS}"; IFS="|" + local params=( $1 ) + IFS="${OLD_IFS}" + local separator_char="" + local padding=2 + local separator_color="" + + if [[ "${SEGMENTS_AT_RIGHT}" -eq 0 ]]; then + separator_color="$(set_rgb_color ${params[1]} -)" else - local BATTERY_PROMPT="" - if [[ "$((10#${BATTERY_STATUS}))" -le 5 ]]; then - BATTERY_STATUS_THEME_PROMPT_COLOR="${BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR}" - elif [[ "$((10#${BATTERY_STATUS}))" -le 25 ]]; then - BATTERY_STATUS_THEME_PROMPT_COLOR="${BATTERY_STATUS_THEME_PROMPT_LOW_COLOR}" - else - BATTERY_STATUS_THEME_PROMPT_COLOR="${BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR}" - fi - [[ "$(ac_adapter_connected)" ]] && BATTERY_STATUS="${BATTERY_AC_CHAR}${BATTERY_STATUS}" - if [[ "${SEGMENT_AT_RIGHT}" -eq 0 ]]; then - BATTERY_PROMPT=$(set_rgb_color ${BATTERY_STATUS_THEME_PROMPT_COLOR} -)${THEME_PROMPT_LEFT_SEPARATOR}${normal} - else - BATTERY_PROMPT=$(set_rgb_color ${BATTERY_STATUS_THEME_PROMPT_COLOR} ${LAST_THEME_COLOR})${THEME_PROMPT_LEFT_SEPARATOR}${normal} - (( offset +=1 )) - fi - BATTERY_PROMPT+="$(set_rgb_color - ${BATTERY_STATUS_THEME_PROMPT_COLOR}) ${BATTERY_STATUS}% ${normal}" - RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#BATTERY_STATUS} + ${offset} )) - LAST_THEME_COLOR=${BATTERY_STATUS_THEME_PROMPT_COLOR} - RIGHT_PROMPT+="${BATTERY_PROMPT}" - (( SEGMENT_AT_RIGHT += 1 )) + separator_color="$(set_rgb_color ${params[1]} ${LAST_SEGMENT_COLOR})" + (( padding += 1 )) fi + RIGHT_PROMPT+="${separator_color}${separator_char}${normal}$(set_rgb_color - ${params[1]}) ${params[0]} ${normal}$(set_rgb_color - ${COLOR})${normal}" + RIGHT_PROMPT_LENGTH=$(( ${#params[0]} + RIGHT_PROMPT_LENGTH + padding )) + LAST_SEGMENT_COLOR="${params[1]}" + (( SEGMENTS_AT_RIGHT += 1 )) } -function powerline_in_vim_prompt { - local offset=2 - local IN_VIM_PROMPT="" - if [ -n "$VIMRUNTIME" ]; then - if [[ "${SEGMENT_AT_RIGHT}" -eq 0 ]]; then - IN_VIM_PROMPT+="$(set_rgb_color ${IN_VIM_PROMPT_COLOR} -)${THEME_PROMPT_LEFT_SEPARATOR}${normal}" - else - IN_VIM_PROMPT+=$(set_rgb_color ${IN_VIM_PROMPT_COLOR} ${LAST_THEME_COLOR})${THEME_PROMPT_LEFT_SEPARATOR}${normal} - (( offset += 1 )) - fi - IN_VIM_PROMPT+="$(set_rgb_color - ${IN_VIM_PROMPT_COLOR}) ${IN_VIM_PROMPT_TEXT} ${normal}" - RIGHT_PROMPT_LENGTH=$(( ${RIGHT_PROMPT_LENGTH} + ${#IN_VIM_PROMPT_TEXT} + ${offset})) - LAST_THEME_COLOR=${IN_VIM_PROMPT_COLOR} - RIGHT_PROMPT+="${IN_VIM_PROMPT}" - (( SEGMENT_AT_RIGHT += 1 )) - fi -} - - -function powerline_prompt_command() { - local LAST_STATUS="$?" - local MOVE_CURSOR_RIGHTMOST='\033[500C' +function __powerline_prompt_command { + local last_status="$?" ## always the first + local separator_char="" + local move_cursor_rightmost='\033[500C' LEFT_PROMPT="" RIGHT_PROMPT="" - SEGMENT_AT_LEFT=0 - SEGMENT_AT_RIGHT=0 RIGHT_PROMPT_LENGTH=0 - LAST_THEME_COLOR="" + SEGMENTS_AT_LEFT=0 + SEGMENTS_AT_RIGHT=0 + LAST_SEGMENT_COLOR="" ## left prompt ## - for segment in $THEME_LEFT_SEGMENTS; do - "powerline_${segment}_prompt" + for segment in $POWERLINE_LEFT_PROMPT; do + local info="$(__powerline_${segment}_prompt)" + [[ -n "${info}" ]] && __powerline_left_segment "${info}" done - [[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="$(set_rgb_color ${LAST_THEME_COLOR} -)${THEME_PROMPT_SEPARATOR}${normal}" + [[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="$(set_rgb_color ${LAST_SEGMENT_COLOR} -)${separator_char}${normal}" ## right prompt ## - if [[ -n "${THEME_RIGHT_SEGMENTS}" ]]; then - LEFT_PROMPT+="${MOVE_CURSOR_RIGHTMOST}" - for segment in $THEME_RIGHT_SEGMENTS; do - "powerline_${segment}_prompt" + if [[ -n "${POWERLINE_RIGHT_PROMPT}" ]]; then + LEFT_PROMPT+="${move_cursor_rightmost}" + for segment in $POWERLINE_RIGHT_PROMPT; do + local info="$(__powerline_${segment}_prompt)" + [[ -n "${info}" ]] && __powerline_right_segment "${info}" done LEFT_PROMPT+="\033[${RIGHT_PROMPT_LENGTH}D" fi - powerline_last_status_prompt LAST_STATUS + __powerline_last_status_prompt "${last_status}" PS1="${LEFT_PROMPT}${RIGHT_PROMPT}\n${LAST_STATUS_PROMPT}${PROMPT_CHAR} " + + ## cleanup ## + unset LAST_STATUS_PROMPT + unset LEFT_PROMPT + unset RIGHT_PROMPT + unset RIGHT_PROMPT_LENGTH + unset SEGMENTS_AT_LEFT + unset SEGMENTS_AT_RIGHT + unset LAST_SEGMENT_COLOR } -PROMPT_COMMAND=powerline_prompt_command +PROMPT_COMMAND=__powerline_prompt_command From 8bee21e428f702a4a91dfd3112f86bb8b2e1724d Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Wed, 27 Jan 2016 01:27:11 +0100 Subject: [PATCH 129/216] Update powerline-multiline README.md --- themes/powerline-multiline/README.md | 31 +++++++++++++--------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/themes/powerline-multiline/README.md b/themes/powerline-multiline/README.md index d0f6bfb8..80f07317 100644 --- a/themes/powerline-multiline/README.md +++ b/themes/powerline-multiline/README.md @@ -2,6 +2,8 @@ Colorfull multiline theme, the first line shows information about your shell session (divided into two parts, left and right), the second one is where the shell commands are introduced. +**IMPORTANT:** This theme has a requirement, [a font with the Powerline symbols](https://github.com/powerline/fonts) need tu be used in your terminal emulator, otherwise, the prompt won't be displayed correctly. + ## Information provided * Current path @@ -23,7 +25,7 @@ This theme is pretty configurable, all the configuration is done by setting envi By default, the username and hostname are shown at the right side, but you can change this behavior setting the value of the following variable: - THEME_PROMPT_USER_INFO_MODE + POWERLINE_PROMPT_USER_INFO_MODE for now, the only supported value is `sudo`, that hides the username and hostname, and shows an indicator when the sudo has the credentials cached. Any other value has no effect. @@ -31,33 +33,28 @@ for now, the only supported value is `sudo`, that hides the username and hostnam By default, the current time is shown at the right side, you can change the format with the variable: - THEME_PROMPT_CLOCK_FORMAT="%H:%M:%S" + POWERLINE_PROMPT_CLOCK_FORMAT="%H:%M:%S" the date is printed by the `date` command, so refer to its man page to change the format. ### Segment order -Both prompt sides can be "reordered", all the "segments" (every piece of information) can take any place, the only restriction (for now), is that some segments only can be placed at left, and others only at right. +Both prompt sides can be "reordered", all the "segments" (every piece of information) can take any place, the current available segments are: -Current available left "segments": - -* scm -* virtualenv -* rvm -* cwd - -Current available right "segments": - -* in_vim -* clock * battery +* clock +* cwd +* in_vim +* python_venv +* rvm +* scm * user_info Two variables can be defined to set the order of the prompt segments: - THEME_LEFT_SEGMENTS="scm virtualenv rvm cwd" - THEME_RIGHT_SEGMENTS="in_vim clock battery user_info" + POWERLINE_LEFT_PROMPT="scm python_venv rvm cwd" + POWERLINE_RIGHT_PROMPT="in_vim clock battery user_info" -if you want to remove something else from the prompt, simply remove the "string" that represents the segment from the corresponding variable. +the example values are the defaults, but if you want to remove something else from the prompt, simply remove the "string" that represents the segment from the corresponding variable. From ead5047fb964be4ca237bddf7f73bfde815af9fa Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Sat, 30 Jan 2016 11:33:00 +0100 Subject: [PATCH 130/216] Reduce unset calls --- .../powerline-multiline/powerline-multiline.theme.bash | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index edd7b82d..6915aaf2 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -236,13 +236,9 @@ function __powerline_prompt_command { PS1="${LEFT_PROMPT}${RIGHT_PROMPT}\n${LAST_STATUS_PROMPT}${PROMPT_CHAR} " ## cleanup ## - unset LAST_STATUS_PROMPT - unset LEFT_PROMPT - unset RIGHT_PROMPT - unset RIGHT_PROMPT_LENGTH - unset SEGMENTS_AT_LEFT - unset SEGMENTS_AT_RIGHT - unset LAST_SEGMENT_COLOR + unset LAST_STATUS_PROMPT LAST_SEGMENT_COLOR \ + LEFT_PROMPT RIGHT_PROMPT RIGHT_PROMPT_LENGTH \ + SEGMENTS_AT_LEFT SEGMENTS_AT_RIGHT } PROMPT_COMMAND=__powerline_prompt_command From f6436a878e037f33580acbedd6644c3bb8f7a658 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Sat, 30 Jan 2016 12:18:07 +0100 Subject: [PATCH 131/216] Fix some regressions and variables names --- .../powerline-multiline.theme.bash | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index 6915aaf2..210e309c 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -62,11 +62,11 @@ function __powerline_user_info_prompt { local color=${USER_INFO_THEME_PROMPT_COLOR} if sudo -n uptime 2>&1 | grep -q "load"; then - COLOR=${USER_INFO_THEME_PROMPT_COLOR_SUDO} + color=${USER_INFO_THEME_PROMPT_COLOR_SUDO} fi case "${POWERLINE_PROMPT_USER_INFO_MODE}" in "sudo") - if [[ "${COLOR}" == "${USER_INFO_THEME_PROMPT_COLOR_SUDO}" ]]; then + if [[ "${color}" == "${USER_INFO_THEME_PROMPT_COLOR_SUDO}" ]]; then user_info="!" fi ;; @@ -78,15 +78,15 @@ function __powerline_user_info_prompt { fi ;; esac - [[ -n "${user_info}" ]] && echo "${user_info}|${COLOR}" + [[ -n "${user_info}" ]] && echo "${user_info}|${color}" } function __powerline_rvm_prompt { - local RVM="" + local rvm="" if command_exists rvm; then - RVM="$(rvm_version_prompt)" - [[ -n "${RVM}" ]] && echo "${RVM}|${RVM_THEME_PROMPT_COLOR}" + rvm="$(rvm_version_prompt)" + [[ -n "${rvm}" ]] && echo "${RVM_CHAR}${rvm}|${RVM_THEME_PROMPT_COLOR}" fi } @@ -95,34 +95,34 @@ function __powerline_python_venv_prompt { if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then python_venv="${CONDA_DEFAULT_ENV}" - PYTHONV_VENV_CHAR=${CONDA_PYTHONVENV_CHAR} + PYTHON_VENV_CHAR=${CONDA_PYTHON_VENV_CHAR} elif [[ -n "${VIRTUAL_ENV}" ]]; then python_venv=$(basename "${VIRTUAL_ENV}") fi - [[ -n "${PYTHON_VENV}" ]] && echo "${python_venv}|${PYTHON_VENV_THEME_PROMPT_COLOR}" + [[ -n "${python_venv}" ]] && echo "${PYTHON_VENV_CHAR}${python_venv}|${PYTHON_VENV_THEME_PROMPT_COLOR}" } function __powerline_scm_prompt { local color="" - local SCM_PROMPT="" + local scm_prompt="" scm_prompt_vars if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]]; then if [[ "${SCM_DIRTY}" -eq 3 ]]; then - COLOR=${SCM_THEME_PROMPT_STAGED_COLOR} + color=${SCM_THEME_PROMPT_STAGED_COLOR} elif [[ "${SCM_DIRTY}" -eq 2 ]]; then - COLOR=${SCM_THEME_PROMPT_UNSTAGED_COLOR} + color=${SCM_THEME_PROMPT_UNSTAGED_COLOR} elif [[ "${SCM_DIRTY}" -eq 1 ]]; then - COLOR=${SCM_THEME_PROMPT_DIRTY_COLOR} + color=${SCM_THEME_PROMPT_DIRTY_COLOR} else - COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR} + color=${SCM_THEME_PROMPT_CLEAN_COLOR} fi if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then - SCM_PROMPT+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" + scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" fi - echo "${SCM_PROMPT}|${COLOR}" + echo "${scm_prompt}|${color}" fi } From 30c6fd1f59b3d4093babe46d446e9f03c55c70c1 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Sat, 30 Jan 2016 12:19:34 +0100 Subject: [PATCH 132/216] Refactor __powerline_last_status_prompt function --- .../powerline-multiline.theme.bash | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index 210e309c..beaf3048 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -160,11 +160,7 @@ function __powerline_in_vim_prompt { } function __powerline_last_status_prompt { - if [[ "$1" -eq 0 ]]; then - LAST_STATUS_PROMPT="" - else - LAST_STATUS_PROMPT="$(set_rgb_color ${LAST_STATUS_THEME_PROMPT_COLOR} -) ${1} ${normal}" - fi + [[ "$1" -ne 0 ]] && echo "$(set_rgb_color ${LAST_STATUS_THEME_PROMPT_COLOR} -) ${1} ${normal}" } function __powerline_left_segment { @@ -231,12 +227,10 @@ function __powerline_prompt_command { LEFT_PROMPT+="\033[${RIGHT_PROMPT_LENGTH}D" fi - __powerline_last_status_prompt "${last_status}" - - PS1="${LEFT_PROMPT}${RIGHT_PROMPT}\n${LAST_STATUS_PROMPT}${PROMPT_CHAR} " + PS1="${LEFT_PROMPT}${RIGHT_PROMPT}\n$(__powerline_last_status_prompt ${last_status})${PROMPT_CHAR} " ## cleanup ## - unset LAST_STATUS_PROMPT LAST_SEGMENT_COLOR \ + unset LAST_SEGMENT_COLOR \ LEFT_PROMPT RIGHT_PROMPT RIGHT_PROMPT_LENGTH \ SEGMENTS_AT_LEFT SEGMENTS_AT_RIGHT } From 5617cc2e31c9e1b6969419f4c109ee184a318d2d Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Mon, 1 Feb 2016 07:45:47 +0100 Subject: [PATCH 133/216] Fixed spelling and wording Some minor changes in spelling, wording and formatting. --- themes/powerline-multiline/README.md | 38 +++++++++++++--------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/themes/powerline-multiline/README.md b/themes/powerline-multiline/README.md index 80f07317..8f353ac6 100644 --- a/themes/powerline-multiline/README.md +++ b/themes/powerline-multiline/README.md @@ -1,45 +1,45 @@ # Powerline Multiline Theme -Colorfull multiline theme, the first line shows information about your shell session (divided into two parts, left and right), the second one is where the shell commands are introduced. +A colorful multiline theme, where the first line shows information about your shell session (divided into two parts, left and right), and the second one is where the shell commands are introduced. -**IMPORTANT:** This theme has a requirement, [a font with the Powerline symbols](https://github.com/powerline/fonts) need tu be used in your terminal emulator, otherwise, the prompt won't be displayed correctly. +**IMPORTANT:** This theme requires that [a font with the Powerline symbols](https://github.com/powerline/fonts) needs to be used in your terminal emulator, otherwise the prompt won't be displayed correctly, i.e. some of the additional icons and characters will be missing. Please follow your operating system's instructions to install one of the fonts from the above link and select it in your terminal emulator. -## Information provided +## Provided Information * Current path * Current username and hostname * An indicator when connected by SSH -* An indicator when sudo has the credentials cached (see the sudo manpage for more info about this) +* An indicator when `sudo` has the credentials cached (see the `sudo` manpage for more info about this) * An indicator when the current shell is inside the Vim editor -* Battery charging status (depends on the battery plugin) -* Repository status -* The current Python enviroment (Virtualenv, venv, and Conda are supported) in use -* The current Ruby enviroment (RVM) in use +* Battery charging status (depends on the [../../plugins/available/battery.plugin.bash](battery plugin)) +* SCM Repository status (e.g. Git, SVN) +* The current Python environment (Virtualenv, venv, and Conda are supported) in use +* The current Ruby environment (RVM) in use * Last command exit code (only shown when the exit code is greater than 0) ## Configuration This theme is pretty configurable, all the configuration is done by setting environment variables. -### User information +### User Information -By default, the username and hostname are shown at the right side, but you can change this behavior setting the value of the following variable: +By default, the username and hostname are shown on the right hand side, but you can change this behavior by setting the value of the following variable: - POWERLINE_PROMPT_USER_INFO_MODE + POWERLINE_PROMPT_USER_INFO_MODE="sudo" -for now, the only supported value is `sudo`, that hides the username and hostname, and shows an indicator when the sudo has the credentials cached. Any other value has no effect. +For now, the only supported value is `sudo`, which hides the username and hostname, and shows an indicator when `sudo` has the credentials cached. Other values have no effect at this time. -### Clock format +### Clock Format -By default, the current time is shown at the right side, you can change the format with the variable: +By default, the current time is shown on the right hand side, you can change the format using the following variable: POWERLINE_PROMPT_CLOCK_FORMAT="%H:%M:%S" -the date is printed by the `date` command, so refer to its man page to change the format. +The time/date is printed by the `date` command, so refer to its man page to change the format. -### Segment order +### Segment Order -Both prompt sides can be "reordered", all the "segments" (every piece of information) can take any place, the current available segments are: +The contents of both prompt sides can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are: * battery * clock @@ -55,6 +55,4 @@ Two variables can be defined to set the order of the prompt segments: POWERLINE_LEFT_PROMPT="scm python_venv rvm cwd" POWERLINE_RIGHT_PROMPT="in_vim clock battery user_info" -the example values are the defaults, but if you want to remove something else from the prompt, simply remove the "string" that represents the segment from the corresponding variable. - - +The example values above are the current default values, but if you want to remove anything from the prompt, simply remove the "string" that represents the segment from the corresponding variable. From c290aa9638f8cc7b0aa58017576ba67c125cc5d3 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Wed, 3 Feb 2016 22:58:19 +0100 Subject: [PATCH 134/216] Fix an error when showing the status of a git repo --- themes/base.theme.bash | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index ee906dee..fffe4b7b 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -94,6 +94,11 @@ function scm_prompt_info { function git_status_summary { awk ' + BEGIN { + untracked=0; + unstaged=0; + staged=0; + } { if (!after_first && $0 ~ /^##.+/) { print $0 From f05c56a4409c6177cf7677928e20c77f1544e971 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Wed, 3 Feb 2016 23:03:07 +0100 Subject: [PATCH 135/216] Set fallback values to POWERLINE_LEFT_PROMPT and POWERLINE_RIGHT_PROMPT variables --- themes/powerline-multiline/powerline-multiline.theme.bash | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index beaf3048..0978e3d0 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -42,9 +42,8 @@ THEME_PROMPT_CLOCK_FORMAT=${POWERLINE_PROMPT_CLOCK_FORMAT:="%H:%M:%S"} IN_VIM_THEME_PROMPT_COLOR=245 IN_VIM_THEME_PROMPT_TEXT="vim" -POWERLINE_LEFT_PROMPT="scm python_venv rvm cwd" -POWERLINE_RIGHT_PROMPT="in_vim clock battery user_info" - +POWERLINE_LEFT_PROMPT=${POWERLINE_LEFT_PROMPT:="scm python_venv rvm cwd"} +POWERLINE_RIGHT_PROMPT=${POWERLINE_RIGHT_PROMPT:="in_vim clock battery user_info"} function set_rgb_color { if [[ "${1}" != "-" ]]; then From 304406b503601be7407f3218bcc87104146e96e3 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Thu, 4 Feb 2016 00:11:59 +0100 Subject: [PATCH 136/216] Remove unnecessary double quotes in alias --- aliases/available/emacs.aliases.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aliases/available/emacs.aliases.bash b/aliases/available/emacs.aliases.bash index 1116b117..f8e1259b 100644 --- a/aliases/available/emacs.aliases.bash +++ b/aliases/available/emacs.aliases.bash @@ -8,7 +8,7 @@ case $OSTYPE in alias e='emacsclient -n' alias et='emacsclient -t' alias ed='emacs --daemon' - alias E='SUDO_EDITOR="emacsclient" sudo -e' + alias E='SUDO_EDITOR=emacsclient sudo -e' ;; darwin*) alias em='open -a emacs' From 14f880202c27b2d318259820dc39aa96e7e35c86 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Thu, 4 Feb 2016 22:40:08 +0100 Subject: [PATCH 137/216] Updated README --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a7bf87ed..e1a9d336 100644 --- a/README.md +++ b/README.md @@ -49,9 +49,11 @@ Anything in the custom directory will be ignored, with the exception of `custom/ There are a few bash it themes. If you've created your own custom prompts, I'd love it if you shared with everyone else! Just submit a Pull Request. -You can see the theme screenshots [here](https://github.com/Bash-it/bash-it/wiki/Themes) +You can see the theme screenshots [here](https://github.com/Bash-it/bash-it/wiki/Themes). -Alternatively, you can preview the themes in your own shell using `BASH_PREVIEW=true reload` +Alternatively, you can preview the themes in your own shell using `BASH_PREVIEW=true reload`. + +**NOTE**: Bash it and some themes use UTF-8 characters, so to avoid extrange behaviors in your terminal, set your locale to `LC_ALL=en_US.UTF-8` or the equivalent to your language if isn't American English. ## Uninstalling From 3438c1d7c4c50458b09a39525d66b57be5320802 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Fri, 5 Feb 2016 00:13:41 +0100 Subject: [PATCH 138/216] New update command --- lib/helpers.bash | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/lib/helpers.bash b/lib/helpers.bash index ae295a7c..28b21b98 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -32,13 +32,14 @@ function reload_plugins() { bash-it () { about 'bash-it help and maintenance' - param '1: verb [one of: help | show | enable | disable ]' + param '1: verb [one of: help | show | enable | disable | update ] ' param '2: component type [one of: alias(es) | completion(s) | plugin(s) ]' param '3: specific component [optional]' example '$ bash-it show plugins' example '$ bash-it help aliases' example '$ bash-it enable plugin git [tmux]...' example '$ bash-it disable alias hg [tmux]...' + example '$ bash-it update' typeset verb=${1:-} shift typeset component=${1:-} @@ -53,6 +54,8 @@ bash-it () func=_disable-$component;; help) func=_help-$component;; + update) + func=_bash-it_update;; *) reference bash-it return;; @@ -115,6 +118,27 @@ _bash-it-plugins () _bash-it-describe "plugins" "a" "plugin" "Plugin" } +_bash-it_update() { + _about 'updates Bash it' + _group 'lib' + + cd "${$BASH_IT}" + git fetch &> /dev/null + local status="$(git rev-list master..origin/master 2> /dev/null)" + if [[ -n "${status}" ]]; then + git pull --rebase &> /dev/null + if [[ $? -eq 0 ]]; then + echo "Bash it successfully updated, enjoy!" + reload + else + echo "Error updating Bash it, please, check if your Bash it installation folder (${BASH_IT}) is clean." + fi + else + echo "Bash it is up to date, nothing to do!" + fi + cd - &> /dev/null +} + _bash-it-describe () { _about 'summarizes available bash_it components' @@ -355,6 +379,13 @@ _help-plugins() rm $grouplist 2> /dev/null } +_help-update () { + _about 'help message for update command' + _group 'lib' + + echo "Check for a new version of Bash it and update it." +} + all_groups () { about 'displays all unique metadata groups' From 6a571b4826509b07b93169296f4829459b14e76a Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Fri, 5 Feb 2016 00:16:20 +0100 Subject: [PATCH 139/216] Update README.md --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index e1a9d336..32ac41b0 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,16 @@ The install script can take the following options: When run without the `--interactive` switch, Bash it only enables a sane default set of functionality to keep your shell lean and to avoid issues with missing dependencies. Feel free to enable the tools you want to use after the installation. +## Update + +To update Bash it, simply run: + +``` +bash-it update +``` + +that's all. + ## Help Screens ``` From 1dba074024a55eb0b55e4a024d649150fd6782e8 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Fri, 5 Feb 2016 18:47:57 +0100 Subject: [PATCH 140/216] Fix variable syntax error --- lib/helpers.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/helpers.bash b/lib/helpers.bash index 28b21b98..30881b45 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -122,7 +122,7 @@ _bash-it_update() { _about 'updates Bash it' _group 'lib' - cd "${$BASH_IT}" + cd "${BASH_IT}" git fetch &> /dev/null local status="$(git rev-list master..origin/master 2> /dev/null)" if [[ -n "${status}" ]]; then From 5c6de8ca672bcdd7749e710127ed1c8d754cd58f Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Fri, 5 Feb 2016 18:48:32 +0100 Subject: [PATCH 141/216] Add new udpate command to Bash it completion --- completion/available/bash-it.completion.bash | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/completion/available/bash-it.completion.bash b/completion/available/bash-it.completion.bash index 43a26a64..f4eddc20 100644 --- a/completion/available/bash-it.completion.bash +++ b/completion/available/bash-it.completion.bash @@ -53,7 +53,7 @@ _bash-it-comp() prev="${COMP_WORDS[COMP_CWORD-1]}" chose_opt="${COMP_WORDS[1]}" file_type="${COMP_WORDS[2]}" - opts="help show enable disable" + opts="help show enable disable update" case "${chose_opt}" in show) local show_args="plugins aliases completions" @@ -61,10 +61,13 @@ _bash-it-comp() return 0 ;; help) - local help_args="plugins aliases completions" + local help_args="plugins aliases completions update" COMPREPLY=( $(compgen -W "${help_args}" -- ${cur}) ) return 0 ;; + update) + return 0 + ;; enable | disable) if [ x"${chose_opt}" == x"enable" ];then suffix="available-not-enabled" From 0c55ed892ce0399424d7be80673aef3d1a7cdbd5 Mon Sep 17 00:00:00 2001 From: Frank Becker Date: Sat, 6 Feb 2016 12:05:51 +0100 Subject: [PATCH 142/216] fixed version completion for sdkman 3.3.2 --- completion/available/sdkman.completion.bash | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/completion/available/sdkman.completion.bash b/completion/available/sdkman.completion.bash index 2bf217bb..95545b87 100644 --- a/completion/available/sdkman.completion.bash +++ b/completion/available/sdkman.completion.bash @@ -4,7 +4,7 @@ _sdkman_complete() local CANDIDATE_VERSIONS COMPREPLY=() - + if [ $COMP_CWORD -eq 1 ]; then COMPREPLY=( $(compgen -W "install uninstall rm list ls use current outdated version default selfupdate broadcast offline help flush" -- ${COMP_WORDS[COMP_CWORD]}) ) elif [ $COMP_CWORD -eq 2 ]; then @@ -35,15 +35,14 @@ _sdkman_complete() ;; esac fi - + return 0 } _sdkman_candidate_versions(){ - CANDIDATE_LOCAL_VERSIONS=$(__sdkman_cleanup_local_versions $1) - if _sdkman_offline; then + if [ "$SDKMAN_OFFLINE_MODE" = "true" ]; then CANDIDATE_VERSIONS=$CANDIDATE_LOCAL_VERSIONS else CANDIDATE_ONLINE_VERSIONS="$(curl -s "${SDKMAN_SERVICE}/candidates/$1" | tr ',' ' ')" @@ -53,19 +52,10 @@ _sdkman_candidate_versions(){ } __sdkman_cleanup_local_versions(){ - - __sdkmantool_build_version_csv $1 + + __sdkman_build_version_csv $1 echo $CSV | tr ',' ' ' } -_sdkman_offline() -{ - if [ "$SDKMAN_ONLINE" = "true" ]; then - return 1 - else - return 0 - fi -} - complete -F _sdkman_complete sdk From ba5e7c9268ab1ed67d57e9eac48ce351b7dbde7a Mon Sep 17 00:00:00 2001 From: Robert Rauch Date: Sat, 6 Feb 2016 21:19:30 +0100 Subject: [PATCH 143/216] Speed up $PROMPT_COMMAND by using rvm-prompt Running `rvm tools identifier` seems to be really slow. Using [`rvm-prompt`](https://rvm.io/workflow/prompt) greatly speeds up the evaluation of `$PROMPT_COMMAND`. --- themes/base.theme.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index fffe4b7b..993e1922 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -268,8 +268,8 @@ function hg_prompt_vars { function rvm_version_prompt { if which rvm &> /dev/null; then - rvm=$(rvm tools identifier) || return - if [ $rvm != "system" ]; then + rvm=$(rvm-prompt) || return + if [ -n "$rvm" ]; then echo -e "$RVM_THEME_PROMPT_PREFIX$rvm$RVM_THEME_PROMPT_SUFFIX" fi fi From 48f26406f00dbe9a25b3e89d5f7157170c2bef40 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Tue, 9 Feb 2016 22:49:08 +0100 Subject: [PATCH 144/216] Apply new naming convention --- README.md | 54 ++++++++++++++++++++++++------------------------ lib/helpers.bash | 12 +++++------ 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 32ac41b0..6c455996 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,18 @@ -# Bash it +# Bash-it [![Build Status](https://travis-ci.org/Bash-it/bash-it.svg?branch=master)](https://travis-ci.org/Bash-it/bash-it) [![Join the chat at https://gitter.im/Bash-it/bash-it](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Bash-it/bash-it?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -**Bash it** is a collection of community bash commands and scripts. (And a shameless ripoff of [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) :smiley:) +**Bash-it** is a collection of community Bash commands and scripts. (And a shameless ripoff of [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) :smiley:) Includes autocompletion, themes, aliases, custom functions, a few stolen pieces from Steve Losh, and more. -Bash it provides a solid framework for using, developing and maintaining shell scripts and custom commands for your daily work. If you're using the _Bourne Again Shell_ (Bash) on a regular basis and have been looking for an easy way on how to keep all of these nice little scripts and aliases under control, then Bash it is for you! Stop polluting your `~/bin` directory and your `.bashrc` file, fork/clone Bash it and start hacking away. +Bash-it provides a solid framework for using, developing and maintaining shell scripts and custom commands for your daily work. If you're using the _Bourne Again Shell_ (Bash) on a regular basis and have been looking for an easy way on how to keep all of these nice little scripts and aliases under control, then Bash-it is for you! Stop polluting your `~/bin` directory and your `.bashrc` file, fork/clone Bash-it and start hacking away. ## Install 1. Check out a clone of this repo to a location of your choice, such as: `git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it` 2. Run `~/.bash_it/install.sh` (it automatically backs up your `~/.bash_profile` or `~/.bashrc`, depending on your OS) -3. Edit your modified config (`~/.bash_profile` or `~/.bashrc`) file in order to customize Bash it. +3. Edit your modified config (`~/.bash_profile` or `~/.bashrc`) file in order to customize Bash-it. 4. Check out available aliases, completions and plugins and enable the ones you want to use (see the next section for more details). **INSTALL OPTIONS:** @@ -20,11 +20,11 @@ The install script can take the following options: * `--interactive`: Asks the user which aliases, completions and plugins to enable. -When run without the `--interactive` switch, Bash it only enables a sane default set of functionality to keep your shell lean and to avoid issues with missing dependencies. Feel free to enable the tools you want to use after the installation. +When run without the `--interactive` switch, Bash-it only enables a sane default set of functionality to keep your shell lean and to avoid issues with missing dependencies. Feel free to enable the tools you want to use after the installation. ## Update -To update Bash it, simply run: +To update Bash-it, simply run: ``` bash-it update @@ -57,24 +57,24 @@ Anything in the custom directory will be ignored, with the exception of `custom/ ## Themes -There are a few bash it themes. If you've created your own custom prompts, I'd love it if you shared with everyone else! Just submit a Pull Request. +There are a few Bash-it themes. If you've created your own custom prompts, I'd love it if you shared with everyone else! Just submit a Pull Request. You can see the theme screenshots [here](https://github.com/Bash-it/bash-it/wiki/Themes). Alternatively, you can preview the themes in your own shell using `BASH_PREVIEW=true reload`. -**NOTE**: Bash it and some themes use UTF-8 characters, so to avoid extrange behaviors in your terminal, set your locale to `LC_ALL=en_US.UTF-8` or the equivalent to your language if isn't American English. +**NOTE**: Bash-it and some themes use UTF-8 characters, so to avoid extrange behaviors in your terminal, set your locale to `LC_ALL=en_US.UTF-8` or the equivalent to your language if isn't American English. ## Uninstalling -To uninstall Bash it, run the `uninstall.sh` script found in the `$BASH_IT` directory: +To uninstall Bash-it, run the `uninstall.sh` script found in the `$BASH_IT` directory: ``` cd $BASH_IT ./uninstall.sh ``` -This will restore your previous Bash profile. After the uninstall script finishes, remove the Bash it directory from your machine (`rm -rf $BASH_IT`) and start a new shell. +This will restore your previous Bash profile. After the uninstall script finishes, remove the Bash-it directory from your machine (`rm -rf $BASH_IT`) and start a new shell. ## Contributing @@ -84,14 +84,14 @@ Please take a look at the [Contribution Guidelines](CONTRIBUTING.md) before repo ### Bash Profile Aliases -Bash it creates a `reload` alias that makes it convenient to reload -your bash profile when you make changes. +Bash-it creates a `reload` alias that makes it convenient to reload +your Bash profile when you make changes. ### Prompt Version Control Check -Bash it provides prompt themes the ability to check and display version control information for the current directory. The information is retrieved for each directory and can slow down the navigation of projects with a large number of files and folders. Turn version control checking off to prevent slow directory navigation within large projects. +Bash-it provides prompt themes the ability to check and display version control information for the current directory. The information is retrieved for each directory and can slow down the navigation of projects with a large number of files and folders. Turn version control checking off to prevent slow directory navigation within large projects. -Bash it provides a flag (`SCM_CHECK`) within the `~/.bash_profile` file that turns off/on version control information checking and display within all themes. Version control checking is on by default unless explicitly turned off. +Bash-it provides a flag (`SCM_CHECK`) within the `~/.bash_profile` file that turns off/on version control information checking and display within all themes. Version control checking is on by default unless explicitly turned off. Set `SCM_CHECK` to 'false' to **turn off** version control checks for all themes: @@ -106,11 +106,11 @@ It is possible for themes to ignore the `SCM_CHECK` flag and query specific vers ### Git prompt -Bash it has some nice features related to Git, continue reading to know more about these features. +Bash-it has some nice features related to Git, continue reading to know more about these features. #### Repository info in the prompt -Bash it can show some information about Git repositories in the shell prompt: the current branch, tag or commit you are at, how many commits the local branch is ahead or behind from the remote branch, and if you have changes stashed. +Bash-it can show some information about Git repositories in the shell prompt: the current branch, tag or commit you are at, how many commits the local branch is ahead or behind from the remote branch, and if you have changes stashed. Additionally, you can view the status of your working copy and get the count of *staged*, *unstaged* and *untracked* files. This feature is controlled through the flag `SCM_GIT_SHOW_DETAILS` as follows: @@ -124,7 +124,7 @@ Set `SCM_GIT_SHOW_DETAILS` to 'false' to **don't show** it: #### Remotes and remote branches -In some git workflows you must work with various remotes, for this reason, Bash it can provide some useful information about your remotes and your remote branches, for example, the remote on you are working, or if your local branch is tracking a remote branch. +In some git workflows you must work with various remotes, for this reason, Bash-it can provide some useful information about your remotes and your remote branches, for example, the remote on you are working, or if your local branch is tracking a remote branch. You can control this feature with the flag `SCM_GIT_SHOW_REMOTE_INFO` as follows: @@ -142,7 +142,7 @@ Set `SCM_GIT_SHOW_REMOTE_INFO` to 'false' to **disable the feature**: #### Untracked files -By default, `git status` command shows information about *untracked* files, this behavior can be controlled through command line flags or git configuration files, for big repositories, ignoring *untracked* files can make git faster. Bash it uses `git status` to gather the repo information it shows in the prompt, so in some circumstances, can be useful to instruct Bash it to ignore these files. You can control this behavior with the flag `SCM_GIT_IGNORE_UNTRACKED`: +By default, `git status` command shows information about *untracked* files, this behavior can be controlled through command line flags or git configuration files, for big repositories, ignoring *untracked* files can make git faster. Bash-it uses `git status` to gather the repo information it shows in the prompt, so in some circumstances, can be useful to instruct Bash-it to ignore these files. You can control this behavior with the flag `SCM_GIT_IGNORE_UNTRACKED`: Set `SCM_GIT_IGNORE_UNTRACKED` to 'false' (the default value) to get information about *untracked* files: @@ -152,13 +152,13 @@ Set `SCM_GIT_IGNORE_UNTRACKED` to 'true' to **ignore** *untracked* files: * `export SCM_GIT_IGNORE_UNTRACKED=true` -also, with this flag to false, Bash it will not show the repository as dirty when the repo have *untracked* files, and will not display the count of *untracked* files. +also, with this flag to false, Bash-it will not show the repository as dirty when the repo have *untracked* files, and will not display the count of *untracked* files. -**NOTE:** If you set in git configuration file the option to ignore *untracked* files, this flag has no effect, and Bash it will ignore *untracked* files always. +**NOTE:** If you set in git configuration file the option to ignore *untracked* files, this flag has no effect, and Bash-it will ignore *untracked* files always. #### Ignore repo status -When working in repos with a large code base Bash it can slow down your prompt when checking the repo status, to avoid it, there is an option you can set via Git config to disable checking repo status in Bash it. +When working in repos with a large code base Bash-it can slow down your prompt when checking the repo status, to avoid it, there is an option you can set via Git config to disable checking repo status in Bash-it. To disable checking the status in the current repo: @@ -176,15 +176,15 @@ setting this flag globally has the same effect that `SCM_CHECK=true` but only fo ### pass function renamed to passgen -The Bash it `pass` function has been renamed to `passgen` in order to avoid a naming conflict with the [pass password manager]. In order to minimize the impact on users of the legacy Bash it `pass` function, Bash it will create the alias `pass` that calls the new `passgen` function if the `pass` password manager command is not found on the `PATH` (default behavior). +The Bash-it `pass` function has been renamed to `passgen` in order to avoid a naming conflict with the [pass password manager]. In order to minimize the impact on users of the legacy Bash-it `pass` function, Bash-it will create the alias `pass` that calls the new `passgen` function if the `pass` password manager command is not found on the `PATH` (default behavior). This behavior can be overridden with the `BASH_IT_LEGACY_PASS` flag as follows: -Set `BASH_IT_LEGACY_PASS` to 'true' to force Bash it to always **create** the `pass` alias to `passgen`: +Set `BASH_IT_LEGACY_PASS` to 'true' to force Bash-it to always **create** the `pass` alias to `passgen`: * `export BASH_IT_LEGACY_PASS=true` -Unset `BASH_IT_LEGACY_PASS` to have Bash it **return to default behavior**: +Unset `BASH_IT_LEGACY_PASS` to have Bash-it **return to default behavior**: * `unset BASH_IT_LEGACY_PASS` @@ -199,13 +199,13 @@ The Bash shell (and many shell tools) use the following variables to define the * `ALL_PROXY` (and `all_proxy`): Used by some tools for the same purpose as above * `NO_PROXY` (and `no_proxy`): Comma-separated list of hostnames that don't have to go through the proxy -Bash it's `proxy` plugin allows to enable and disable these variables with a simple command. To start using the `proxy` plugin, run the following: +Bash-it's `proxy` plugin allows to enable and disable these variables with a simple command. To start using the `proxy` plugin, run the following: ```bash bash-it enable plugin proxy ``` -Bash it also provides support for enabling/disabling proxy settings for various shell tools. The following backends are currently supported (in addition to the shell's environment variables): Git, SVN, npm, ssh. The `proxy` plugin changes the configuration files of these tools to enable or disable the proxy settings. +Bash-it also provides support for enabling/disabling proxy settings for various shell tools. The following backends are currently supported (in addition to the shell's environment variables): Git, SVN, npm, ssh. The `proxy` plugin changes the configuration files of these tools to enable or disable the proxy settings. Bash-it uses the following variables to set the shell's proxy settings when you call `enable-proxy`. These variables are best defined in a custom script in Bash-it's custom script folder (`$BASH_IT/custom`), e.g. `$BASH_IT/custom/proxy.env.bash` @@ -221,7 +221,7 @@ There are many more proxy commands, e.g. for changing the local Git project's pr ## Help out -We think everyone has their own custom scripts accumulated over time. And so, following in the footsteps of oh-my-zsh, Bash it is a framework for easily customizing your bash shell. Everyone's got a custom toolbox, so let's start making them even better, **as a community!** +We think everyone has their own custom scripts accumulated over time. And so, following in the footsteps of oh-my-zsh, Bash-it is a framework for easily customizing your Bash shell. Everyone's got a custom toolbox, so let's start making them even better, **as a community!** Send us a pull request and we'll merge it as long as it looks good. If you change an existing command, please give an explanation why. That will help a lot when we merge your changes in. diff --git a/lib/helpers.bash b/lib/helpers.bash index 30881b45..e3d0ef0d 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -31,7 +31,7 @@ function reload_plugins() { bash-it () { - about 'bash-it help and maintenance' + about 'Bash-it help and maintenance' param '1: verb [one of: help | show | enable | disable | update ] ' param '2: component type [one of: alias(es) | completion(s) | plugin(s) ]' param '3: specific component [optional]' @@ -119,7 +119,7 @@ _bash-it-plugins () } _bash-it_update() { - _about 'updates Bash it' + _about 'updates Bash-it' _group 'lib' cd "${BASH_IT}" @@ -128,13 +128,13 @@ _bash-it_update() { if [[ -n "${status}" ]]; then git pull --rebase &> /dev/null if [[ $? -eq 0 ]]; then - echo "Bash it successfully updated, enjoy!" + echo "Bash-it successfully updated, enjoy!" reload else - echo "Error updating Bash it, please, check if your Bash it installation folder (${BASH_IT}) is clean." + echo "Error updating Bash-it, please, check if your Bash-it installation folder (${BASH_IT}) is clean." fi else - echo "Bash it is up to date, nothing to do!" + echo "Bash-it is up to date, nothing to do!" fi cd - &> /dev/null } @@ -383,7 +383,7 @@ _help-update () { _about 'help message for update command' _group 'lib' - echo "Check for a new version of Bash it and update it." + echo "Check for a new version of Bash-it and update it." } all_groups () From 3bce1782e74ad3c8b13c446dfa7387f6f2924809 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Fri, 12 Feb 2016 01:13:03 +0100 Subject: [PATCH 145/216] Update README.md --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6c455996..22698f04 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,17 @@ The install script can take the following options: * `--interactive`: Asks the user which aliases, completions and plugins to enable. -When run without the `--interactive` switch, Bash-it only enables a sane default set of functionality to keep your shell lean and to avoid issues with missing dependencies. Feel free to enable the tools you want to use after the installation. +When run without the `--interactive` switch, Bash-it only enables a sane default set of functionality to keep your shell clean and to avoid issues with missing dependencies. Feel free to enable the tools you want to use after the installation. + +**NOTE**: Keep in mind how Bash load its configuration files, `.bash_profile` for login shells (and in Mac OS X in terminal emulators like [Termminal.app](http://www.apple.com/osx/apps/) or [iTerm2](https://www.iterm2.com/)) and `.bashrc` for interactive shells (default mode in most of the GNU/Linux terminal emulators), to ensure that Bash-it is loaded correctly. A good "practice" is sourcing `.bashrc` into `.bash_profile` to keep things working in all the scenarios, to achieve this, you can add this snippet in your `.bash_profile`: + +``` +if [ -f ~/.bashrc ]; then + . ~/.bashrc +fi +``` + +Refer to the official [Bash documention](https://www.gnu.org/software/bash/manual/bashref.html#Bash-Startup-Files) to get more info. ## Update From c34cd9b7ec41d3ffbd784d35637c0e2f11f9f481 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Fri, 12 Feb 2016 01:29:40 +0100 Subject: [PATCH 146/216] Update some git aliases --- aliases/available/git.aliases.bash | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/aliases/available/git.aliases.bash b/aliases/available/git.aliases.bash index aeab208f..2b8dc7c8 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -5,8 +5,10 @@ about-alias 'common git abbreviations' alias gcl='git clone' alias ga='git add' alias gall='git add -A' -alias gf='git fetch --all --prune --verbose' -alias gft='git fetch --all --prune --tags --verbose' +alias gf='git fetch --all --prune' +alias gft='git fetch --all --prune --tags' +alias gfv='git fetch --all --prune --verbose' +alias gftv='git fetch --all --prune --tags --verbose' alias gus='git reset HEAD' alias gm="git merge" alias g='git' @@ -40,7 +42,7 @@ alias gexport='git archive --format zip --output' alias gdel='git branch -D' alias gmu='git fetch origin -v; git fetch upstream -v; git merge upstream/master' alias gll='git log --graph --pretty=oneline --abbrev-commit' -alias gg="git log --graph --pretty=format:'%C(bold)%h%Creset%C(yellow)%d%Creset %s %C(yellow)%an %C(cyan)%cr%Creset' --abbrev-commit --date=relative" +alias gg="git log --graph --pretty=format:'%C(bold)%h%Creset%C(magenta)%d%Creset %s %C(yellow)<%an> %C(cyan)(%cr)%Creset' --abbrev-commit --date=relative" alias ggs="gg --stat" alias gsl="git shortlog -sn" alias gw="git whatchanged" From 85e7e408aa820a533bbc8c187d33f6812f23846a Mon Sep 17 00:00:00 2001 From: cornfeedhobo Date: Fri, 12 Feb 2016 09:05:22 -0600 Subject: [PATCH 147/216] added menu and error messages to projects plugin. indentation cleanup to conform to editorconfig. --- completion/available/projects.completion.bash | 49 +++++------ plugins/available/projects.plugin.bash | 82 ++++++++++++++----- 2 files changed, 88 insertions(+), 43 deletions(-) diff --git a/completion/available/projects.completion.bash b/completion/available/projects.completion.bash index a46864b7..71d740cd 100644 --- a/completion/available/projects.completion.bash +++ b/completion/available/projects.completion.bash @@ -1,38 +1,39 @@ _pj() { - [ -z "$PROJECT_PATHS" ] && return - shift - [ "$1" == "open" ] && shift + [ -z "$PROJECT_PATHS" ] && return + shift + [ "$1" == "open" ] && shift - local cur prev words cword - _init_completion || return + local cur prev words cword + _init_completion || return - local IFS=$'\n' i j k + local IFS=$'\n' i j k - compopt -o filenames + compopt -o filenames - local -r mark_dirs=$(_rl_enabled mark-directories && echo y) - local -r mark_symdirs=$(_rl_enabled mark-symlinked-directories && echo y) + local -r mark_dirs=$(_rl_enabled mark-directories && echo y) + local -r mark_symdirs=$(_rl_enabled mark-symlinked-directories && echo y) - for i in ${PROJECT_PATHS//:/$'\n'}; do - # create an array of matched subdirs - k="${#COMPREPLY[@]}" - for j in $( compgen -d $i/$cur ); do - if [[ ( $mark_symdirs && -h $j || $mark_dirs && ! -h $j ) && ! -d ${j#$i/} ]]; then - j+="/" - fi - COMPREPLY[k++]=${j#$i/} - done + for i in ${PROJECT_PATHS//:/$'\n'}; do + # create an array of matched subdirs + k="${#COMPREPLY[@]}" + for j in $( compgen -d $i/$cur ); do + if [[ ( $mark_symdirs && -h $j || $mark_dirs && ! -h $j ) && ! -d ${j#$i/} ]]; then + j+="/" + fi + COMPREPLY[k++]=${j#$i/} done + done - if [[ ${#COMPREPLY[@]} -eq 1 ]]; then - i=${COMPREPLY[0]} - if [[ "$i" == "$cur" && $i != "*/" ]]; then - COMPREPLY[0]="${i}/" - fi + if [[ ${#COMPREPLY[@]} -eq 1 ]]; then + i=${COMPREPLY[0]} + if [[ "$i" == "$cur" && $i != "*/" ]]; then + COMPREPLY[0]="${i}/" fi + fi - return 0 + return 0 } complete -F _pj -o nospace pj +complete -F _pj -o nospace pjo diff --git a/plugins/available/projects.plugin.bash b/plugins/available/projects.plugin.bash index 6e4926ca..e4dc39e2 100644 --- a/plugins/available/projects.plugin.bash +++ b/plugins/available/projects.plugin.bash @@ -2,30 +2,74 @@ cite about-plugin about-plugin 'add "export PROJECT_PATHS=~/projects:~/intertrode/projects" to navigate quickly to your project directories with `pj` and `pjo`' function pj { - about 'navigate quickly to your various project directories' - group 'projects' +about 'navigate quickly to your various project directories' +group 'projects' - if [ -n "$PROJECT_PATHS" ]; then - local cmd - if [ "$1" == "open" ]; then - shift - cmd="$EDITOR" - fi +if [ -z "$PROJECT_PATHS" ]; then + echo "error: PROJECT_PATHS not set" + return 1 +fi - cmd="${cmd:-cd}" - if [ -n "$1" ]; then - for i in ${PROJECT_PATHS//:/$'\n'}; do - if [ -d "$i"/"$1" ]; then - $cmd "$i"/"$1" - return - fi - done - fi - fi +local cmd +local dest +local -a dests - echo "No such project '$1'" + +if [ "$1" == "open" ]; then + shift + cmd="$EDITOR" +fi +cmd="${cmd:-cd}" + + +if [ -z "$1" ]; then + echo "error: no project provided" + return 1 +fi + + +# collect possible destinations to account for directories +# with the same name in project directories +for i in ${PROJECT_PATHS//:/$'\n'}; do + if [ -d "$i"/"$1" ]; then + dests+=("$i/$1") + fi +done + + +# when multiple destinations are found, present a menu +if [ ${#dests[@]} -eq 0 ]; then + echo "error: no such project '$1'" + return 1 + +elif [ ${#dests[@]} -eq 1 ]; then + dest="${dests[0]}" + +elif [ ${#dests[@]} -gt 1 ]; then + PS3="Multiple project directories found. Please select one: " + dests+=("cancel") + select d in "${dests[@]}"; do + case $d in + "cancel") + return + ;; + *) + dest=$d + break + ;; + esac + done + +else + echo "error: please report this error" + return 1 # should never reach this + +fi + + +$cmd "$dest" } alias pjo="pj open" From 35c2be1e964b74ad64cfd09f2335f3b18a6de88b Mon Sep 17 00:00:00 2001 From: Joan Leon Date: Tue, 16 Feb 2016 16:35:57 +0100 Subject: [PATCH 148/216] Added npm aliases --- aliases/available/npm.aliases.bash | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 aliases/available/npm.aliases.bash diff --git a/aliases/available/npm.aliases.bash b/aliases/available/npm.aliases.bash new file mode 100644 index 00000000..b01241e7 --- /dev/null +++ b/aliases/available/npm.aliases.bash @@ -0,0 +1,22 @@ +cite 'about-alias' +about-alias 'common npm abbreviations' + +# Aliases +alias ni='npm install' +alias nis='npm install --save' +alias nid='npm install --save-dev' +alias nit='npm install-test' +alias nits='npm install-test --save' +alias nitd='npm install-test --save-dev' +alias nu='npm uninstall' +alias nus='npm uninstall --save' +alias nud='npm uninstall --save-dev' +alias np='npm publish' +alias nup='npm unpublish' +alias nlk='npm link' +alias nod='npm outdated' +alias nrb='npm rebuild' +alias nud='npm update' +alias nr='npm run' +alias nls='npm list' +alias nlsg='npm list --global' From 2911f88cf2b76623ad2fe6305403c9355408e75e Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Fri, 19 Feb 2016 00:35:45 +0100 Subject: [PATCH 149/216] Use the same parsing_command for OSX and Linux --- completion/available/gradle.completion.bash | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/completion/available/gradle.completion.bash b/completion/available/gradle.completion.bash index 03fcc741..2f55cade 100644 --- a/completion/available/gradle.completion.bash +++ b/completion/available/gradle.completion.bash @@ -6,13 +6,12 @@ function __gradle { case $OSTYPE in darwin*) local checksum_command="find . -name build.gradle -print0 | xargs -0 md5 -q | md5 -q" - local parsing_command="gradle --console=plain --quiet tasks | grep -v Rules | sed -nE -e 's/^([a-zA-Z]+)($| - .+)/\1/p'" ;; *) local checksum_command="find . -name build.gradle -print0 | xargs -0 md5sum | md5sum | cut -d ' ' -f 1" - local parsing_command="gradle --console=plain --quiet tasks | grep -v Rules | sed -nr -e 's/^([a-zA-Z]+)($| - .+)/\1/p'" ;; esac + local parsing_command="gradle --console=plain --quiet tasks | grep -v Rules | sed -nE -e 's/^([a-zA-Z]+)($| - .+)/\1/p'" mkdir -p "${cache_dir}" From 2eedb137fdf6e0b5355836d38c42e9d52a3b2d30 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Fri, 4 Mar 2016 10:04:02 +0100 Subject: [PATCH 150/216] Added aliases for docker-compose --- aliases/available/docker-compose.aliases.bash | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 aliases/available/docker-compose.aliases.bash diff --git a/aliases/available/docker-compose.aliases.bash b/aliases/available/docker-compose.aliases.bash new file mode 100644 index 00000000..99b1db19 --- /dev/null +++ b/aliases/available/docker-compose.aliases.bash @@ -0,0 +1,5 @@ +cite 'about-alias' +about-alias 'docker-compose abbreviations' + +alias dco="docker-compose" +alias dcofresh="docker-compose stop ; docker-compose rm -f ; docker-compose up -d ; docker-compose logs" From 3c9fecf967e8b956ed483cf2910eb16662e02ca9 Mon Sep 17 00:00:00 2001 From: James Cuzella Date: Fri, 11 Mar 2016 11:28:11 -0700 Subject: [PATCH 151/216] Make all vars defined in lib/history.bash overridable. Set these before sourcing Bash-It with .bashrc or .bash_profile to override defaults --- lib/history.bash | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/history.bash b/lib/history.bash index d582192b..f7d3303c 100755 --- a/lib/history.bash +++ b/lib/history.bash @@ -2,10 +2,10 @@ # Bash History Handling -shopt -s histappend # append to bash_history if Terminal.app quits -export HISTCONTROL=erasedups # erase duplicates; alternative option: export HISTCONTROL=ignoredups -export HISTSIZE=5000 # resize history size -export AUTOFEATURE=true autotest +shopt -s histappend # append to bash_history if Terminal.app quits +export HISTCONTROL=${HISTCONTROL:-erasedups} # erase duplicates; alternative option: export HISTCONTROL=ignoredups +export HISTSIZE=${HISTSIZE:-5000} # resize history size +export AUTOFEATURE=${AUTOFEATURE:-true autotest} # Cucumber / Autotest integration function rh { history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head From 6de871294e6b1571789cf5595df906a63ceb8f55 Mon Sep 17 00:00:00 2001 From: Konstantin Gredeskoul Date: Mon, 14 Mar 2016 03:23:22 -0700 Subject: [PATCH 152/216] Adding support for rbenv in addition to rvm - following existing patterns, clearing out RBENV prefix and suffix - using existing function to read the prompt --- .../powerline-multiline.theme.bash | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index 0978e3d0..27d51d52 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -23,8 +23,11 @@ SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR} RVM_THEME_PROMPT_PREFIX="" RVM_THEME_PROMPT_SUFFIX="" -RVM_THEME_PROMPT_COLOR=161 -RVM_CHAR=${POWERLINE_RVM_CHAR:="❲r❳ "} +RBENV_THEME_PROMPT_PREFIX="" +RBENV_THEME_PROMPT_SUFFIX="" + +RUBY_THEME_PROMPT_COLOR=161 +RUBY_CHAR=${POWERLINE_RUBY_CHAR:="❲r❳"} CWD_THEME_PROMPT_COLOR=240 @@ -42,7 +45,7 @@ THEME_PROMPT_CLOCK_FORMAT=${POWERLINE_PROMPT_CLOCK_FORMAT:="%H:%M:%S"} IN_VIM_THEME_PROMPT_COLOR=245 IN_VIM_THEME_PROMPT_TEXT="vim" -POWERLINE_LEFT_PROMPT=${POWERLINE_LEFT_PROMPT:="scm python_venv rvm cwd"} +POWERLINE_LEFT_PROMPT=${POWERLINE_LEFT_PROMPT:="scm python_venv ruby cwd"} POWERLINE_RIGHT_PROMPT=${POWERLINE_RIGHT_PROMPT:="in_vim clock battery user_info"} function set_rgb_color { @@ -80,13 +83,16 @@ function __powerline_user_info_prompt { [[ -n "${user_info}" ]] && echo "${user_info}|${color}" } -function __powerline_rvm_prompt { - local rvm="" +function __powerline_ruby_prompt { + local ruby_version="" if command_exists rvm; then - rvm="$(rvm_version_prompt)" - [[ -n "${rvm}" ]] && echo "${RVM_CHAR}${rvm}|${RVM_THEME_PROMPT_COLOR}" + ruby_version="$(rvm_version_prompt)" + elif command_exists rbenv; then + ruby_version=$(rbenv_version_prompt) fi + + [[ -n "${ruby_version}" ]] && echo "${RUBY_CHAR}${ruby_version}|${RUBY_THEME_PROMPT_COLOR}" } function __powerline_python_venv_prompt { @@ -121,7 +127,7 @@ function __powerline_scm_prompt { if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" fi - echo "${scm_prompt}|${color}" + echo "${scm_prompt}${scm}|${color}" fi } From b70018e53130926ebb5c737d51b3cd6297d24aaa Mon Sep 17 00:00:00 2001 From: Konstantin Gredeskoul Date: Mon, 14 Mar 2016 03:42:38 -0700 Subject: [PATCH 153/216] Adding support for git user & git pair --- README.md | 16 +++++++++++++++- themes/base.theme.bash | 14 ++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 22698f04..cae8a128 100644 --- a/README.md +++ b/README.md @@ -166,6 +166,20 @@ also, with this flag to false, Bash-it will not show the repository as dirty whe **NOTE:** If you set in git configuration file the option to ignore *untracked* files, this flag has no effect, and Bash-it will ignore *untracked* files always. +#### Git user + +In some environments it is useful to know the value of the currently-set git user, which is used to mark all new commits. For example, any organization that uses the practice of pair programming will typically author each commit with a [combined name of two authors](https://github.com/pivotal/git_scripts). When another pair uses the same pairing station, the authors must be changed. + +To enable display of the current pair in the prompt, you can set `SCM_GIT_SHOW_CURRENT_USER` to `true`. Once set, the `SCM_CURRENT_USER` variable will be automatically set to the initials of the git author(s). It will also be included in the default git prompt. + +You can control the prefix and the suffix of this component using the two variables: + +* `export SCM_THEME_CURRENT_USER_PREFFIX=' ☺︎ '` + +And + +* `export SCM_THEME_CURRENT_USER_SUFFIX=' '`` + #### Ignore repo status When working in repos with a large code base Bash-it can slow down your prompt when checking the repo status, to avoid it, there is an option you can set via Git config to disable checking repo status in Bash-it. @@ -184,7 +198,7 @@ $ git config --global --add bash-it.hide-status 1 setting this flag globally has the same effect that `SCM_CHECK=true` but only for Git repos. -### pass function renamed to passgen +### Pass function renamed to passgen The Bash-it `pass` function has been renamed to `passgen` in order to avoid a naming conflict with the [pass password manager]. In order to minimize the impact on users of the legacy Bash-it `pass` function, Bash-it will create the alias `pass` that calls the new `passgen` function if the `pass` password manager command is not found on the `PATH` (default behavior). diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 993e1922..a93200c7 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -13,6 +13,8 @@ SCM_THEME_TAG_PREFIX='tag:' SCM_THEME_DETACHED_PREFIX='detached:' SCM_THEME_BRANCH_TRACK_PREFIX=' → ' SCM_THEME_BRANCH_GONE_PREFIX=' ⇢ ' +SCM_THEME_CURRENT_USER_PREFFIX=' ☺︎ ' +SCM_THEME_CURRENT_USER_SUFFIX='' CLOCK_CHAR='☆' THEME_CLOCK_CHECK=${THEME_CLOCK_CHECK:=true} @@ -21,6 +23,7 @@ THEME_BATTERY_PERCENTAGE_CHECK=${THEME_BATTERY_PERCENTAGE_CHECK:=true} SCM_GIT_SHOW_DETAILS=${SCM_GIT_SHOW_DETAILS:=true} SCM_GIT_SHOW_REMOTE_INFO=${SCM_GIT_SHOW_REMOTE_INFO:=auto} SCM_GIT_IGNORE_UNTRACKED=${SCM_GIT_IGNORE_UNTRACKED:=false} +SCM_GIT_SHOW_CURRENT_USER=${SCM_GIT_SHOW_CURRENT_USER:=false} SCM_GIT='git' SCM_GIT_CHAR='±' @@ -144,6 +147,12 @@ function git_prompt_vars { fi fi + if [[ "${SCM_GIT_SHOW_CURRENT_USER}" = "true" ]]; then + # support two or more initials, set by 'git pair' plugin + SCM_CURRENT_USER=`git config user.initials | sed 's% %+%'` + details+="$(git_user_info)" + fi + SCM_CHANGE=$(git rev-parse --short HEAD 2>/dev/null) local ref=$(git symbolic-ref -q HEAD 2> /dev/null) @@ -332,6 +341,11 @@ function python_version_prompt { echo -e "$(virtualenv_prompt)$(condaenv_prompt)$(py_interp_prompt)" } +function git_user_info { + if [[ -n "$SCM_CURRENT_USER" ]]; then + echo -e "$SCM_THEME_CURRENT_USER_PREFFIX$SCM_CURRENT_USER$SCM_THEME_CURRENT_USER_SUFFIX" + fi +} # backwards-compatibility function git_prompt_info { From 36d994dec5eb645c57b0318737b879fcd3fbf1b1 Mon Sep 17 00:00:00 2001 From: Konstantin Gredeskoul Date: Wed, 16 Mar 2016 20:15:20 -0700 Subject: [PATCH 154/216] Explained `git pair` and a more reliable fallback - Added more information to the README about the practice of using `git pair`, and provided instructions on installing the support. - Write a more reliable fallback that uses `user.name` to extract user initials, when `user.initials` aren't set. --- README.md | 6 ++++-- themes/base.theme.bash | 14 ++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index cae8a128..c3cab1b5 100644 --- a/README.md +++ b/README.md @@ -168,9 +168,11 @@ also, with this flag to false, Bash-it will not show the repository as dirty whe #### Git user -In some environments it is useful to know the value of the currently-set git user, which is used to mark all new commits. For example, any organization that uses the practice of pair programming will typically author each commit with a [combined name of two authors](https://github.com/pivotal/git_scripts). When another pair uses the same pairing station, the authors must be changed. +In some environments it is useful to know the value of the current git user, which is used to mark all new commits. For example, any organization that uses the practice of pair programming will typically author each commit with a [combined names of the two authors](https://github.com/pivotal/git_scripts). When another pair uses the same pairing station, the authors are changed at the beginning of the session. -To enable display of the current pair in the prompt, you can set `SCM_GIT_SHOW_CURRENT_USER` to `true`. Once set, the `SCM_CURRENT_USER` variable will be automatically set to the initials of the git author(s). It will also be included in the default git prompt. +To get up and running with this technique, run `gem install pivotal_git_scripts`, and then edit your `~/.pairs` file, according to the specification on the [gem's homepage](https://github.com/pivotal/git_scripts) After that you should be able to run `git pair kg as` to set the author to, eg. "Konstantin Gredeskoul and Alex Saxby", assuming they've been added to the `~/.pairs` file. Please see gem's documentation for more information. + +To enable the display of the current pair in the prompt, you must set `SCM_GIT_SHOW_CURRENT_USER` to `true`. Once set, the `SCM_CURRENT_USER` variable will be automatically populated with the initials of the git author(s). It will also be included in the default git prompt. Even if you do not have `git pair` installed, as long as your `user.name` is set, your initials will be computed from your name, and shown in the prompt. You can control the prefix and the suffix of this component using the two variables: diff --git a/themes/base.theme.bash b/themes/base.theme.bash index a93200c7..2f1bf4b3 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -147,11 +147,7 @@ function git_prompt_vars { fi fi - if [[ "${SCM_GIT_SHOW_CURRENT_USER}" = "true" ]]; then - # support two or more initials, set by 'git pair' plugin - SCM_CURRENT_USER=`git config user.initials | sed 's% %+%'` - details+="$(git_user_info)" - fi + [[ "${SCM_GIT_SHOW_CURRENT_USER}" == "true" ]] && details+="$(git_user_info)" SCM_CHANGE=$(git rev-parse --short HEAD 2>/dev/null) @@ -342,9 +338,11 @@ function python_version_prompt { } function git_user_info { - if [[ -n "$SCM_CURRENT_USER" ]]; then - echo -e "$SCM_THEME_CURRENT_USER_PREFFIX$SCM_CURRENT_USER$SCM_THEME_CURRENT_USER_SUFFIX" - fi + # support two or more initials, set by 'git pair' plugin + SCM_CURRENT_USER=$(git config user.initials | sed 's% %+%') + # if `user.initials` weren't set, attempt to extract initials from `user.name` + [[ -z "${SCM_CURRENT_USER}" ]] && SCM_CURRENT_USER=$(printf "%s" $(for word in $(git config user.name | tr 'A-Z' 'a-z'); do printf "%1.1s" $word; done)) + [[ -n "${SCM_CURRENT_USER}" ]] && printf "%s" "$SCM_THEME_CURRENT_USER_PREFFIX$SCM_CURRENT_USER$SCM_THEME_CURRENT_USER_SUFFIX" } # backwards-compatibility From c0a657270c2aea7cd4aeb9cc3774214e9b980000 Mon Sep 17 00:00:00 2001 From: Konstantin Gredeskoul Date: Sun, 20 Mar 2016 10:34:49 -0700 Subject: [PATCH 155/216] Add bash-it search functionality - "bash-it search term1 [term2]...." - we are using existing 'bash-it show plugins|aliases|completions' commands output, to search (with grep) for lines that match the search terms, and then output the matches. - wrote a simple unit test that for whatever reason fails on Travis, so wrapped it in 'if "Darwin"'... --- .editorconfig | 0 .gitignore | 3 + .travis.yml | 3 +- completion/available/bash-it.completion.bash | 2 +- lib/helpers.bash | 60 +++++++++++++++++++- test/lib/helpers.bats | 19 +++++++ test/run | 4 +- 7 files changed, 85 insertions(+), 6 deletions(-) mode change 100644 => 100755 .editorconfig mode change 100644 => 100755 .gitignore mode change 100644 => 100755 lib/helpers.bash create mode 100644 test/lib/helpers.bats diff --git a/.editorconfig b/.editorconfig old mode 100644 new mode 100755 diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index dc868103..b748d384 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.atom-build.json */enabled/* .DS_Store custom/* @@ -9,3 +10,5 @@ lib/custom.bash plugins/custom.plugins.bash *.swp .*.un~ +bats +.idea diff --git a/.travis.yml b/.travis.yml index a1745beb..34c38fe7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,3 @@ sudo: false -install: git clone --depth 1 https://github.com/sstephenson/bats.git -script: PATH="./bats/bin:$PATH" test/run +script: test/run language: c diff --git a/completion/available/bash-it.completion.bash b/completion/available/bash-it.completion.bash index f4eddc20..3cd8e84e 100644 --- a/completion/available/bash-it.completion.bash +++ b/completion/available/bash-it.completion.bash @@ -53,7 +53,7 @@ _bash-it-comp() prev="${COMP_WORDS[COMP_CWORD-1]}" chose_opt="${COMP_WORDS[1]}" file_type="${COMP_WORDS[2]}" - opts="help show enable disable update" + opts="help show enable disable update search" case "${chose_opt}" in show) local show_args="plugins aliases completions" diff --git a/lib/helpers.bash b/lib/helpers.bash old mode 100644 new mode 100755 index e3d0ef0d..84915b9f --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -32,14 +32,15 @@ function reload_plugins() { bash-it () { about 'Bash-it help and maintenance' - param '1: verb [one of: help | show | enable | disable | update ] ' - param '2: component type [one of: alias(es) | completion(s) | plugin(s) ]' + param '1: verb [one of: help | show | enable | disable | update | search ] ' + param '2: component type [one of: alias(es) | completion(s) | plugin(s) ] or search term(s)' param '3: specific component [optional]' example '$ bash-it show plugins' example '$ bash-it help aliases' example '$ bash-it enable plugin git [tmux]...' example '$ bash-it disable alias hg [tmux]...' example '$ bash-it update' + example '$ bash-it search ruby [rake]...' typeset verb=${1:-} shift typeset component=${1:-} @@ -54,6 +55,9 @@ bash-it () func=_disable-$component;; help) func=_help-$component;; + search) + _bash-it-search $component $* + return;; update) func=_bash-it_update;; *) @@ -139,6 +143,58 @@ _bash-it_update() { cd - &> /dev/null } +# This function returns list of aliases, plugins and completions in bash-it, +# whose name or description matches one of the search terms provided as arguments. +# +# Usage: +# ❯ bash-it search term1 [term2]... +# Example: +# ❯ bash-it search ruby rbenv rvm gem rake +# aliases: bundler +# plugins: chruby chruby-auto rbenv ruby rvm +# completions: gem rake +# + +_bash-it-search() { + _about 'searches for given terms amongst bash-it plugins, aliases and completions' + _param '1: term1' + _param '2: [ term2 ]...' + _example '$ _bash-it-search ruby rvm rake bundler' + + declare -a _components=(aliases plugins completions) + for _component in "${_components[@]}" ; do + _bash-it-search-component "${_component}" "$*" + done +} + +_bash-it-search-component() { + _about 'searches for given terms amongst a given component' + _param '1: component type, one of: [ aliases | plugins | completions ]' + _param '2: term1' + _param '3: [ term2 ]...' + _example '$ _bash-it-search-component aliases rake bundler' + + _component=$1 + local func=_bash-it-${_component} + shift + declare -a terms=($@) + declare -a matches=() + local _grep=$(which egrep || which grep) + for term in "${terms[@]}"; do + local term_match=($($func | ${_grep} -i -- ${term} | cut -d ' ' -f 1 | tr '\n' ' ')) + [[ "${#term_match[@]}" -gt 0 ]] && { + matches=(${matches[@]} ${term_match[@]}) + } + done + [[ -n "$NO_COLOR" && color_on="" ]] || color_on="\e[1;32m" + [[ -n "$NO_COLOR" && color_off="" ]] || color_off="\e[0;0m" + + if [[ "${#matches[*]}" -gt 0 ]] ; then + printf "%-12s: ${color_on}%s${color_off}\n" "${_component}" "$(echo -n ${matches[*]} | tr ' ' '\n' | sort | uniq | tr '\n' ' ' | sed 's/ $//g')" + fi + unset matches +} + _bash-it-describe () { _about 'summarizes available bash_it components' diff --git a/test/lib/helpers.bats b/test/lib/helpers.bats new file mode 100644 index 00000000..8e4e3468 --- /dev/null +++ b/test/lib/helpers.bats @@ -0,0 +1,19 @@ +#!/usr/bin/env bats + +load ../../lib/composure +load ../../plugins/available/base.plugin + +cite _about _param _example _group _author _version + +load ../../lib/helpers + +NO_COLOR=true +IS_DARWIN=false +[[ "$(uname -s)" == "Darwin" ]] && IS_DARWIN=true + +if [ "$IS_DARWIN" == "true" ]; then + @test "helpers search aliases" { + run _bash-it-search-component 'plugins' 'base' + [[ "${lines[0]}" =~ 'plugins' && "${lines[0]}" =~ 'base' ]] + } +fi diff --git a/test/run b/test/run index 1fb11518..2efc35d0 100755 --- a/test/run +++ b/test/run @@ -1,4 +1,6 @@ #!/usr/bin/env bash +PATH=$PATH:$(pwd)/bats/bin +set +e +[[ -z "$(which bats)" ]] && git clone --depth 1 https://github.com/sstephenson/bats.git set -e - exec bats ${CI:+--tap} test/{lib,plugins} From a9bf098c7a7acb750dbc272e0435c1554ef0e0ed Mon Sep 17 00:00:00 2001 From: Konstantin Gredeskoul Date: Wed, 23 Mar 2016 23:26:13 -0700 Subject: [PATCH 156/216] bash-it search functionality: allow test to skip on travis --- test/lib/helpers.bats | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/test/lib/helpers.bats b/test/lib/helpers.bats index 8e4e3468..47cb6797 100644 --- a/test/lib/helpers.bats +++ b/test/lib/helpers.bats @@ -8,12 +8,14 @@ cite _about _param _example _group _author _version load ../../lib/helpers NO_COLOR=true -IS_DARWIN=false + +IS_DARWIN= [[ "$(uname -s)" == "Darwin" ]] && IS_DARWIN=true -if [ "$IS_DARWIN" == "true" ]; then - @test "helpers search aliases" { - run _bash-it-search-component 'plugins' 'base' - [[ "${lines[0]}" =~ 'plugins' && "${lines[0]}" =~ 'base' ]] - } -fi +@test "helpers search aliases" { + if [ -z "$IS_DARWIN" ]; then + skip 'search test only runs on OSX' + fi + run _bash-it-search-component 'plugins' 'base' + [[ "${lines[0]}" =~ 'plugins' && "${lines[0]}" =~ 'base' ]] +} From 50d28364b2d9d51cab74c3359e6c97c7fe5b4469 Mon Sep 17 00:00:00 2001 From: Konstantin Gredeskoul Date: Thu, 24 Mar 2016 00:15:27 -0700 Subject: [PATCH 157/216] Updated README with a section on Search --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index c3cab1b5..bd92e849 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,30 @@ bash-it help completions # shows help for installed completions bash-it help plugins # shows help for installed plugins ``` +## Search + +If you need to quickly find out which of the plugins, aliases or completions +are available for a specific task or an environment, you can search for +multiple terms related to the commands you use frequently. Search will +find and output modules with the name or description matching the terms +provided. + +``` +bash-it search term1 [term2] [term3].... +``` + +For example, if you are a ruby developer, you might want to enable everything +related to the commands such as `ruby`, `rake`, `gem`, `bundler` and `rails`. +Search command helps you find related modules, so that you can decide which +of them you'd like to use: + +``` +> bash-it search ruby rake gem bundle irb rails +aliases : bundler rails +plugins : chruby chruby-auto ruby +completions : bundler gem rake +``` + ## Your Custom scripts, aliases, themes, and functions For custom scripts, and aliases, just create the following files (they'll be ignored by the git repo): From fd3d305fad1d8d8e347704275f67aecd2ec1f621 Mon Sep 17 00:00:00 2001 From: Konstantin Gredeskoul Date: Thu, 24 Mar 2016 02:54:30 -0700 Subject: [PATCH 158/216] Faster search, and cleaner completion --- completion/available/bash-it.completion.bash | 2 +- lib/helpers.bash | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/completion/available/bash-it.completion.bash b/completion/available/bash-it.completion.bash index 3cd8e84e..f4326a0a 100644 --- a/completion/available/bash-it.completion.bash +++ b/completion/available/bash-it.completion.bash @@ -65,7 +65,7 @@ _bash-it-comp() COMPREPLY=( $(compgen -W "${help_args}" -- ${cur}) ) return 0 ;; - update) + update | search) return 0 ;; enable | disable) diff --git a/lib/helpers.bash b/lib/helpers.bash index 84915b9f..6473d471 100755 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -176,12 +176,14 @@ _bash-it-search-component() { _component=$1 local func=_bash-it-${_component} + local help=$($func) + shift declare -a terms=($@) declare -a matches=() local _grep=$(which egrep || which grep) for term in "${terms[@]}"; do - local term_match=($($func | ${_grep} -i -- ${term} | cut -d ' ' -f 1 | tr '\n' ' ')) + local term_match=($(echo "${help}"| ${_grep} -i -- ${term} | cut -d ' ' -f 1 | tr '\n' ' ')) [[ "${#term_match[@]}" -gt 0 ]] && { matches=(${matches[@]} ${term_match[@]}) } From 8c5ec7589881c2d4ae384d02cc8c3bae22e49bd3 Mon Sep 17 00:00:00 2001 From: Konstantin Gredeskoul Date: Thu, 24 Mar 2016 03:05:03 -0700 Subject: [PATCH 159/216] Full featured search test, dig into travis failures --- test/lib/helpers.bats | 13 +++++++------ test/run | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/test/lib/helpers.bats b/test/lib/helpers.bats index 47cb6797..af9ae6b6 100644 --- a/test/lib/helpers.bats +++ b/test/lib/helpers.bats @@ -9,13 +9,14 @@ load ../../lib/helpers NO_COLOR=true -IS_DARWIN= -[[ "$(uname -s)" == "Darwin" ]] && IS_DARWIN=true - @test "helpers search aliases" { - if [ -z "$IS_DARWIN" ]; then - skip 'search test only runs on OSX' - fi run _bash-it-search-component 'plugins' 'base' [[ "${lines[0]}" =~ 'plugins' && "${lines[0]}" =~ 'base' ]] } + +@test "helpers search all ruby et al" { + run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' 'rails' + [[ "${lines[0]}" == 'aliases : bundler rails' ]] + [[ "${lines[1]}" == 'plugins : chruby chruby-auto ruby' ]] + [[ "${lines[2]}" == 'completions : bundler gem rake' ]] +} diff --git a/test/run b/test/run index 2efc35d0..6bc2f578 100755 --- a/test/run +++ b/test/run @@ -3,4 +3,4 @@ PATH=$PATH:$(pwd)/bats/bin set +e [[ -z "$(which bats)" ]] && git clone --depth 1 https://github.com/sstephenson/bats.git set -e -exec bats ${CI:+--tap} test/{lib,plugins} +exec ./bats/bin/bats ${CI:+--tap} ./test/{lib,plugins} From 320e864f591c3ae6c6c0a4a4783e5c4a875e7765 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 24 Mar 2016 16:34:32 +0000 Subject: [PATCH 160/216] Fix battery plugin Clean cases and remove spaces and % symbol in one awk command --- plugins/available/battery.plugin.bash | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/plugins/available/battery.plugin.bash b/plugins/available/battery.plugin.bash index 75741c4a..826b9b15 100644 --- a/plugins/available/battery.plugin.bash +++ b/plugins/available/battery.plugin.bash @@ -32,30 +32,13 @@ battery_percentage(){ ;; esac ;; - *" Discharging"*) - local PERC_OUTPUT=$(echo $ACPI_OUTPUT | head -c 26 | tail -c 2) - case $PERC_OUTPUT in - *%) - echo "0${PERC_OUTPUT}" | head -c 2 - ;; - *) - echo ${PERC_OUTPUT} - ;; - esac - ;; - *" Charging"*) - local PERC_OUTPUT=$(echo $ACPI_OUTPUT | head -c 23 | tail -c 2) - case $PERC_OUTPUT in - *%) - echo "0${PERC_OUTPUT}" | head -c 2 - ;; - *) - echo ${PERC_OUTPUT} - ;; - esac + + *" Charging"* | *" Discharging"*) + local PERC_OUTPUT=$(echo $ACPI_OUTPUT | awk -F, '/,/{gsub(/ /, "", $0); gsub(/%/,"", $0); print $2}' ) + echo ${PERC_OUTPUT} ;; *" Full"*) - echo '99' + echo '100' ;; *) echo '-1' From c5de52aef3c8abb6de21db5a630eba7ecba78324 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Fri, 25 Mar 2016 10:13:16 -0500 Subject: [PATCH 161/216] Changing to output 100% for full battery on OS X. This commit ensures that `battery_percentage` has the same output on both Linux and OS X. Thanks @jfmcarreira for finding this! --- plugins/available/battery.plugin.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/available/battery.plugin.bash b/plugins/available/battery.plugin.bash index 826b9b15..85af5097 100644 --- a/plugins/available/battery.plugin.bash +++ b/plugins/available/battery.plugin.bash @@ -52,7 +52,7 @@ battery_percentage(){ local IOREG_OUTPUT=$(ioreg -n AppleSmartBattery -r | awk '$1~/Capacity/{c[$1]=$3} END{OFMT="%05.2f%%"; max=c["\"MaxCapacity\""]; print (max>0? 100*c["\"CurrentCapacity\""]/max: "?")}') case $IOREG_OUTPUT in 100*) - echo '99' + echo '100' ;; *) echo $IOREG_OUTPUT | head -c 2 From c600d82f46fc412a32d3920409b21ed28f26b41b Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Fri, 25 Mar 2016 10:55:04 -0500 Subject: [PATCH 162/216] Update to latest version of fasd. This brings the fasd up to November 5, 2015. Commit imported: https://github.com/clvv/fasd/commit/d41c4b0470abb8528132a7e1a6d5055403e6cbfe --- plugins/available/fasd.plugin.bash | 510 ++++++++++++++++------------- 1 file changed, 274 insertions(+), 236 deletions(-) diff --git a/plugins/available/fasd.plugin.bash b/plugins/available/fasd.plugin.bash index ee810e22..4275b7e3 100755 --- a/plugins/available/fasd.plugin.bash +++ b/plugins/available/fasd.plugin.bash @@ -29,9 +29,11 @@ fasd() { - case "$1" in - --init) - shift + # make zsh do word splitting inside this function + [ "$ZSH_VERSION" ] && emulate sh && setopt localoptions + + case $1 in + --init) shift while [ "$1" ]; do case $1 in env) @@ -43,11 +45,15 @@ fasd() { [ -z "$_FASD_DATA" ] && _FASD_DATA="$HOME/.fasd" [ -z "$_FASD_BLACKLIST" ] && _FASD_BLACKLIST="--help" [ -z "$_FASD_SHIFT" ] && _FASD_SHIFT="sudo busybox" - [ -z "$_FASD_IGNORE" ] && _FASD_IGNORE="fasd cd ls echo" + [ -z "$_FASD_IGNORE" ] && _FASD_IGNORE="fasd ls echo" [ -z "$_FASD_SINK" ] && _FASD_SINK=/dev/null [ -z "$_FASD_TRACK_PWD" ] && _FASD_TRACK_PWD=1 [ -z "$_FASD_MAX" ] && _FASD_MAX=2000 [ -z "$_FASD_BACKENDS" ] && _FASD_BACKENDS=native + [ -z "$_FASD_FUZZY" ] && _FASD_FUZZY=2 + [ -z "$_FASD_VIMINFO" ] && _FASD_VIMINFO="$HOME/.viminfo" + [ -z "$_FASD_RECENTLY_USED_XBEL" ] && \ + _FASD_RECENTLY_USED_XBEL="$HOME/.local/share/recently-used.xbel" if [ -z "$_FASD_AWK" ]; then # awk preferences @@ -59,10 +65,10 @@ fasd() { ;; auto) cat <& /dev/null || fasd -d'; EOS ;; zsh-hook) cat <> "$_FASD_SINK" 2>&1 + { eval "fasd --proc \$(fasd --sanitize \$2)"; } >> "$_FASD_SINK" 2>&1 } -autoload -U add-zsh-hook +autoload -Uz add-zsh-hook add-zsh-hook preexec _fasd_preexec EOS ;; bash-hook) cat <> "$_FASD_SINK" 2>&1 +} + # add bash hook -echo \$PROMPT_COMMAND | grep -v -q "fasd --proc" && \ - PROMPT_COMMAND='eval "fasd --proc \$(fasd --sanitize \$(history 1 | \ - sed -e "s/^[ ]*[0-9]*[ ]*//"))" >> "$_FASD_SINK" 2>&1;'"\$PROMPT_COMMAND" +case \$PROMPT_COMMAND in + *_fasd_prompt_func*) ;; + *) PROMPT_COMMAND="_fasd_prompt_func;\$PROMPT_COMMAND";; +esac EOS ;; posix-hook) cat <> "$_FASD_SINK" 2>&1 + { eval "fasd --proc \$(fasd --sanitize \$(fc -nl -1))"; } \\ + >> "$_FASD_SINK" 2>&1 } -echo "\$PS1" | grep -v -q "_fasd_ps1_func" && \ -export PS1="\\\$(_fasd_ps1_func)\$PS1" +case \$PS1 in + *_fasd_ps1_func*) ;; + *) export PS1="\\\$(_fasd_ps1_func)\$PS1";; +esac EOS ;; + tcsh-hook) cat <& /dev/null'; +EOS + + ;; + zsh-ccomp) cat <> "$_FASD_SINK" | \\ + sort -nr | sed 's/^[^ ]*[ ]*//' | while read -r line; do + compadd -U -V fasd "\$line" + done + compstate[insert]=menu # no expand + } + _fasd_zsh_word_complete_f() { _fasd_zsh_word_complete f ; } + _fasd_zsh_word_complete_d() { _fasd_zsh_word_complete d ; } + _fasd_zsh_word_complete_trigger() { + local _fasd_cur="\${words[CURRENT]}" + eval \$(fasd --word-complete-trigger _fasd_zsh_word_complete \$_fasd_cur) + } + # define zle widgets + zle -C fasd-complete complete-word _generic + zstyle ':completion:fasd-complete:*' completer _fasd_zsh_word_complete + zstyle ':completion:fasd-complete:*' menu-select + + zle -C fasd-complete-f complete-word _generic + zstyle ':completion:fasd-complete-f:*' completer _fasd_zsh_word_complete_f + zstyle ':completion:fasd-complete-f:*' menu-select + + zle -C fasd-complete-d complete-word _generic + zstyle ':completion:fasd-complete-d:*' completer _fasd_zsh_word_complete_d + zstyle ':completion:fasd-complete-d:*' menu-select } -_fasd_zsh_word_complete_f() { _fasd_zsh_word_complete f ; } -_fasd_zsh_word_complete_d() { _fasd_zsh_word_complete d ; } -_fasd_zsh_word_complete_trigger() { - local _fasd_cur="\${words[CURRENT]}" - eval \$(fasd --word-complete-trigger _fasd_zsh_word_complete \$_fasd_cur) -} -# define zle widgets -zle -C fasd-complete 'menu-select' _fasd_zsh_word_complete -zle -C fasd-complete-f 'menu-select' _fasd_zsh_word_complete_f -zle -C fasd-complete-d 'menu-select' _fasd_zsh_word_complete_d EOS ;; zsh-ccomp-install) cat <> "$_FASD_SINK" | sed -n "\\\$s/^.*'\(.*\)'/\1/p") \${COMP_LINE#* }" ) - IFS=\$'\n' COMPREPLY=( \$RESULT ) + local RESULT=\$( fasd --complete "\$(alias -p \$COMP_WORDS \\ + 2>> "$_FASD_SINK" | sed -n "\\\$s/^.*'\\\\(.*\\\\)'/\\\\1/p") + \${COMP_LINE#* }" | while read -r line; do + quote_readline "\$line" 2>/dev/null || \\ + printf %q "\$line" 2>/dev/null && \\ + printf \\\\n + done) + local IFS=\$'\\n'; COMPREPLY=( \$RESULT ) } _fasd_bash_hook_cmd_complete() { for cmd in \$*; do @@ -194,54 +261,12 @@ _fasd_bash_hook_cmd_complete() { done } -EOS - ;; - - bash-wcomp) cat <> "$_FASD_SINK" 2>&1 -_fasd_bash_word_complete_trigger() { - [ "\$_fasd_cur" ] || local _fasd_cur="\${COMP_WORDS[COMP_CWORD]}" - eval "\$(fasd --word-complete-trigger _fasd_bash_word_complete \$_fasd_cur)" -} >> "$_FASD_SINK" 2>&1 -_fasd_bash_word_complete_wrap() { - local _fasd_cur="\${COMP_WORDS[COMP_CWORD]}" - _fasd_bash_word_complete_trigger - local z=\${COMP_WORDS[0]} - # try original comp func - [ "\$COMPREPLY" ] || eval "\$( echo "\$_FASD_BASH_COMPLETE_P" | \ - sed -n "/ \$z\$/"'s/.*-F \(.*\) .*/\1/p' )" - # fall back on original complete options - local cmd="\$(echo "\$_FASD_BASH_COMPLETE_P" | \ - sed -n "/ \$z\$/"'s/complete/compgen/') \$_fasd_cur" - [ "\$COMPREPLY" ] || COMPREPLY=( \$(eval \$cmd) ) -} >> "$_FASD_SINK" 2>&1 - EOS ;; bash-ccomp-install) cat <> "$_FASD_SINK" 2>&1 +_fasd_bash_hook_cmd_complete fasd a s d f sd sf z zz EOS ;; @@ -249,46 +274,27 @@ EOS done ;; - --init-alias) - fasd --init posix-alias - ;; - - --init-zsh) - fasd --init zsh-hook zsh-ccomp zsh-ccomp-install zsh-wcomp zsh-wcomp-install - ;; - - --init-bash) - fasd --init bash-hook bash-ccomp bash-ccomp-install - ;; - - --init-posix) - fasd --init posix-hook - ;; - - # if "$_fasd_cur" is a query, then eval all the arguments + # if "$_fasd_cur" or "$2" is a query, then output shell code to be eval'd --word-complete-trigger) shift; [ "$2" ] && local _fasd_cur="$2" || return - case "$_fasd_cur" in - ,*) echo "$1" e "$_fasd_cur";; - f,*) echo "$1" f "${_fasd_cur#?}";; - d,*) echo "$1" d "${_fasd_cur#?}";; - *,,) echo "$1" e "$_fasd_cur";; - *,,f) echo "$1" f "${_fasd_cur%?}";; - *,,d) echo "$1" d "${_fasd_cur%?}";; + case $_fasd_cur in + ,*) printf %s\\n "$1 e $_fasd_cur";; + f,*) printf %s\\n "$1 f ${_fasd_cur#?}";; + d,*) printf %s\\n "$1 d ${_fasd_cur#?}";; + *,,) printf %s\\n "$1 e $_fasd_cur";; + *,,f) printf %s\\n "$1 f ${_fasd_cur%?}";; + *,,d) printf %s\\n "$1 d ${_fasd_cur%?}";; esac ;; - --sanitize) - shift; echo "$@" | \ - sed 's/\([^\]\)$([^ ]*\([^)]*\)))*/\1\2/g;s/\([^\]\)[|&;<>$`]\{1,\}/\1 /g' + --sanitize) shift; printf %s\\n "$*" | \ + sed 's/\([^\]\)$( *[^ ]* *\([^)]*\)))*/\1\2/g + s/\([^\]\)[|&;<>$`{}]\{1,\}/\1 /g' ;; --proc) shift # process commands - # stop if we don't own ~/.fasd (we're another user but our ENV is still set) - [ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] && return - - # make zsh do word splitting for the for loop to work - [ "$ZSH_VERSION" ] && emulate sh && setopt localoptions + # stop if we don't own $_FASD_DATA or $_FASD_RO is set + [ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return # blacklists local each; for each in $_FASD_BLACKLIST; do @@ -299,25 +305,30 @@ EOS while true; do case " $_FASD_SHIFT " in *\ $1\ *) shift;; - *) break + *) break;; esac done # ignores case " $_FASD_IGNORE " in - *\ $1\ *) return + *\ $1\ *) return;; esac shift; fasd --add "$@" # add all arguments except command ;; --add|-A) shift # add entries + # stop if we don't own $_FASD_DATA or $_FASD_RO is set + [ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return + # find all valid path arguments, convert them to simplest absolute form local paths="$(while [ "$1" ]; do - [ -e "$1" ] && echo "$1"; shift + [ -e "$1" ] && printf %s\\n "$1"; shift done | sed '/^[^/]/s@^@'"$PWD"'/@ - s@/\.\.$@/\.\./@;s@/\(\./\)\{1,\}@/@g;: 0;s@[^/][^/]*//*\.\./@/@;t 0 - s@^/*\.\./@/@;s@//*@/@g;s@/\.\{0,1\}$@@;s@^$@/@' | tr '\n' '|')" + s@/\.\.$@/../@;s@/\(\./\)\{1,\}@/@g;:0 + s@[^/][^/]*//*\.\./@/@;t 0 + s@^/*\.\./@/@;s@//*@/@g;s@/\.\{0,1\}$@@;s@^$@/@' 2>> "$_FASD_SINK" \ + | tr '\n' '|')" # add current pwd if the option is set [ "$_FASD_TRACK_PWD" = "1" -a "$PWD" != "$HOME" ] && paths="$paths|$PWD" @@ -340,7 +351,7 @@ EOS } $2 >= 1 { if($1 in paths) { - rank[$1] = $2 + 1 + rank[$1] = $2 + 1 / $2 time[$1] = now } else { rank[$1] = $2 @@ -362,17 +373,21 @@ EOS ;; --delete|-D) shift # delete entries + # stop if we don't own $_FASD_DATA or $_FASD_RO is set + [ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return + # turn valid arguments into entry-deleting sed commands - local sed_cmd="$(while [ "$1" ]; do echo "$1"; shift; done | \ - sed '/^[^/]/s@^@'"$PWD"'/@;s@/\.\.$@/\.\./@;s@/\(\./\)\{1,\}@/@g - : 0;s@[^/][^/]*//*\.\./@/@;t 0;s@^/*\.\./@/@;s@//*@/@g;s@/\.\{0,1\}$@@ - s@^$@/@;s@\([.[/*^$]\)@\\\1@g;s@^\(.*\)$@/^\1|/d@')" + local sed_cmd="$(while [ "$1" ]; do printf %s\\n "$1"; shift; done | \ + sed '/^[^/]/s@^@'"$PWD"'/@;s@/\.\.$@/../@;s@/\(\./\)\{1,\}@/@g;:0 + s@[^/][^/]*//*\.\./@/@;t 0 + s@^/*\.\./@/@;s@//*@/@g;s@/\.\{0,1\}$@@ + s@^$@/@;s@\([.[\/*^$]\)@\\\1@g;s@^\(.*\)$@/^\1|/d@' 2>> "$_FASD_SINK")" # maintain the file local tempfile tempfile="$(mktemp "$_FASD_DATA".XXXXXX)" || return - sed -e "$sed_cmd" "$_FASD_DATA" 2>> "$_FASD_SINK" >| "$tempfile" + sed "$sed_cmd" "$_FASD_DATA" 2>> "$_FASD_SINK" >| "$tempfile" if [ $? -ne 0 -a -f "$_FASD_DATA" ]; then env rm -f "$tempfile" @@ -381,16 +396,11 @@ EOS fi ;; - --query) shift # query the db, --query [$typ ["$fnd" [$mode [$quote]]]] + --query) shift # query the db, --query [$typ ["$fnd" [$mode]]] [ -f "$_FASD_DATA" ] || return # no db yet [ "$1" ] && local typ="$1" [ "$2" ] && local fnd="$2" [ "$3" ] && local mode="$3" - [ "$4" ] && local quote="$4" - [ "$quote" ] && local qts='"\""' || local qts= - - # make zsh do word spliting for the for loop to work - [ "$ZSH_VERSION" ] && emulate sh && setopt localoptions # cat all backends local each _fasd_data; for each in $_FASD_BACKENDS; do @@ -406,10 +416,45 @@ $(fasd --backend $each)" *) local prior='times[i] * frecent(la[i])';; esac + if [ "$fnd" ]; then # dafault matching + local bre="$(printf %s\\n "$fnd" | sed 's/\([*\.\\\[]\)/\\\1/g + s@ @[^|]*@g;s/\$$/|/')" + bre='^[^|]*'"$bre"'[^|/]*|' + local _ret="$(printf %s\\n "$_fasd_data" | grep "$bre")" + [ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do + [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" + done)" + if [ "$_ret" ]; then + _fasd_data="$_ret" + else # no case mathcing + _ret="$(printf %s\\n "$_fasd_data" | grep -i "$bre")" + [ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do + [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" + done)" + if [ "$_ret" ]; then + _fasd_data="$_ret" + elif [ "${_FASD_FUZZY:-0}" -gt 0 ]; then # fuzzy matching + local fuzzy_bre="$(printf %s\\n "$fnd" | \ + sed 's/\([*\.\\\[]\)/\\\1/g;s/\$$/|/ + s@\(\\\{0,1\}[^ ]\)@\1[^|/]\\{0,'"$_FASD_FUZZY"'\\}@g + s@ @[^|]*@g')" + fuzzy_bre='^[^|]*'"$fuzzy_bre"'[^|/]*|' + _ret="$(printf %s\\n "$_fasd_data" | grep -i "$fuzzy_bre")" + [ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do + [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" + done)" + [ "$_ret" ] && _fasd_data="$_ret" || _fasd_data= + fi + fi + else # no query arugments + _fasd_data="$(printf %s\\n "$_fasd_data" | while read -r line; do + [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" + done)" + fi + # query the database - echo "$_fasd_data" | while read line; do - [ -${typ:-e} "${line%%\|*}" ] && echo "$line" - done | $_FASD_AWK -v t="$(date +%s)" -v q="$fnd" -F"|" ' + [ "$_fasd_data" ] && printf %s\\n "$_fasd_data" | \ + $_FASD_AWK -v t="$(date +%s)" -F"|" ' function frecent(time) { dx = t-time if( dx < 3600 ) return 6 @@ -417,51 +462,18 @@ $(fasd --backend $each)" if( dx < 604800 ) return 2 return 1 } - function likelihood(pattern, path) { - m = gsub("/+", "/", path) - r = 1 - for(i in pattern) { - tmp = path - gsub(".*" pattern[i], "", tmp) - n = gsub("/+", "/", tmp) - if(n == m) - return 0 - else if(n == 0) - r *= 20 # F - else - r *= 1 - (n / m) - } - return r - } - BEGIN { - split(q, pattern, " ") - for(i in pattern) pattern_lower[i] = tolower(pattern[i]) # nocase - } { - if(!wcase[$1]) { + if(!paths[$1]) { times[$1] = $2 la[$1] = $3 - wcase[$1] = likelihood(pattern, $1) - if(!cx) nocase[$1] = likelihood(pattern_lower, tolower($1)) + paths[$1] = 1 } else { times[$1] += $2 if($3 > la[$1]) la[$1] = $3 } - cx = cx || wcase[$1] - ncx = ncx || nocase[$1] } END { - if(cx) { - for(i in wcase) { - if(wcase[i]) - printf "%-10s %s\n", '"$prior"' * wcase[i], '"$qts"' i '"$qts"' - } - } else if(ncx) { - for(i in nocase) { - if(nocase[i]) - printf "%-10s %s\n", '"$prior"' * nocase[i], '"$qts"' i '"$qts"' - } - } + for(i in paths) printf "%-10s %s\n", '"$prior"', i }' - 2>> "$_FASD_SINK" ;; @@ -469,36 +481,51 @@ $(fasd --backend $each)" case $2 in native) cat "$_FASD_DATA";; viminfo) - local t="$(date +%s)" - < "$HOME/.viminfo" sed -n '/^>/{s@~@'"$HOME"'@;p}' | \ - while IFS=" " read line; do - t=$((t-60)); echo "${line#??}|1|$t" - done + < "$_FASD_VIMINFO" sed -n '/^>/{s@~@'"$HOME"'@ + s/^..// + p + }' | $_FASD_AWK -v t="$(date +%s)" '{ + t -= 60 + print $0 "|1|" t + }' ;; recently-used) - tr -d '\n' < "$HOME/.local/share/recently-used.xbel" | \ - sed 's@file:/@\n@g;s@count="@\n@g' | sed '1d;s/".*$//' | \ - tr '\n' '|' | sed 's@|/@\n@g' | $_FASD_AWK -F'|' '{ + local nl="$(printf '\\\nX')"; nl="${nl%X}" # slash newline for sed + tr -d '\n' < "$_FASD_RECENTLY_USED_XBEL" | \ + sed 's@file:/@'"$nl"'@g;s@count="@'"$nl"'@g' | sed '1d;s/".*$//' | \ + tr '\n' '|' | sed 's@|/@'"$nl"'@g' | $_FASD_AWK -F'|' '{ sum = 0 for( i=2; i<=NF; i++ ) sum += $i print $1 "|" sum }' ;; + current) + for path in *; do + printf "$PWD/%s|1\\n" "$path" + done + ;; + spotlight) + mdfind '(kMDItemFSContentChangeDate >= $time.today) || + kMDItemLastUsedDate >= $time.this_month' \ + | sed '/Library\//d + /\.app$/d + s/$/|2/' + ;; *) eval "$2";; esac ;; *) # parsing logic and processing - local fnd last _FASD_BACKENDS="$_FASD_BACKENDS" _fasd_data - while [ "$1" ]; do case "$1" in - --complete) [ "$2" = "--" ] && shift; set -- $(echo $2); local lst=1 r=r;; + local fnd= last= _FASD_BACKENDS="$_FASD_BACKENDS" _fasd_data= comp= exec= + while [ "$1" ]; do case $1 in + --complete) [ "$2" = "--" ] && shift; set -- $2; local lst=1 r=r comp=1;; --query|--add|--delete|-A|-D) fasd "$@"; return $?;; - --version) echo "0.5.4"; return 0;; - --) while [ "$2" ]; do shift; fnd="$fnd$1 "; last="$1"; done;; - -*) local o="${1#-}"; while [ "$o" ]; do case "$o" in + --version) [ -z "$comp" ] && echo "1.0.1" && return;; + --) while [ "$2" ]; do shift; fnd="$fnd $1"; last="$1"; done;; + -*) local o="${1#-}"; while [ "$o" ]; do case $o in s*) local show=1;; l*) local lst=1;; - i*) local interactive=1 show=1;; + i*) [ -z "$comp" ] && local interactive=1 show=1;; r*) local mode=rank;; t*) local mode=recent;; e*) o="${o#?}"; if [ "$o" ]; then # there are characters after "-e" @@ -522,77 +549,88 @@ $(fasd --backend $each)" a*) local typ=e;; d*) local typ=d;; f*) local typ=f;; - q*) local quote=1;; - h*) echo "fasd [options] [query ...] -[f|a|s|d|z] [opions] [query ...] + R*) local r=r;; + [0-9]*) local _fasd_i="$o"; break;; + h*) [ -z "$comp" ] && echo "fasd [options] [query ...] +[f|a|s|d|z] [options] [query ...] options: - -s show list of files with their ranks - -l list paths only + -s list paths with scores + -l list paths without scores -i interactive mode -e set command to execute on the result file -b only use backend - -b add additional backend + -B add additional backend -a match files and directories -d match directories only -f match files only -r match by rank only -t match by recent access only + -R reverse listing order -h show a brief help message + -[0-9] select the nth entry fasd [-A|-D] [paths ...] -A add paths - -D delete paths" >&2; return;; + -D delete paths" >&2 && return;; esac; o="${o#?}"; done;; *) fnd="$fnd $1"; last="$1";; esac; shift; done - # if we hit enter on a completion just execute - case "$last" in - # completions will always start with / - /*) [ -z "$show$lst" -a -${typ:-e} "$last" -a "$exec" ] \ - && eval $exec "\"$last\"" && return;; + # guess whether the last query is selected from tab completion + case $last in + /?*) if [ -z "$show$lst" -a -${typ:-e} "$last" -a "$exec" ]; then + $exec "$last" + return + fi;; esac - local result - result="$(fasd --query 2>> "$_FASD_SINK")" # query the database - [ $? -gt 0 ] && return - if [ "$interactive" ] || [ "$exec" -a -z "$fnd$lst$show" -a -t 1 ]; then - result="$(echo "$result" | sort -nr)" - echo "$result" | sed = | sed 'N;s/\n/ /' | sort -nr >&2; printf "> " >&2 - local i; read i; [ 0 -lt "${i:-0}" ] 2>> "$_FASD_SINK" || return 1 - result="$(echo "$result" | sed -n "${i:-1}"'s/^[0-9.]*[ ]*//p')" - if [ "$result" ]; then - fasd --add "$result"; eval ${exec:-echo} "\"$result\"" - fi - elif [ "$lst" ]; then - echo "$result" | sort -n${r} | sed 's/^[0-9.]*[ ]*//' - elif [ "$show" ]; then - echo "$result" | sort -n - elif [ "$fnd" -a "$exec" ]; then # exec - result="$(echo "$result" | sort -n | sed -n '$s/^[0-9.]*[ ]*//p')" - fasd --add "$result"; eval $exec "\"$result\"" - elif [ "$fnd" -a ! -t 1 ]; then # echo if output is not terminal - result="$(echo "$result" | sort -n | sed -n '$s/^[0-9.]*[ ]*//p')" - fasd --add "$result"; echo "$result" - else # no args, show - echo "$result" | sort -n - fi + local R; [ -z "$r" ] && R=r || R= # let $R be the opposite of $r + fnd="${fnd# }" + local res + res="$(fasd --query 2>> "$_FASD_SINK")" # query the database + [ $? -gt 0 ] && return + if [ 0 -lt ${_fasd_i:-0} ] 2>> "$_FASD_SINK"; then + res="$(printf %s\\n "$res" | sort -n${R} | \ + sed -n "$_fasd_i"'s/^[^ ]*[ ]*//p')" + elif [ "$interactive" ] || [ "$exec" -a -z "$fnd$lst$show" -a -t 1 ]; then + if [ "$(printf %s "$res" | sed -n '$=')" -gt 1 ]; then + res="$(printf %s\\n "$res" | sort -n${R})" + printf %s\\n "$res" | sed = | sed 'N;s/\n/ /' | sort -nr >&2 + printf "> " >&2 + local i; read i; [ 0 -lt "${i:-0}" ] 2>> "$_FASD_SINK" || return 1 + fi + res="$(printf %s\\n "$res" | sed -n "${i:-1}"'s/^[^ ]*[ ]*//p')" + elif [ "$lst" ]; then + [ "$res" ] && printf %s\\n "$res" | sort -n${r} | sed 's/^[^ ]*[ ]*//' + return + elif [ "$show" ]; then + [ "$res" ] && printf %s\\n "$res" | sort -n${r} + return + elif [ "$fnd" ] && [ "$exec" -o ! -t 1 ]; then # exec or subshell + res="$(printf %s\\n "$res" | sort -n | sed -n '$s/^[^ ]*[ ]*//p')" + else # no args, show + [ "$res" ] && printf %s\\n "$res" | sort -n${r} + return + fi + if [ "$res" ]; then + fasd --add "$res" + [ -z "$exec" ] && exec='printf %s\n' + $exec "$res" + fi + ;; esac } fasd --init env case $- in - *i*) cite about-plugin - about-plugin 'navigate "frecently" used files and directories' - eval "$(fasd --init auto)" - ;; + *i*) ;; # assume being sourced, do nothing *) # assume being executed as an executable if [ -x "$_FASD_SHELL" -a -z "$_FASD_SET" ]; then _FASD_SET=1 exec $_FASD_SHELL "$0" "$@" else fasd "$@" - fi + fi;; esac From 3923cf0276fe7ecd9c915a8a9dadd3ddfc3efa24 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Fri, 25 Mar 2016 15:29:10 -0500 Subject: [PATCH 163/216] Ignore the enabled directories when running ack --- .ackrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 .ackrc diff --git a/.ackrc b/.ackrc new file mode 100644 index 00000000..876f1317 --- /dev/null +++ b/.ackrc @@ -0,0 +1 @@ +--ignore-dir=enabled/ From 06b458c896670ada4dd7d4b340cea87ef07ae386 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Fri, 25 Mar 2016 17:08:35 -0500 Subject: [PATCH 164/216] Replace embedded fasd with initialization There are multiple ways to install fasd, but the initialization still needs to happen. Currently, fasd is broken in bash in that it doesn't maintain the exit code properly. This custom init removes the call to `fasd --init bash-hook` and replaces it with the version that would be generated once fasd PR #72 is merged. See: https://github.com/clvv/fasd/pull/72 --- plugins/available/fasd.plugin.bash | 656 ++--------------------------- 1 file changed, 25 insertions(+), 631 deletions(-) diff --git a/plugins/available/fasd.plugin.bash b/plugins/available/fasd.plugin.bash index 4275b7e3..eef18265 100755 --- a/plugins/available/fasd.plugin.bash +++ b/plugins/available/fasd.plugin.bash @@ -1,636 +1,30 @@ -#!/usr/bin/env sh +cite about-plugin +about-plugin 'initialize fasd (see https://github.com/clvv/fasd)' -# Fasd (this file) can be sourced or executed by any POSIX compatible shell. - -# Fasd is originally written based on code from z (https://github.com/rupa/z) -# by rupa deadwyler under the WTFPL license. Most if not all of the code has -# been rewritten. - -# Copyright (C) 2011, 2012 by Wei Dai. All rights reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -fasd() { - - # make zsh do word splitting inside this function - [ "$ZSH_VERSION" ] && emulate sh && setopt localoptions - - case $1 in - --init) shift - while [ "$1" ]; do - case $1 in - env) - { # source rc files if present - [ -s "/etc/fasdrc" ] && . "/etc/fasdrc" - [ -s "$HOME/.fasdrc" ] && . "$HOME/.fasdrc" - - # set default options - [ -z "$_FASD_DATA" ] && _FASD_DATA="$HOME/.fasd" - [ -z "$_FASD_BLACKLIST" ] && _FASD_BLACKLIST="--help" - [ -z "$_FASD_SHIFT" ] && _FASD_SHIFT="sudo busybox" - [ -z "$_FASD_IGNORE" ] && _FASD_IGNORE="fasd ls echo" - [ -z "$_FASD_SINK" ] && _FASD_SINK=/dev/null - [ -z "$_FASD_TRACK_PWD" ] && _FASD_TRACK_PWD=1 - [ -z "$_FASD_MAX" ] && _FASD_MAX=2000 - [ -z "$_FASD_BACKENDS" ] && _FASD_BACKENDS=native - [ -z "$_FASD_FUZZY" ] && _FASD_FUZZY=2 - [ -z "$_FASD_VIMINFO" ] && _FASD_VIMINFO="$HOME/.viminfo" - [ -z "$_FASD_RECENTLY_USED_XBEL" ] && \ - _FASD_RECENTLY_USED_XBEL="$HOME/.local/share/recently-used.xbel" - - if [ -z "$_FASD_AWK" ]; then - # awk preferences - local awk; for awk in mawk gawk original-awk nawk awk; do - $awk "" && _FASD_AWK=$awk && break - done - fi - } >> "${_FASD_SINK:-/dev/null}" 2>&1 - ;; - - auto) cat <> "$_FASD_SINK" 2>&1 - -EOS - ;; - - posix-alias) cat <> "/dev/null" 2>&1 + return $_exit_code + } + + # add bash hook + case $PROMPT_COMMAND in + *_fasd_prompt_func*) ;; + *) PROMPT_COMMAND="_fasd_prompt_func;$PROMPT_COMMAND";; + esac + eval "$(fasd --init bash-ccomp bash-ccomp-install)" fi } -alias z='fasd_cd -d' -alias zz='fasd_cd -d -i' - -EOS - ;; - - tcsh-alias) cat <& /dev/null || fasd -d'; -EOS - ;; - - zsh-hook) cat <> "$_FASD_SINK" 2>&1 -} -autoload -Uz add-zsh-hook -add-zsh-hook preexec _fasd_preexec - -EOS - ;; - - bash-hook) cat <> "$_FASD_SINK" 2>&1 -} - -# add bash hook -case \$PROMPT_COMMAND in - *_fasd_prompt_func*) ;; - *) PROMPT_COMMAND="_fasd_prompt_func;\$PROMPT_COMMAND";; -esac - -EOS - ;; - - posix-hook) cat <> "$_FASD_SINK" 2>&1 -} -case \$PS1 in - *_fasd_ps1_func*) ;; - *) export PS1="\\\$(_fasd_ps1_func)\$PS1";; -esac - -EOS - ;; - - tcsh-hook) cat <& /dev/null'; -EOS - - ;; - - zsh-ccomp) cat <> "$_FASD_SINK" | \\ - sort -nr | sed 's/^[^ ]*[ ]*//' | while read -r line; do - compadd -U -V fasd "\$line" - done - compstate[insert]=menu # no expand - } - _fasd_zsh_word_complete_f() { _fasd_zsh_word_complete f ; } - _fasd_zsh_word_complete_d() { _fasd_zsh_word_complete d ; } - _fasd_zsh_word_complete_trigger() { - local _fasd_cur="\${words[CURRENT]}" - eval \$(fasd --word-complete-trigger _fasd_zsh_word_complete \$_fasd_cur) - } - # define zle widgets - zle -C fasd-complete complete-word _generic - zstyle ':completion:fasd-complete:*' completer _fasd_zsh_word_complete - zstyle ':completion:fasd-complete:*' menu-select - - zle -C fasd-complete-f complete-word _generic - zstyle ':completion:fasd-complete-f:*' completer _fasd_zsh_word_complete_f - zstyle ':completion:fasd-complete-f:*' menu-select - - zle -C fasd-complete-d complete-word _generic - zstyle ':completion:fasd-complete-d:*' completer _fasd_zsh_word_complete_d - zstyle ':completion:fasd-complete-d:*' menu-select -} - -EOS - ;; - - zsh-ccomp-install) cat <> "$_FASD_SINK" | sed -n "\\\$s/^.*'\\\\(.*\\\\)'/\\\\1/p") - \${COMP_LINE#* }" | while read -r line; do - quote_readline "\$line" 2>/dev/null || \\ - printf %q "\$line" 2>/dev/null && \\ - printf \\\\n - done) - local IFS=\$'\\n'; COMPREPLY=( \$RESULT ) -} -_fasd_bash_hook_cmd_complete() { - for cmd in \$*; do - complete -F _fasd_bash_cmd_complete \$cmd - done -} - -EOS - ;; - - bash-ccomp-install) cat <$`{}]\{1,\}/\1 /g' - ;; - - --proc) shift # process commands - # stop if we don't own $_FASD_DATA or $_FASD_RO is set - [ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return - - # blacklists - local each; for each in $_FASD_BLACKLIST; do - case " $* " in *\ $each\ *) return;; esac - done - - # shifts - while true; do - case " $_FASD_SHIFT " in - *\ $1\ *) shift;; - *) break;; - esac - done - - # ignores - case " $_FASD_IGNORE " in - *\ $1\ *) return;; - esac - - shift; fasd --add "$@" # add all arguments except command - ;; - - --add|-A) shift # add entries - # stop if we don't own $_FASD_DATA or $_FASD_RO is set - [ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return - - # find all valid path arguments, convert them to simplest absolute form - local paths="$(while [ "$1" ]; do - [ -e "$1" ] && printf %s\\n "$1"; shift - done | sed '/^[^/]/s@^@'"$PWD"'/@ - s@/\.\.$@/../@;s@/\(\./\)\{1,\}@/@g;:0 - s@[^/][^/]*//*\.\./@/@;t 0 - s@^/*\.\./@/@;s@//*@/@g;s@/\.\{0,1\}$@@;s@^$@/@' 2>> "$_FASD_SINK" \ - | tr '\n' '|')" - - # add current pwd if the option is set - [ "$_FASD_TRACK_PWD" = "1" -a "$PWD" != "$HOME" ] && paths="$paths|$PWD" - - [ -z "${paths##\|}" ] && return # stop if we have nothing to add - - # maintain the file - local tempfile - tempfile="$(mktemp "$_FASD_DATA".XXXXXX)" || return - $_FASD_AWK -v list="$paths" -v now="$(date +%s)" -v max="$_FASD_MAX" -F"|" ' - BEGIN { - split(list, files, "|") - for(i in files) { - path = files[i] - if(path == "") continue - paths[path] = path # array for checking - rank[path] = 1 - time[path] = now - } - } - $2 >= 1 { - if($1 in paths) { - rank[$1] = $2 + 1 / $2 - time[$1] = now - } else { - rank[$1] = $2 - time[$1] = $3 - } - count += $2 - } - END { - if(count > max) - for(i in rank) print i "|" 0.9*rank[i] "|" time[i] # aging - else - for(i in rank) print i "|" rank[i] "|" time[i] - }' "$_FASD_DATA" 2>> "$_FASD_SINK" >| "$tempfile" - if [ $? -ne 0 -a -f "$_FASD_DATA" ]; then - env rm -f "$tempfile" - else - env mv -f "$tempfile" "$_FASD_DATA" - fi - ;; - - --delete|-D) shift # delete entries - # stop if we don't own $_FASD_DATA or $_FASD_RO is set - [ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return - - # turn valid arguments into entry-deleting sed commands - local sed_cmd="$(while [ "$1" ]; do printf %s\\n "$1"; shift; done | \ - sed '/^[^/]/s@^@'"$PWD"'/@;s@/\.\.$@/../@;s@/\(\./\)\{1,\}@/@g;:0 - s@[^/][^/]*//*\.\./@/@;t 0 - s@^/*\.\./@/@;s@//*@/@g;s@/\.\{0,1\}$@@ - s@^$@/@;s@\([.[\/*^$]\)@\\\1@g;s@^\(.*\)$@/^\1|/d@' 2>> "$_FASD_SINK")" - - # maintain the file - local tempfile - tempfile="$(mktemp "$_FASD_DATA".XXXXXX)" || return - - sed "$sed_cmd" "$_FASD_DATA" 2>> "$_FASD_SINK" >| "$tempfile" - - if [ $? -ne 0 -a -f "$_FASD_DATA" ]; then - env rm -f "$tempfile" - else - env mv -f "$tempfile" "$_FASD_DATA" - fi - ;; - - --query) shift # query the db, --query [$typ ["$fnd" [$mode]]] - [ -f "$_FASD_DATA" ] || return # no db yet - [ "$1" ] && local typ="$1" - [ "$2" ] && local fnd="$2" - [ "$3" ] && local mode="$3" - - # cat all backends - local each _fasd_data; for each in $_FASD_BACKENDS; do - _fasd_data="$_fasd_data -$(fasd --backend $each)" - done - [ "$_fasd_data" ] || _fasd_data="$(cat "$_FASD_DATA")" - - # set mode specific code for calculating the prior - case $mode in - rank) local prior='times[i]';; - recent) local prior='sqrt(100000/(1+t-la[i]))';; - *) local prior='times[i] * frecent(la[i])';; - esac - - if [ "$fnd" ]; then # dafault matching - local bre="$(printf %s\\n "$fnd" | sed 's/\([*\.\\\[]\)/\\\1/g - s@ @[^|]*@g;s/\$$/|/')" - bre='^[^|]*'"$bre"'[^|/]*|' - local _ret="$(printf %s\\n "$_fasd_data" | grep "$bre")" - [ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do - [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" - done)" - if [ "$_ret" ]; then - _fasd_data="$_ret" - else # no case mathcing - _ret="$(printf %s\\n "$_fasd_data" | grep -i "$bre")" - [ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do - [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" - done)" - if [ "$_ret" ]; then - _fasd_data="$_ret" - elif [ "${_FASD_FUZZY:-0}" -gt 0 ]; then # fuzzy matching - local fuzzy_bre="$(printf %s\\n "$fnd" | \ - sed 's/\([*\.\\\[]\)/\\\1/g;s/\$$/|/ - s@\(\\\{0,1\}[^ ]\)@\1[^|/]\\{0,'"$_FASD_FUZZY"'\\}@g - s@ @[^|]*@g')" - fuzzy_bre='^[^|]*'"$fuzzy_bre"'[^|/]*|' - _ret="$(printf %s\\n "$_fasd_data" | grep -i "$fuzzy_bre")" - [ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do - [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" - done)" - [ "$_ret" ] && _fasd_data="$_ret" || _fasd_data= - fi - fi - else # no query arugments - _fasd_data="$(printf %s\\n "$_fasd_data" | while read -r line; do - [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" - done)" - fi - - # query the database - [ "$_fasd_data" ] && printf %s\\n "$_fasd_data" | \ - $_FASD_AWK -v t="$(date +%s)" -F"|" ' - function frecent(time) { - dx = t-time - if( dx < 3600 ) return 6 - if( dx < 86400 ) return 4 - if( dx < 604800 ) return 2 - return 1 - } - { - if(!paths[$1]) { - times[$1] = $2 - la[$1] = $3 - paths[$1] = 1 - } else { - times[$1] += $2 - if($3 > la[$1]) la[$1] = $3 - } - } - END { - for(i in paths) printf "%-10s %s\n", '"$prior"', i - }' - 2>> "$_FASD_SINK" - ;; - - --backend) - case $2 in - native) cat "$_FASD_DATA";; - viminfo) - < "$_FASD_VIMINFO" sed -n '/^>/{s@~@'"$HOME"'@ - s/^..// - p - }' | $_FASD_AWK -v t="$(date +%s)" '{ - t -= 60 - print $0 "|1|" t - }' - ;; - recently-used) - local nl="$(printf '\\\nX')"; nl="${nl%X}" # slash newline for sed - tr -d '\n' < "$_FASD_RECENTLY_USED_XBEL" | \ - sed 's@file:/@'"$nl"'@g;s@count="@'"$nl"'@g' | sed '1d;s/".*$//' | \ - tr '\n' '|' | sed 's@|/@'"$nl"'@g' | $_FASD_AWK -F'|' '{ - sum = 0 - for( i=2; i<=NF; i++ ) sum += $i - print $1 "|" sum - }' - ;; - current) - for path in *; do - printf "$PWD/%s|1\\n" "$path" - done - ;; - spotlight) - mdfind '(kMDItemFSContentChangeDate >= $time.today) || - kMDItemLastUsedDate >= $time.this_month' \ - | sed '/Library\//d - /\.app$/d - s/$/|2/' - ;; - *) eval "$2";; - esac - ;; - - *) # parsing logic and processing - local fnd= last= _FASD_BACKENDS="$_FASD_BACKENDS" _fasd_data= comp= exec= - while [ "$1" ]; do case $1 in - --complete) [ "$2" = "--" ] && shift; set -- $2; local lst=1 r=r comp=1;; - --query|--add|--delete|-A|-D) fasd "$@"; return $?;; - --version) [ -z "$comp" ] && echo "1.0.1" && return;; - --) while [ "$2" ]; do shift; fnd="$fnd $1"; last="$1"; done;; - -*) local o="${1#-}"; while [ "$o" ]; do case $o in - s*) local show=1;; - l*) local lst=1;; - i*) [ -z "$comp" ] && local interactive=1 show=1;; - r*) local mode=rank;; - t*) local mode=recent;; - e*) o="${o#?}"; if [ "$o" ]; then # there are characters after "-e" - local exec="$o" # anything after "-e" - else # use the next argument - local exec="${2:?"-e: Argument needed "}" - shift - fi; break;; - b*) o="${o#?}"; if [ "$o" ]; then - _FASD_BACKENDS="$o" - else - _FASD_BACKENDS="${2:?"-b: Argument needed"}" - shift - fi; break;; - B*) o="${o#?}"; if [ "$o" ]; then - _FASD_BACKENDS="$_FASD_BACKENDS $o" - else - _FASD_BACKENDS="$_FASD_BACKENDS ${2:?"-B: Argument needed"}" - shift - fi; break;; - a*) local typ=e;; - d*) local typ=d;; - f*) local typ=f;; - R*) local r=r;; - [0-9]*) local _fasd_i="$o"; break;; - h*) [ -z "$comp" ] && echo "fasd [options] [query ...] -[f|a|s|d|z] [options] [query ...] - options: - -s list paths with scores - -l list paths without scores - -i interactive mode - -e set command to execute on the result file - -b only use backend - -B add additional backend - -a match files and directories - -d match directories only - -f match files only - -r match by rank only - -t match by recent access only - -R reverse listing order - -h show a brief help message - -[0-9] select the nth entry - -fasd [-A|-D] [paths ...] - -A add paths - -D delete paths" >&2 && return;; - esac; o="${o#?}"; done;; - *) fnd="$fnd $1"; last="$1";; - esac; shift; done - - # guess whether the last query is selected from tab completion - case $last in - /?*) if [ -z "$show$lst" -a -${typ:-e} "$last" -a "$exec" ]; then - $exec "$last" - return - fi;; - esac - - local R; [ -z "$r" ] && R=r || R= # let $R be the opposite of $r - fnd="${fnd# }" - - local res - res="$(fasd --query 2>> "$_FASD_SINK")" # query the database - [ $? -gt 0 ] && return - if [ 0 -lt ${_fasd_i:-0} ] 2>> "$_FASD_SINK"; then - res="$(printf %s\\n "$res" | sort -n${R} | \ - sed -n "$_fasd_i"'s/^[^ ]*[ ]*//p')" - elif [ "$interactive" ] || [ "$exec" -a -z "$fnd$lst$show" -a -t 1 ]; then - if [ "$(printf %s "$res" | sed -n '$=')" -gt 1 ]; then - res="$(printf %s\\n "$res" | sort -n${R})" - printf %s\\n "$res" | sed = | sed 'N;s/\n/ /' | sort -nr >&2 - printf "> " >&2 - local i; read i; [ 0 -lt "${i:-0}" ] 2>> "$_FASD_SINK" || return 1 - fi - res="$(printf %s\\n "$res" | sed -n "${i:-1}"'s/^[^ ]*[ ]*//p')" - elif [ "$lst" ]; then - [ "$res" ] && printf %s\\n "$res" | sort -n${r} | sed 's/^[^ ]*[ ]*//' - return - elif [ "$show" ]; then - [ "$res" ] && printf %s\\n "$res" | sort -n${r} - return - elif [ "$fnd" ] && [ "$exec" -o ! -t 1 ]; then # exec or subshell - res="$(printf %s\\n "$res" | sort -n | sed -n '$s/^[^ ]*[ ]*//p')" - else # no args, show - [ "$res" ] && printf %s\\n "$res" | sort -n${r} - return - fi - if [ "$res" ]; then - fasd --add "$res" - [ -z "$exec" ] && exec='printf %s\n' - $exec "$res" - fi - ;; - esac -} - -fasd --init env - -case $- in - *i*) ;; # assume being sourced, do nothing - *) # assume being executed as an executable - if [ -x "$_FASD_SHELL" -a -z "$_FASD_SET" ]; then - _FASD_SET=1 exec $_FASD_SHELL "$0" "$@" - else - fasd "$@" - fi;; -esac +__init_fasd From 5b6b7392defb9e495c915ebef48406162f6e1d57 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Fri, 25 Mar 2016 17:18:14 -0500 Subject: [PATCH 165/216] Include a note in code about the upstream bugfix and remove trailing spaces --- plugins/available/fasd.plugin.bash | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/available/fasd.plugin.bash b/plugins/available/fasd.plugin.bash index eef18265..9d0442e2 100755 --- a/plugins/available/fasd.plugin.bash +++ b/plugins/available/fasd.plugin.bash @@ -10,9 +10,12 @@ __init_fasd() { eval "$(fasd --init posix-alias)" # Note, this is a custom bash-hook to ensure that the last exit status - # is maintained even while this hook is in place + # is maintained even while this hook is in place. This code can be + # removed once PR #72 is merged into fasd. + # + # See: https://github.com/clvv/fasd/pull/72 _fasd_prompt_func() { - local _exit_code="$? " + local _exit_code="$?" eval "fasd --proc $(fasd --sanitize $(history 1 | \ sed "s/^[ ]*[0-9]*[ ]*//"))" >> "/dev/null" 2>&1 return $_exit_code From b835b3d9ce5613987e9eba13e6b352f870483d8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Havlas?= Date: Fri, 25 Mar 2016 23:29:33 +0100 Subject: [PATCH 166/216] Added support for multiple aliases/hosts in single line for ssh completion and plugin --- completion/available/ssh.completion.bash | 4 ++-- plugins/available/ssh.plugin.bash | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/completion/available/ssh.completion.bash b/completion/available/ssh.completion.bash index 19a52991..1ab08000 100644 --- a/completion/available/ssh.completion.bash +++ b/completion/available/ssh.completion.bash @@ -14,7 +14,7 @@ _sshcomplete() { # parse all defined hosts from .ssh/config if [ -r "$HOME/.ssh/config" ]; then - COMPREPLY=($(compgen -W "$(grep ^Host "$HOME/.ssh/config" | awk '{print $2}' )" ${OPTIONS}) ) + COMPREPLY=($(compgen -W "$(grep ^Host "$HOME/.ssh/config" | awk '{for (i=2; i<=NF; i++) print $i}' )" ${OPTIONS}) ) fi # parse all hosts found in .ssh/known_hosts @@ -26,7 +26,7 @@ _sshcomplete() { # parse hosts defined in /etc/hosts if [ -r /etc/hosts ]; then - COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$( grep -v '^[[:space:]]*$' /etc/hosts | grep -v '^#' | awk '{print $2}' )" ${OPTIONS}) ) + COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$( grep -v '^[[:space:]]*$' /etc/hosts | grep -v '^#' | awk '{for (i=2; i<=NF; i++) print $i}' )" ${OPTIONS}) ) fi return 0 diff --git a/plugins/available/ssh.plugin.bash b/plugins/available/ssh.plugin.bash index 4e17206c..f670b98c 100644 --- a/plugins/available/ssh.plugin.bash +++ b/plugins/available/ssh.plugin.bash @@ -15,5 +15,5 @@ function sshlist() { about 'list hosts defined in ssh config' group 'ssh' - awk '$1 ~ /Host$/ { print $2 }' ~/.ssh/config + awk '$1 ~ /Host$/ {for (i=2; i<=NF; i++) print $i}' ~/.ssh/config } From 3eb35f6054146d2a0300648ba0d21043b41a43f9 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Fri, 25 Mar 2016 17:46:46 -0500 Subject: [PATCH 167/216] Fix issue with PATH causing test failures I was seeing an issue where modifying PATH caused the Ruby plugin tests to fail. I fixed that and while digging around fixed an issue that would cause the tests to behave weirdly if run from any other location. This solves one of the issues noted in #687, but I haven't tried running the new tests from that PR with these changes. --- test/run | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/run b/test/run index 2efc35d0..f626521d 100755 --- a/test/run +++ b/test/run @@ -1,6 +1,5 @@ #!/usr/bin/env bash -PATH=$PATH:$(pwd)/bats/bin -set +e -[[ -z "$(which bats)" ]] && git clone --depth 1 https://github.com/sstephenson/bats.git -set -e -exec bats ${CI:+--tap} test/{lib,plugins} +_TEST_DIR="$(cd "$(dirname "$0")" && pwd)" +_BATS="${_TEST_DIR}/../bats/bin/bats" +[ ! -e $_BATS ] && git clone --depth 1 https://github.com/sstephenson/bats.git ${_TEST_DIR}/../bats +exec $_BATS ${CI:+--tap} ${_TEST_DIR}/{lib,plugins} From 1e826eefb4b2c782a426f28bffa0910b312c7980 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Fri, 25 Mar 2016 18:02:58 -0500 Subject: [PATCH 168/216] Allow overriding name of remote --- lib/helpers.bash | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/helpers.bash b/lib/helpers.bash index 6473d471..775eb43f 100755 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -127,8 +127,11 @@ _bash-it_update() { _group 'lib' cd "${BASH_IT}" + if [ -z $BASH_IT_REMOTE ]; then + BASH_IT_REMOTE="origin" + fi git fetch &> /dev/null - local status="$(git rev-list master..origin/master 2> /dev/null)" + local status="$(git rev-list master..${BASH_IT_REMOTE}/master 2> /dev/null)" if [[ -n "${status}" ]]; then git pull --rebase &> /dev/null if [[ $? -eq 0 ]]; then From 4cef46271dd1fec8763900a2a6fa4aa8946443d1 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Fri, 25 Mar 2016 18:06:03 -0500 Subject: [PATCH 169/216] Add sample BASH_IT_REMOTE to bash_profile template --- template/bash_profile.template.bash | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/template/bash_profile.template.bash b/template/bash_profile.template.bash index 94e04209..03c4d86c 100755 --- a/template/bash_profile.template.bash +++ b/template/bash_profile.template.bash @@ -7,6 +7,10 @@ export BASH_IT="{{BASH_IT}}" # location /.bash_it/themes/ export BASH_IT_THEME='bobby' +# (Advanced): Change this to the name of your remote repo if you +# cloned bash-it with a remote other than origin such as `bash-it`. +# export BASH_IT_REMOTE='bash-it' + # Your place for hosting Git repos. I use this for private repos. export GIT_HOSTING='git@git.domain.com' From 183c514881382b94f21b45c11aa56935af90280c Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Sun, 27 Mar 2016 00:03:40 +0100 Subject: [PATCH 170/216] Make #691 work on Linux --- plugins/available/fasd.plugin.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/available/fasd.plugin.bash b/plugins/available/fasd.plugin.bash index 9d0442e2..5db2b359 100755 --- a/plugins/available/fasd.plugin.bash +++ b/plugins/available/fasd.plugin.bash @@ -2,7 +2,7 @@ cite about-plugin about-plugin 'initialize fasd (see https://github.com/clvv/fasd)' __init_fasd() { - which -s fasd + which fasd &> /dev/null if [ $? -eq 1 ]; then echo -e "You must install fasd before you can use this plugin" echo -e "See: https://github.com/clvv/fasd" From fc70767315e7680fb5bce31460b1c451043c3b48 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Fri, 25 Mar 2016 17:46:46 -0500 Subject: [PATCH 171/216] Ensuring BASH_IT is set before running tests --- test/run | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test/run b/test/run index 6bc2f578..397aec9c 100755 --- a/test/run +++ b/test/run @@ -1,6 +1,12 @@ #!/usr/bin/env bash -PATH=$PATH:$(pwd)/bats/bin -set +e -[[ -z "$(which bats)" ]] && git clone --depth 1 https://github.com/sstephenson/bats.git -set -e -exec ./bats/bin/bats ${CI:+--tap} ./test/{lib,plugins} +test_directory="$(cd "$(dirname "$0")" && pwd)" +bats_executable="${test_directory}/../bats/bin/bats" + +[ ! -e $bats_executable ] && \ + git clone --depth 1 https://github.com/sstephenson/bats.git ${test_directory}/../bats + +if [ -z "${BASH_IT}" ]; then + export BASH_IT=$(cd ${test_directory} && dirname $(pwd)) +fi + +exec $bats_executable ${CI:+--tap} ${test_directory}/{lib,plugins} From 1e81df500456bace52377a4834da18fa56b027eb Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Tue, 5 Apr 2016 08:02:13 +0200 Subject: [PATCH 172/216] Added Autojump plugin See https://github.com/wting/autojump for more details. Currently only supports the version installed through Homebrew on OS X. Please feel free to provide a PR for supporting additional installation options. --- plugins/available/autojump.plugin.bash | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 plugins/available/autojump.plugin.bash diff --git a/plugins/available/autojump.plugin.bash b/plugins/available/autojump.plugin.bash new file mode 100644 index 00000000..7ba98879 --- /dev/null +++ b/plugins/available/autojump.plugin.bash @@ -0,0 +1,8 @@ +cite about-plugin +about-plugin 'Autojump configuration, see https://github.com/wting/autojump for more details' + +# Only supports the Homebrew variant at the moment. +# Feel free to provide a PR to support other install locations +if command -v brew &>/dev/null && [[ -s $(brew --prefix)/etc/profile.d/autojump.sh ]]; then + . $(brew --prefix)/etc/profile.d/autojump.sh +fi From 28c6d17632a714a56454ae2e8492667666bd0724 Mon Sep 17 00:00:00 2001 From: Paul Dapolito Date: Fri, 8 Apr 2016 09:38:06 -0700 Subject: [PATCH 173/216] Updating git.completion.bash to latest version from git source code mirror. --- completion/available/git.completion.bash | 119 ++++++++++++++--------- 1 file changed, 72 insertions(+), 47 deletions(-) diff --git a/completion/available/git.completion.bash b/completion/available/git.completion.bash index 5944c824..e3918c87 100644 --- a/completion/available/git.completion.bash +++ b/completion/available/git.completion.bash @@ -10,6 +10,7 @@ # *) local and remote tag names # *) .git/remotes file names # *) git 'subcommands' +# *) git email aliases for git-send-email # *) tree paths within 'ref:path/to/file' expressions # *) file paths within current working directory and index # *) common --long-options @@ -663,10 +664,11 @@ __git_list_porcelain_commands () check-mailmap) : plumbing;; check-ref-format) : plumbing;; checkout-index) : plumbing;; + column) : internal helper;; commit-tree) : plumbing;; count-objects) : infrequent;; - credential-cache) : credentials helper;; - credential-store) : credentials helper;; + credential) : credentials;; + credential-*) : credentials helper;; cvsexportcommit) : export;; cvsimport) : import;; cvsserver) : daemon;; @@ -735,35 +737,28 @@ __git_list_porcelain_commands () __git_porcelain_commands= __git_compute_porcelain_commands () { - __git_compute_all_commands test -n "$__git_porcelain_commands" || __git_porcelain_commands=$(__git_list_porcelain_commands) } +# Lists all set config variables starting with the given section prefix, +# with the prefix removed. +__git_get_config_variables () +{ + local section="$1" i IFS=$'\n' + for i in $(git --git-dir="$(__gitdir)" config --name-only --get-regexp "^$section\..*" 2>/dev/null); do + echo "${i#$section.}" + done +} + __git_pretty_aliases () { - local i IFS=$'\n' - for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); do - case "$i" in - pretty.*) - i="${i#pretty.}" - echo "${i/ */}" - ;; - esac - done + __git_get_config_variables "pretty" } __git_aliases () { - local i IFS=$'\n' - for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do - case "$i" in - alias.*) - i="${i#alias.}" - echo "${i/ */}" - ;; - esac - done + __git_get_config_variables "alias" } # __git_aliased_command requires 1 argument @@ -1114,7 +1109,7 @@ _git_commit () case "$cur" in --cleanup=*) - __gitcomp "default strip verbatim whitespace + __gitcomp "default scissors strip verbatim whitespace " "" "${cur##--cleanup=}" return ;; @@ -1174,7 +1169,7 @@ __git_diff_common_options="--stat --numstat --shortstat --summary --no-prefix --src-prefix= --dst-prefix= --inter-hunk-context= --patience --histogram --minimal - --raw --word-diff + --raw --word-diff --word-diff-regex= --dirstat --dirstat= --dirstat-by-file --dirstat-by-file= --cumulative --diff-algorithm= @@ -1317,6 +1312,7 @@ _git_grep () --full-name --line-number --extended-regexp --basic-regexp --fixed-strings --perl-regexp + --threads --files-with-matches --name-only --files-without-match --max-depth @@ -1448,7 +1444,7 @@ _git_log () return ;; --decorate=*) - __gitcomp "long short" "" "${cur##--decorate=}" + __gitcomp "full short no" "" "${cur##--decorate=}" return ;; --*) @@ -1673,7 +1669,10 @@ _git_push () _git_rebase () { local dir="$(__gitdir)" - if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then + if [ -f "$dir"/rebase-merge/interactive ]; then + __gitcomp "--continue --skip --abort --edit-todo" + return + elif [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then __gitcomp "--continue --skip --abort" return fi @@ -1689,8 +1688,12 @@ _git_rebase () --preserve-merges --stat --no-stat --committer-date-is-author-date --ignore-date --ignore-whitespace --whitespace= - --autosquash --fork-point --no-fork-point - --autostash + --autosquash --no-autosquash + --fork-point --no-fork-point + --autostash --no-autostash + --verify --no-verify + --keep-empty --root --force-rebase --no-ff + --exec " return @@ -1715,6 +1718,15 @@ __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all" _git_send_email () { + case "$prev" in + --to|--cc|--bcc|--from) + __gitcomp " + $(git --git-dir="$(__gitdir)" send-email --dump-aliases 2>/dev/null) + " + return + ;; + esac + case "$cur" in --confirm=*) __gitcomp " @@ -1739,6 +1751,12 @@ _git_send_email () " "" "${cur##--thread=}" return ;; + --to=*|--cc=*|--bcc=*|--from=*) + __gitcomp " + $(git --git-dir="$(__gitdir)" send-email --dump-aliases 2>/dev/null) + " "" "${cur#--*=}" + return + ;; --*) __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to --compose --confirm= --dry-run --envelope-sender @@ -1780,15 +1798,7 @@ __git_config_get_set_variables () c=$((--c)) done - git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null | - while read -r line - do - case "$line" in - *.*=*) - echo "${line/=*/}" - ;; - esac - done + git --git-dir="$(__gitdir)" config $config_file --name-only --list 2>/dev/null } _git_config () @@ -1803,7 +1813,7 @@ _git_config () return ;; branch.*.rebase) - __gitcomp "false true" + __gitcomp "false true preserve interactive" return ;; remote.pushdefault) @@ -1893,6 +1903,7 @@ _git_config () --get --get-all --get-regexp --add --unset --unset-all --remove-section --rename-section + --name-only " return ;; @@ -2049,6 +2060,7 @@ _git_config () core.sparseCheckout core.symlinks core.trustctime + core.untrackedCache core.warnAmbiguousRefs core.whitespace core.worktree @@ -2123,6 +2135,8 @@ _git_config () http.noEPSV http.postBuffer http.proxy + http.sslCipherList + http.sslVersion http.sslCAInfo http.sslCAPath http.sslCert @@ -2260,12 +2274,7 @@ _git_remote () __git_complete_remote_or_refspec ;; update) - local i c='' IFS=$'\n' - for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do - i="${i#remotes.}" - c="$c ${i/ */}" - done - __gitcomp "$c" + __gitcomp "$(__git_get_config_variables "remotes")" ;; *) ;; @@ -2292,6 +2301,11 @@ _git_reset () _git_revert () { + local dir="$(__gitdir)" + if [ -f "$dir"/REVERT_HEAD ]; then + __gitcomp "--continue --quit --abort" + return + fi case "$cur" in --*) __gitcomp "--edit --mainline --no-edit --no-commit --signoff" @@ -2360,7 +2374,7 @@ _git_show_branch () case "$cur" in --*) __gitcomp " - --all --remotes --topo-order --current --more= + --all --remotes --topo-order --date-order --current --more= --list --independent --merge-base --no-name --color --no-color --sha1-name --sparse --topics --reflog @@ -2373,7 +2387,7 @@ _git_show_branch () _git_stash () { - local save_opts='--keep-index --no-keep-index --quiet --patch' + local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked' local subcommands='save list show apply clear drop pop create branch' local subcommand="$(__git_find_on_cmdline "$subcommands")" if [ -z "$subcommand" ]; then @@ -2395,9 +2409,20 @@ _git_stash () apply,--*|pop,--*) __gitcomp "--index --quiet" ;; - show,--*|drop,--*|branch,--*) + drop,--*) + __gitcomp "--quiet" ;; - show,*|apply,*|drop,*|pop,*|branch,*) + show,--*|branch,--*) + ;; + branch,*) + if [ $cword -eq 3 ]; then + __gitcomp_nl "$(__git_refs)"; + else + __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \ + | sed -n -e 's/:.*//p')" + fi + ;; + show,*|apply,*|drop,*|pop,*) __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \ | sed -n -e 's/:.*//p')" ;; From 93d70a6150ff0d658811c7b22873c5eb152650ed Mon Sep 17 00:00:00 2001 From: Clay Reimann Date: Fri, 8 Apr 2016 09:19:48 -0500 Subject: [PATCH 174/216] Display the prompt when changing directories This change allows for the capture of the expanded prompt (rather than the raw `PS1`) so that it is easier to maintain context when changing directories. Fix is based on the comments from [this stackoverflow](http://stackoverflow.com/a/24006864) --- themes/iterate/iterate.theme.bash | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/themes/iterate/iterate.theme.bash b/themes/iterate/iterate.theme.bash index b417f34f..7b375f44 100644 --- a/themes/iterate/iterate.theme.bash +++ b/themes/iterate/iterate.theme.bash @@ -40,17 +40,20 @@ function git_prompt_info { echo -e "$SCM_PREFIX$SCM_BRANCH$SCM_STATE$SCM_GIT_AHEAD$SCM_GIT_BEHIND$SCM_GIT_STASH$SCM_SUFFIX" } -LAST_PROMPT_INFO="" +LAST_PROMPT="" function prompt_command() { - local prompt_info="\n${bold_cyan}$(scm_char)${yellow}$(ruby_version_prompt)${green}\w $(scm_prompt_info)" - if [ "$LAST_PROMPT_INFO" = "$prompt_info" ]; then - prompt_info="" + local new_PS1="${bold_cyan}$(scm_char)${yellow}$(ruby_version_prompt)${green}\w $(scm_prompt_info)" + local new_prompt=$(PS1="$new_PS1" "$BASH" --norc -i &1 | sed -n '${s/^\(.*\)exit$/\1/p;}') + + if [ "$LAST_PROMPT" = "$new_prompt" ]; then + new_PS1="" else - LAST_PROMPT_INFO="$prompt_info" + LAST_PROMPT="$new_prompt" fi + local wrap_char="" - [[ ${#prompt_info} -gt $(($COLUMNS/1)) ]] && wrap_char="\n" - PS1="${prompt_info}${green}${wrap_char}→${reset_color} " + [[ ${#new_PS1} -gt $(($COLUMNS/1)) ]] && wrap_char="\n" + PS1="${new_PS1}${green}${wrap_char}→${reset_color} " } PROMPT_COMMAND=prompt_command; From 2a3fde2b14aa6162c3474e84f5f7ac1bd7dcd1b5 Mon Sep 17 00:00:00 2001 From: Brian Malehorn Date: Sat, 9 Apr 2016 19:41:13 -0700 Subject: [PATCH 175/216] colors.theme.bash: pre-compute colors bash-it takes rather a while to startup, around 0.5 seconds on my laptop. After a bit of timing it appears the majority of the time is spent in themes/colors.theme.bash. The reason for that is the fancy abstraction layers that use $(). For example, consider this code: red="$(color reset red)" It will go through 9 forkexecs to evaluate: red="$(color reset red)" "$(__color_parse make_ansi reset red)" "$(__make_ansi reset red)" "\[\e[$(__reset red)m\]" "\[\e[0;$(__red)m\]" "\[\e[0;$(__color red)m\]" "\[\e[0;$(__color_normal_fg $(__color_red))m\]" "\[\e[0;$(__color_normal_fg 1)m\]" "\[\e[0;31m\]" With all the variables in colors.theme.bash, this adds up to hundreds of forks: $ strace -f bash ./colors.theme.bash 2>&1 | grep clone | wc -l 649 The solution is to replace the function with its result: -red="$(color reset red)" +red='\[\e[0;31m\]' This is safe, since colors.theme.bash never calls external functions or takes any input. So, its result can be safely hard-coded. This improves startup time dramatically. Try adding "time" to your .bashrc: # Load Bash It time source $BASH_IT/bash_it.sh before: real 0m0.462s user 0m0.100s sys 0m0.399s after: real 0m0.150s user 0m0.091s sys 0m0.064s --- themes/colors.theme.bash | 152 +++++++++++++++++++-------------------- 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/themes/colors.theme.bash b/themes/colors.theme.bash index 4374039e..da42f66b 100644 --- a/themes/colors.theme.bash +++ b/themes/colors.theme.bash @@ -182,89 +182,89 @@ function echo_color { } -black="$(color reset black)" -red="$(color reset red)" -green="$(color reset green)" -yellow="$(color reset yellow)" -blue="$(color reset blue)" -purple="$(color reset magenta)" -cyan="$(color reset cyan)" -white="$(color reset white bold)" -orange="$(color reset red fg bright)" +black="\[\e[0;30m\]" +red="\[\e[0;31m\]" +green="\[\e[0;32m\]" +yellow="\[\e[0;33m\]" +blue="\[\e[0;34m\]" +purple="\[\e[0;35m\]" +cyan="\[\e[0;36m\]" +white="\[\e[0;37;1m\]" +orange="\[\e[0;91m\]" -bold_black="$(color black bold)" -bold_red="$(color red bold)" -bold_green="$(color green bold)" -bold_yellow="$(color yellow bold)" -bold_blue="$(color blue bold)" -bold_purple="$(color magenta bold)" -bold_cyan="$(color cyan bold)" -bold_white="$(color white bold)" -bold_orange="$(color red fg bright bold)" +bold_black="\[\e[30;1m\]" +bold_red="\[\e[31;1m\]" +bold_green="\[\e[32;1m\]" +bold_yellow="\[\e[33;1m\]" +bold_blue="\[\e[34;1m\]" +bold_purple="\[\e[35;1m\]" +bold_cyan="\[\e[36;1m\]" +bold_white="\[\e[37;1m\]" +bold_orange="\[\e[91;1m\]" -underline_black="$(color black underline)" -underline_red="$(color red underline)" -underline_green="$(color green underline)" -underline_yellow="$(color yellow underline)" -underline_blue="$(color blue underline)" -underline_purple="$(color magenta underline)" -underline_cyan="$(color cyan underline)" -underline_white="$(color white underline)" -underline_orange="$(color red fg bright underline)" +underline_black="\[\e[30;4m\]" +underline_red="\[\e[31;4m\]" +underline_green="\[\e[32;4m\]" +underline_yellow="\[\e[33;4m\]" +underline_blue="\[\e[34;4m\]" +underline_purple="\[\e[35;4m\]" +underline_cyan="\[\e[36;4m\]" +underline_white="\[\e[37;4m\]" +underline_orange="\[\e[91;4m\]" -background_black="$(color black bg)" -background_red="$(color red bg)" -background_green="$(color green bg)" -background_yellow="$(color yellow bg)" -background_blue="$(color blue bg)" -background_purple="$(color magenta bg)" -background_cyan="$(color cyan bg)" -background_white="$(color white bg bold)" -background_orange="$(color red bg bright)" +background_black="\[\e[40m\]" +background_red="\[\e[41m\]" +background_green="\[\e[42m\]" +background_yellow="\[\e[43m\]" +background_blue="\[\e[44m\]" +background_purple="\[\e[45m\]" +background_cyan="\[\e[46m\]" +background_white="\[\e[47;1m\]" +background_orange="\[\e[101m\]" -normal="$(color reset)" -reset_color="$(__make_ansi '' 39)" +normal="\[\e[0m\]" +reset_color="\[\e[39m\]" # These colors are meant to be used with `echo -e` -echo_black="$(echo_color reset black)" -echo_red="$(echo_color reset red)" -echo_green="$(echo_color reset green)" -echo_yellow="$(echo_color reset yellow)" -echo_blue="$(echo_color reset blue)" -echo_purple="$(echo_color reset magenta)" -echo_cyan="$(echo_color reset cyan)" -echo_white="$(echo_color reset white bold)" -echo_orange="$(echo_color reset red fg bright)" +echo_black="\033[0;30m" +echo_red="\033[0;31m" +echo_green="\033[0;32m" +echo_yellow="\033[0;33m" +echo_blue="\033[0;34m" +echo_purple="\033[0;35m" +echo_cyan="\033[0;36m" +echo_white="\033[0;37;1m" +echo_orange="\033[0;91m" -echo_bold_black="$(echo_color black bold)" -echo_bold_red="$(echo_color red bold)" -echo_bold_green="$(echo_color green bold)" -echo_bold_yellow="$(echo_color yellow bold)" -echo_bold_blue="$(echo_color blue bold)" -echo_bold_purple="$(echo_color magenta bold)" -echo_bold_cyan="$(echo_color cyan bold)" -echo_bold_white="$(echo_color white bold)" -echo_bold_orange="$(echo_color red fg bright bold)" +echo_bold_black="\033[30;1m" +echo_bold_red="\033[31;1m" +echo_bold_green="\033[32;1m" +echo_bold_yellow="\033[33;1m" +echo_bold_blue="\033[34;1m" +echo_bold_purple="\033[35;1m" +echo_bold_cyan="\033[36;1m" +echo_bold_white="\033[37;1m" +echo_bold_orange="\033[91;1m" -echo_underline_black="$(echo_color black underline)" -echo_underline_red="$(echo_color red underline)" -echo_underline_green="$(echo_color green underline)" -echo_underline_yellow="$(echo_color yellow underline)" -echo_underline_blue="$(echo_color blue underline)" -echo_underline_purple="$(echo_color magenta underline)" -echo_underline_cyan="$(echo_color cyan underline)" -echo_underline_white="$(echo_color white underline)" -echo_underline_orange="$(echo_color red fg bright underline)" +echo_underline_black="\033[30;4m" +echo_underline_red="\033[31;4m" +echo_underline_green="\033[32;4m" +echo_underline_yellow="\033[33;4m" +echo_underline_blue="\033[34;4m" +echo_underline_purple="\033[35;4m" +echo_underline_cyan="\033[36;4m" +echo_underline_white="\033[37;4m" +echo_underline_orange="\033[91;4m" -echo_background_black="$(echo_color black bg)" -echo_background_red="$(echo_color red bg)" -echo_background_green="$(echo_color green bg)" -echo_background_yellow="$(echo_color yellow bg)" -echo_background_blue="$(echo_color blue bg)" -echo_background_purple="$(echo_color magenta bg)" -echo_background_cyan="$(echo_color cyan bg)" -echo_background_white="$(echo_color white bg bold)" -echo_background_orange="$(echo_color red bg bright)" +echo_background_black="\033[40m" +echo_background_red="\033[41m" +echo_background_green="\033[42m" +echo_background_yellow="\033[43m" +echo_background_blue="\033[44m" +echo_background_purple="\033[45m" +echo_background_cyan="\033[46m" +echo_background_white="\033[47;1m" +echo_background_orange="\033[101m" -echo_normal="$(echo_color reset)" -echo_reset_color="$(__make_echo '' 39)" +echo_normal="\033[0m" +echo_reset_color="\033[39m" From fb88e702131eae2087a5518829ce82e4d0505e18 Mon Sep 17 00:00:00 2001 From: Zhao Han Date: Mon, 11 Apr 2016 20:28:04 -0500 Subject: [PATCH 176/216] Update osx.aliases.bash --- aliases/available/osx.aliases.bash | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aliases/available/osx.aliases.bash b/aliases/available/osx.aliases.bash index 5bc8a1e2..3d09605e 100644 --- a/aliases/available/osx.aliases.bash +++ b/aliases/available/osx.aliases.bash @@ -18,6 +18,7 @@ alias textedit='open -a TextEdit' alias hex='open -a "Hex Fiend"' alias skype='open -a Skype' alias mou='open -a Mou' +alias subl='open -a Sublime\ Text --args' if [ -s /usr/bin/firefox ] ; then unalias firefox @@ -51,4 +52,4 @@ alias unmute="osascript -e 'set volume output muted false'" # Pin to the tail of long commands for an audible alert after long processes ## curl http://downloads.com/hugefile.zip; lmk -alias lmk="say 'Process complete.'" \ No newline at end of file +alias lmk="say 'Process complete.'" From 833ae57c9af94c71a53f75b1c26296993a374c0e Mon Sep 17 00:00:00 2001 From: Zhao Han Date: Mon, 11 Apr 2016 20:39:23 -0500 Subject: [PATCH 177/216] Add ggui (git gui) to git.aliases.bash --- aliases/available/git.aliases.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/aliases/available/git.aliases.bash b/aliases/available/git.aliases.bash index 2b8dc7c8..d80c0927 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -55,6 +55,7 @@ alias gtl="git tag -l" alias gnew="git log HEAD@{1}..HEAD@{0}" # Add uncommitted and unstaged changes to the last commit alias gcaa="git commit -a --amend -C HEAD" +alias ggui="git gui" case $OSTYPE in darwin*) From a9c5670c2cf0e67324cbd83a37f73da772f6aecf Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Tue, 12 Apr 2016 09:54:03 +0200 Subject: [PATCH 178/216] Added AC indicator support on OS X Not sure about the logic for returning 1/0 from the function, though - will have to clarify. --- plugins/available/battery.plugin.bash | 24 ++++++++++++------- .../powerline-multiline.theme.bash | 2 +- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/plugins/available/battery.plugin.bash b/plugins/available/battery.plugin.bash index 85af5097..9646b0e7 100644 --- a/plugins/available/battery.plugin.bash +++ b/plugins/available/battery.plugin.bash @@ -2,15 +2,23 @@ cite about-plugin about-plugin 'display info about your battery charge level' ac_adapter_connected(){ - if command_exists acpi; - then - acpi -a | grep "on-line" - if [[ "$?" -eq 0 ]]; then - return 1 - else - return 0 - fi + if command_exists acpi; + then + acpi -a | grep "on-line" + if [[ "$?" -eq 0 ]]; then + return 1 + else + return 0 fi + elif command_exists ioreg; + then + local IOREG_OUTPUT=$(ioreg -n AppleSmartBattery -r | grep '"ExternalConnected"' | awk -F'=' '{print $2}') + if [[ "$IOREG_OUTPUT" == *"Yes"* ]]; then + return 0 + else + return 1 + fi + fi } battery_percentage(){ diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index 27d51d52..68f7858c 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -153,7 +153,7 @@ function __powerline_battery_prompt { else color="${BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR}" fi - [[ "$(ac_adapter_connected)" ]] && battery_status="${BATTERY_AC_CHAR}${battery_status}" + ac_adapter_connected && battery_status="${BATTERY_AC_CHAR} ${battery_status}" echo "${battery_status}%|${color}" fi } From e5d50f0d979ada3b274a9c695170363cc81ace09 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Thu, 14 Apr 2016 08:16:32 +0200 Subject: [PATCH 179/216] Simplified logic for both Linux and OS X Avoiding the if statements, using exit code of `grep -q` instead. Reverted the change that adds a space after the AC char. Opting for a default value, allowing to override from one's profile. --- plugins/available/battery.plugin.bash | 16 ++++------------ .../powerline-multiline.theme.bash | 4 ++-- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/plugins/available/battery.plugin.bash b/plugins/available/battery.plugin.bash index 9646b0e7..80ff5bdb 100644 --- a/plugins/available/battery.plugin.bash +++ b/plugins/available/battery.plugin.bash @@ -4,20 +4,12 @@ about-plugin 'display info about your battery charge level' ac_adapter_connected(){ if command_exists acpi; then - acpi -a | grep "on-line" - if [[ "$?" -eq 0 ]]; then - return 1 - else - return 0 - fi + acpi -a | grep -q "on-line" + return $? elif command_exists ioreg; then - local IOREG_OUTPUT=$(ioreg -n AppleSmartBattery -r | grep '"ExternalConnected"' | awk -F'=' '{print $2}') - if [[ "$IOREG_OUTPUT" == *"Yes"* ]]; then - return 0 - else - return 1 - fi + ioreg -n AppleSmartBattery -r | grep -q '"ExternalConnected" = Yes' + return $? fi } diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index 68f7858c..c4833756 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -35,7 +35,7 @@ LAST_STATUS_THEME_PROMPT_COLOR=196 CLOCK_THEME_PROMPT_COLOR=240 -BATTERY_AC_CHAR="⚡" +BATTERY_AC_CHAR=${BATTERY_AC_CHAR:="⚡"} BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR=70 BATTERY_STATUS_THEME_PROMPT_LOW_COLOR=208 BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=160 @@ -153,7 +153,7 @@ function __powerline_battery_prompt { else color="${BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR}" fi - ac_adapter_connected && battery_status="${BATTERY_AC_CHAR} ${battery_status}" + ac_adapter_connected && battery_status="${BATTERY_AC_CHAR}${battery_status}" echo "${battery_status}%|${color}" fi } From d8a22e6a0efbd954c532875fa0c1a108079e211f Mon Sep 17 00:00:00 2001 From: AlfredoBejarano Date: Wed, 20 Apr 2016 00:07:18 -0500 Subject: [PATCH 180/216] Adds cooperkid theme by AlfredoBejarano --- themes/cooperkid/cooperkid.theme.bash | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 themes/cooperkid/cooperkid.theme.bash diff --git a/themes/cooperkid/cooperkid.theme.bash b/themes/cooperkid/cooperkid.theme.bash new file mode 100644 index 00000000..c4c58a73 --- /dev/null +++ b/themes/cooperkid/cooperkid.theme.bash @@ -0,0 +1,30 @@ +# ------------------------------------------------------------------# +# FILE: cooperkid.zsh-theme # +# BY: Alfredo Bejarano # +# BASED ON: Mr Briggs by Matt Brigg (matt@mattbriggs.net) # +# ------------------------------------------------------------------# + +SCM_THEME_PROMPT_DIRTY="${yellow}⚡${reset_color}" +SCM_THEME_PROMPT_AHEAD="${red}!${reset_color}" +SCM_THEME_PROMPT_CLEAN="${green}✓${reset_color}" +SCM_THEME_PROMPT_PREFIX=" " +SCM_THEME_PROMPT_SUFFIX="" +GIT_SHA_PREFIX="${blue}" +GIT_SHA_SUFFIX="${reset_color}" + +function git_short_sha() { + SHA=$(git rev-parse --short HEAD 2> /dev/null) && echo "$GIT_SHA_PREFIX$SHA$GIT_SHA_SUFFIX" +} + +function prompt() { + local return_status="" + local ruby="${red}$(ruby_version_prompt)${reset_color}" + local user_host="${green}\h @ \w${reset_color}" + local git_branch="$(git_short_sha)$(scm_prompt_info)" + local prompt_symbol=' ' + local prompt_char="${purple}>_${reset_color} " + + PS1="\n${user_host}${prompt_symbol}${ruby} ${git_branch} ${return_status}\n${prompt_char}" +} + +PROMPT_COMMAND=prompt From 07236c05714478d87572faffa865e38d19384932 Mon Sep 17 00:00:00 2001 From: AlfredoBejarano Date: Wed, 20 Apr 2016 00:29:02 -0500 Subject: [PATCH 181/216] Adds spacing to git status icon and changes the dirty and ahead icons --- themes/cooperkid/cooperkid.theme.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/themes/cooperkid/cooperkid.theme.bash b/themes/cooperkid/cooperkid.theme.bash index c4c58a73..d46c885e 100644 --- a/themes/cooperkid/cooperkid.theme.bash +++ b/themes/cooperkid/cooperkid.theme.bash @@ -4,9 +4,9 @@ # BASED ON: Mr Briggs by Matt Brigg (matt@mattbriggs.net) # # ------------------------------------------------------------------# -SCM_THEME_PROMPT_DIRTY="${yellow}⚡${reset_color}" -SCM_THEME_PROMPT_AHEAD="${red}!${reset_color}" -SCM_THEME_PROMPT_CLEAN="${green}✓${reset_color}" +SCM_THEME_PROMPT_DIRTY="${red} ✗${reset_color}" +SCM_THEME_PROMPT_AHEAD="${yellow} ↑${reset_color}" +SCM_THEME_PROMPT_CLEAN="${green} ✓${reset_color}" SCM_THEME_PROMPT_PREFIX=" " SCM_THEME_PROMPT_SUFFIX="" GIT_SHA_PREFIX="${blue}" From d2acf1664681464caf5409f7ea12ce14af69b163 Mon Sep 17 00:00:00 2001 From: AlfredoBejarano Date: Wed, 20 Apr 2016 00:32:28 -0500 Subject: [PATCH 182/216] Changes color for git status prompt --- themes/cooperkid/cooperkid.theme.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/cooperkid/cooperkid.theme.bash b/themes/cooperkid/cooperkid.theme.bash index d46c885e..60e4adec 100644 --- a/themes/cooperkid/cooperkid.theme.bash +++ b/themes/cooperkid/cooperkid.theme.bash @@ -20,7 +20,7 @@ function prompt() { local return_status="" local ruby="${red}$(ruby_version_prompt)${reset_color}" local user_host="${green}\h @ \w${reset_color}" - local git_branch="$(git_short_sha)$(scm_prompt_info)" + local git_branch="$(git_short_sha)${cyan}$(scm_prompt_info)${reset_color}" local prompt_symbol=' ' local prompt_char="${purple}>_${reset_color} " From cff6025338afed9ac0ede59b3e4b7722d4a64bbf Mon Sep 17 00:00:00 2001 From: AlfredoBejarano Date: Wed, 20 Apr 2016 00:58:08 -0500 Subject: [PATCH 183/216] Removes pipes around ruby version --- themes/cooperkid/cooperkid.theme.bash | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/themes/cooperkid/cooperkid.theme.bash b/themes/cooperkid/cooperkid.theme.bash index 60e4adec..ff4df68e 100644 --- a/themes/cooperkid/cooperkid.theme.bash +++ b/themes/cooperkid/cooperkid.theme.bash @@ -12,6 +12,15 @@ SCM_THEME_PROMPT_SUFFIX="" GIT_SHA_PREFIX="${blue}" GIT_SHA_SUFFIX="${reset_color}" +function rvm_version_prompt { + if which rvm &> /dev/null; then + rvm=$(rvm-prompt) || return + if [ -n "$rvm" ]; then + echo -e "$rvm" + fi + fi +} + function git_short_sha() { SHA=$(git rev-parse --short HEAD 2> /dev/null) && echo "$GIT_SHA_PREFIX$SHA$GIT_SHA_SUFFIX" } From ca889da3e7e6d82e6efd066ad0314683f215e437 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Thu, 3 Mar 2016 08:59:11 +0100 Subject: [PATCH 184/216] Removed embedded todo script Fixes #710 --- plugins/available/todo.plugin.bash | 19 +- plugins/available/todo/todo.cfg | 75 -- plugins/available/todo/todo.sh | 1321 ------------------------ plugins/available/todo/todo_completion | 107 -- 4 files changed, 5 insertions(+), 1517 deletions(-) delete mode 100644 plugins/available/todo/todo.cfg delete mode 100755 plugins/available/todo/todo.sh delete mode 100644 plugins/available/todo/todo_completion diff --git a/plugins/available/todo.plugin.bash b/plugins/available/todo.plugin.bash index ef9266e2..cf1479e2 100755 --- a/plugins/available/todo.plugin.bash +++ b/plugins/available/todo.plugin.bash @@ -1,21 +1,12 @@ #!/bin/bash +cite about-plugin +about-plugin 'Todo.txt integration' # you may override any of the exported variables below in your .bash_profile -if [ -z "$TODO_DIR" ]; then - export TODO_DIR=$BASH_IT/custom # store todo items in user's custom dir, ignored by git -fi if [ -z "$TODOTXT_DEFAULT_ACTION" ]; then - export TODOTXT_DEFAULT_ACTION=ls # typing 't' by itself will list current todos -fi -if [ -z "$TODO_SRC_DIR" ]; then - export TODO_SRC_DIR=$BASH_IT/plugins/available/todo + # typing 't' by itself will list current todos + export TODOTXT_DEFAULT_ACTION=ls fi -# respect ENV var set in .bash_profile, default is 't' -alias $TODO='$TODO_SRC_DIR/todo.sh -d $TODO_SRC_DIR/todo.cfg' - -pathmunge $TODO_SRC_DIR after - -source $TODO_SRC_DIR/todo_completion # bash completion for todo.sh -complete -F _todo $TODO # enable completion for 't' alias +alias t='todo.sh' diff --git a/plugins/available/todo/todo.cfg b/plugins/available/todo/todo.cfg deleted file mode 100644 index d79bf77a..00000000 --- a/plugins/available/todo/todo.cfg +++ /dev/null @@ -1,75 +0,0 @@ -# === EDIT FILE LOCATIONS BELOW === - -# Your todo/done/report.txt locations -export TODO_FILE="$TODO_DIR/todo.txt" -export DONE_FILE="$TODO_DIR/done.txt" -export REPORT_FILE="$TODO_DIR/report.txt" - -# You can customize your actions directory location -#export TODO_ACTIONS_DIR="$HOME/.todo.actions.d" - -# == EDIT FILE LOCATIONS ABOVE === - -# === COLOR MAP === - -## Text coloring and formatting is done by inserting ANSI escape codes. -## If you have re-mapped your color codes, or use the todo.txt -## output in another output system (like Conky), you may need to -## over-ride by uncommenting and editing these defaults. -## If you change any of these here, you also need to uncomment -## the defaults in the COLORS section below. Otherwise, todo.txt -## will still use the defaults! - -# export BLACK='\\033[0;30m' -# export RED='\\033[0;31m' -# export GREEN='\\033[0;32m' -# export BROWN='\\033[0;33m' -# export BLUE='\\033[0;34m' -# export PURPLE='\\033[0;35m' -# export CYAN='\\033[0;36m' -# export LIGHT_GREY='\\033[0;37m' -# export DARK_GREY='\\033[1;30m' -# export LIGHT_RED='\\033[1;31m' -# export LIGHT_GREEN='\\033[1;32m' -# export YELLOW='\\033[1;33m' -# export LIGHT_BLUE='\\033[1;34m' -# export LIGHT_PURPLE='\\033[1;35m' -# export LIGHT_CYAN='\\033[1;36m' -# export WHITE='\\033[1;37m' -# export DEFAULT='\\033[0m' - -# === COLORS === - -## Uncomment and edit to override these defaults. -## Reference the constants from the color map above, -## or use $NONE to disable highlighting. -# -# Priorities can be any upper-case letter. -# A,B,C are highlighted; you can add coloring for more. -# -# export PRI_A=$YELLOW # color for A priority -# export PRI_B=$GREEN # color for B priority -# export PRI_C=$LIGHT_BLUE # color for C priority -# export PRI_D=... # define your own -# export PRI_X=$WHITE # color unless explicitly defined - -# There is highlighting for tasks that have been done, -# but haven't been archived yet. -# -# export COLOR_DONE=$LIGHT_GREY - -# === BEHAVIOR === - -## customize list output -# -# TODOTXT_SORT_COMMAND will filter after line numbers are -# inserted, but before colorization, and before hiding of -# priority, context, and project. -# -# export TODOTXT_SORT_COMMAND='env LC_COLLATE=C sort -f -k2' - -# TODOTXT_FINAL_FILTER will filter list output after colorization, -# priority hiding, context hiding, and project hiding. That is, -# just before the list output is displayed. -# -# export TODOTXT_FINAL_FILTER='cat' diff --git a/plugins/available/todo/todo.sh b/plugins/available/todo/todo.sh deleted file mode 100755 index c2e149f0..00000000 --- a/plugins/available/todo/todo.sh +++ /dev/null @@ -1,1321 +0,0 @@ -#! /bin/bash - -# === HEAVY LIFTING === -shopt -s extglob extquote - -# NOTE: Todo.sh requires the .todo/config configuration file to run. -# Place the .todo/config file in your home directory or use the -d option for a custom location. - -[ -f VERSION-FILE ] && . VERSION-FILE || VERSION="2.9" -version() { - cat <<-EndVersion - TODO.TXT Command Line Interface v$VERSION - - First release: 5/11/2006 - Original conception by: Gina Trapani (http://ginatrapani.org) - Contributors: http://github.com/ginatrapani/todo.txt-cli/network - License: GPL, http://www.gnu.org/copyleft/gpl.html - More information and mailing list at http://todotxt.com - Code repository: http://github.com/ginatrapani/todo.txt-cli/tree/master - EndVersion - exit 1 -} - -# Set script name and full path early. -TODO_SH=$(basename "$0") -TODO_FULL_SH="$0" -export TODO_SH TODO_FULL_SH - -oneline_usage="$TODO_SH [-fhpantvV] [-d todo_config] action [task_number] [task_description]" - -usage() -{ - cat <<-EndUsage - Usage: $oneline_usage - Try '$TODO_SH -h' for more information. - EndUsage - exit 1 -} - -shorthelp() -{ - cat <<-EndHelp - Usage: $oneline_usage - - Actions: - add|a "THING I NEED TO DO +project @context" - addm "THINGS I NEED TO DO - MORE THINGS I NEED TO DO" - addto DEST "TEXT TO ADD" - append|app ITEM# "TEXT TO APPEND" - archive - command [ACTIONS] - deduplicate - del|rm ITEM# [TERM] - depri|dp ITEM#[, ITEM#, ITEM#, ...] - do ITEM#[, ITEM#, ITEM#, ...] - help - list|ls [TERM...] - listall|lsa [TERM...] - listaddons - listcon|lsc - listfile|lf [SRC [TERM...]] - listpri|lsp [PRIORITIES] [TERM...] - listproj|lsprj [TERM...] - move|mv ITEM# DEST [SRC] - prepend|prep ITEM# "TEXT TO PREPEND" - pri|p ITEM# PRIORITY - replace ITEM# "UPDATED TODO" - report - shorthelp - - Actions can be added and overridden using scripts in the actions - directory. - EndHelp - - # Only list the one-line usage from the add-on actions. This assumes that - # add-ons use the same usage indentation structure as todo.sh. - addonHelp | grep -e '^ Add-on Actions:' -e '^ [[:alpha:]]' - - cat <<-EndHelpFooter - - See "help" for more details. - EndHelpFooter - exit 0 -} - -help() -{ - cat <<-EndOptionsHelp - Usage: $oneline_usage - - Options: - -@ - Hide context names in list output. Use twice to show context - names (default). - -+ - Hide project names in list output. Use twice to show project - names (default). - -c - Color mode - -d CONFIG_FILE - Use a configuration file other than the default ~/.todo/config - -f - Forces actions without confirmation or interactive input - -h - Display a short help message; same as action "shorthelp" - -p - Plain mode turns off colors - -P - Hide priority labels in list output. Use twice to show - priority labels (default). - -a - Don't auto-archive tasks automatically on completion - -A - Auto-archive tasks automatically on completion - -n - Don't preserve line numbers; automatically remove blank lines - on task deletion - -N - Preserve line numbers - -t - Prepend the current date to a task automatically - when it's added. - -T - Do not prepend the current date to a task automatically - when it's added. - -v - Verbose mode turns on confirmation messages - -vv - Extra verbose mode prints some debugging information and - additional help text - -V - Displays version, license and credits - -x - Disables TODOTXT_FINAL_FILTER - - - EndOptionsHelp - - [ $TODOTXT_VERBOSE -gt 1 ] && cat <<-'EndVerboseHelp' - Environment variables: - TODOTXT_AUTO_ARCHIVE is same as option -a (0)/-A (1) - TODOTXT_CFG_FILE=CONFIG_FILE is same as option -d CONFIG_FILE - TODOTXT_FORCE=1 is same as option -f - TODOTXT_PRESERVE_LINE_NUMBERS is same as option -n (0)/-N (1) - TODOTXT_PLAIN is same as option -p (1)/-c (0) - TODOTXT_DATE_ON_ADD is same as option -t (1)/-T (0) - TODOTXT_VERBOSE=1 is same as option -v - TODOTXT_DISABLE_FILTER=1 is same as option -x - TODOTXT_DEFAULT_ACTION="" run this when called with no arguments - TODOTXT_SORT_COMMAND="sort ..." customize list output - TODOTXT_FINAL_FILTER="sed ..." customize list after color, P@+ hiding - TODOTXT_SOURCEVAR=\$DONE_FILE use another source for listcon, listproj - - - EndVerboseHelp - cat <<-EndActionsHelp - Built-in Actions: - add "THING I NEED TO DO +project @context" - a "THING I NEED TO DO +project @context" - Adds THING I NEED TO DO to your todo.txt file on its own line. - Project and context notation optional. - Quotes optional. - - addm "FIRST THING I NEED TO DO +project1 @context - SECOND THING I NEED TO DO +project2 @context" - Adds FIRST THING I NEED TO DO to your todo.txt on its own line and - Adds SECOND THING I NEED TO DO to you todo.txt on its own line. - Project and context notation optional. - - addto DEST "TEXT TO ADD" - Adds a line of text to any file located in the todo.txt directory. - For example, addto inbox.txt "decide about vacation" - - append ITEM# "TEXT TO APPEND" - app ITEM# "TEXT TO APPEND" - Adds TEXT TO APPEND to the end of the task on line ITEM#. - Quotes optional. - - archive - Moves all done tasks from todo.txt to done.txt and removes blank lines. - - command [ACTIONS] - Runs the remaining arguments using only todo.sh builtins. - Will not call any .todo.actions.d scripts. - - deduplicate - Removes duplicate lines from todo.txt. - - del ITEM# [TERM] - rm ITEM# [TERM] - Deletes the task on line ITEM# in todo.txt. - If TERM specified, deletes only TERM from the task. - - depri ITEM#[, ITEM#, ITEM#, ...] - dp ITEM#[, ITEM#, ITEM#, ...] - Deprioritizes (removes the priority) from the task(s) - on line ITEM# in todo.txt. - - do ITEM#[, ITEM#, ITEM#, ...] - Marks task(s) on line ITEM# as done in todo.txt. - - help - Display this help message. - - list [TERM...] - ls [TERM...] - Displays all tasks that contain TERM(s) sorted by priority with line - numbers. Each task must match all TERM(s) (logical AND); to display - tasks that contain any TERM (logical OR), use - "TERM1\|TERM2\|..." (with quotes), or TERM1\\\|TERM2 (unquoted). - Hides all tasks that contain TERM(s) preceded by a - minus sign (i.e. -TERM). If no TERM specified, lists entire todo.txt. - - listall [TERM...] - lsa [TERM...] - Displays all the lines in todo.txt AND done.txt that contain TERM(s) - sorted by priority with line numbers. Hides all tasks that - contain TERM(s) preceded by a minus sign (i.e. -TERM). If no - TERM specified, lists entire todo.txt AND done.txt - concatenated and sorted. - - listaddons - Lists all added and overridden actions in the actions directory. - - listcon - lsc - Lists all the task contexts that start with the @ sign in todo.txt. - - listfile [SRC [TERM...]] - lf [SRC [TERM...]] - Displays all the lines in SRC file located in the todo.txt directory, - sorted by priority with line numbers. If TERM specified, lists - all lines that contain TERM(s) in SRC file. Hides all tasks that - contain TERM(s) preceded by a minus sign (i.e. -TERM). - Without any arguments, the names of all text files in the todo.txt - directory are listed. - - listpri [PRIORITIES] [TERM...] - lsp [PRIORITIES] [TERM...] - Displays all tasks prioritized PRIORITIES. - PRIORITIES can be a single one (A) or a range (A-C). - If no PRIORITIES specified, lists all prioritized tasks. - If TERM specified, lists only prioritized tasks that contain TERM(s). - Hides all tasks that contain TERM(s) preceded by a minus sign - (i.e. -TERM). - - listproj - lsprj - Lists all the projects (terms that start with a + sign) in - todo.txt. - - move ITEM# DEST [SRC] - mv ITEM# DEST [SRC] - Moves a line from source text file (SRC) to destination text file (DEST). - Both source and destination file must be located in the directory defined - in the configuration directory. When SRC is not defined - it's by default todo.txt. - - prepend ITEM# "TEXT TO PREPEND" - prep ITEM# "TEXT TO PREPEND" - Adds TEXT TO PREPEND to the beginning of the task on line ITEM#. - Quotes optional. - - pri ITEM# PRIORITY - p ITEM# PRIORITY - Adds PRIORITY to task on line ITEM#. If the task is already - prioritized, replaces current priority with new PRIORITY. - PRIORITY must be a letter between A and Z. - - replace ITEM# "UPDATED TODO" - Replaces task on line ITEM# with UPDATED TODO. - - report - Adds the number of open tasks and done tasks to report.txt. - - shorthelp - List the one-line usage of all built-in and add-on actions. - - EndActionsHelp - - addonHelp - exit 1 -} - -addonHelp() -{ - if [ -d "$TODO_ACTIONS_DIR" ]; then - didPrintAddonActionsHeader= - for action in "$TODO_ACTIONS_DIR"/* - do - if [ -f "$action" -a -x "$action" ]; then - if [ ! "$didPrintAddonActionsHeader" ]; then - cat <<-EndAddonActionsHeader - Add-on Actions: - EndAddonActionsHeader - didPrintAddonActionsHeader=1 - fi - "$action" usage - fi - done - fi -} - -die() -{ - echo "$*" - exit 1 -} - -cleaninput() -{ - # Parameters: When $1 = "for sed", performs additional escaping for use - # in sed substitution with "|" separators. - # Precondition: $input contains text to be cleaned. - # Postcondition: Modifies $input. - - # Replace CR and LF with space; tasks always comprise a single line. - input=${input//$'\r'/ } - input=${input//$'\n'/ } - - if [ "$1" = "for sed" ]; then - # This action uses sed with "|" as the substitution separator, and & as - # the matched string; these must be escaped. - # Backslashes must be escaped, too, and before the other stuff. - input=${input//\\/\\\\} - input=${input//|/\\|} - input=${input//&/\\&} - fi -} - -getPrefix() -{ - # Parameters: $1: todo file; empty means $TODO_FILE. - # Returns: Uppercase FILE prefix to be used in place of "TODO:" where - # a different todo file can be specified. - local base=$(basename "${1:-$TODO_FILE}") - echo "${base%%.[^.]*}" | tr 'a-z' 'A-Z' -} - -getTodo() -{ - # Parameters: $1: task number - # $2: Optional todo file - # Precondition: $errmsg contains usage message. - # Postcondition: $todo contains task text. - - local item=$1 - [ -z "$item" ] && die "$errmsg" - [ "${item//[0-9]/}" ] && die "$errmsg" - - todo=$(sed "$item!d" "${2:-$TODO_FILE}") - [ -z "$todo" ] && die "$(getPrefix "$2"): No task $item." -} -getNewtodo() -{ - # Parameters: $1: task number - # $2: Optional todo file - # Precondition: None. - # Postcondition: $newtodo contains task text. - - local item=$1 - [ -z "$item" ] && die 'Programming error: $item should exist.' - [ "${item//[0-9]/}" ] && die 'Programming error: $item should be numeric.' - - newtodo=$(sed "$item!d" "${2:-$TODO_FILE}") - [ -z "$newtodo" ] && die "$(getPrefix "$2"): No updated task $item." -} - -replaceOrPrepend() -{ - action=$1; shift - case "$action" in - replace) - backref= - querytext="Replacement: " - ;; - prepend) - backref=' &' - querytext="Prepend: " - ;; - esac - shift; item=$1; shift - getTodo "$item" - - if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then - echo -n "$querytext" - read input - else - input=$* - fi - cleaninput "for sed" - - # Retrieve existing priority and prepended date - priority=$(sed -e "$item!d" -e $item's/^\((.) \)\{0,1\}\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} \)\{0,1\}.*/\1/' "$TODO_FILE") - prepdate=$(sed -e "$item!d" -e $item's/^\((.) \)\{0,1\}\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} \)\{0,1\}.*/\2/' "$TODO_FILE") - - if [ "$prepdate" -a "$action" = "replace" ] && [ "$(echo "$input"|sed -e 's/^\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\}\)\{0,1\}.*/\1/')" ]; then - # If the replaced text starts with a date, it will replace the existing - # date, too. - prepdate= - fi - - # Temporarily remove any existing priority and prepended date, perform the - # change (replace/prepend) and re-insert the existing priority and prepended - # date again. - sed -i.bak -e "$item s/^${priority}${prepdate}//" -e "$item s|^.*|${priority}${prepdate}${input}${backref}|" "$TODO_FILE" - if [ $TODOTXT_VERBOSE -gt 0 ]; then - getNewtodo "$item" - case "$action" in - replace) - echo "$item $todo" - echo "TODO: Replaced task with:" - echo "$item $newtodo" - ;; - prepend) - echo "$item $newtodo" - ;; - esac - fi -} - -#Preserving environment variables so they don't get clobbered by the config file -OVR_TODOTXT_AUTO_ARCHIVE="$TODOTXT_AUTO_ARCHIVE" -OVR_TODOTXT_FORCE="$TODOTXT_FORCE" -OVR_TODOTXT_PRESERVE_LINE_NUMBERS="$TODOTXT_PRESERVE_LINE_NUMBERS" -OVR_TODOTXT_PLAIN="$TODOTXT_PLAIN" -OVR_TODOTXT_DATE_ON_ADD="$TODOTXT_DATE_ON_ADD" -OVR_TODOTXT_DISABLE_FILTER="$TODOTXT_DISABLE_FILTER" -OVR_TODOTXT_VERBOSE="$TODOTXT_VERBOSE" -OVR_TODOTXT_DEFAULT_ACTION="$TODOTXT_DEFAULT_ACTION" -OVR_TODOTXT_SORT_COMMAND="$TODOTXT_SORT_COMMAND" -OVR_TODOTXT_FINAL_FILTER="$TODOTXT_FINAL_FILTER" - -# == PROCESS OPTIONS == -while getopts ":fhpcnNaAtTvVx+@Pd:" Option -do - case $Option in - '@' ) - ## HIDE_CONTEXT_NAMES starts at zero (false); increment it to one - ## (true) the first time this flag is seen. Each time the flag - ## is seen after that, increment it again so that an even - ## number shows context names and an odd number hides context - ## names. - : $(( HIDE_CONTEXT_NAMES++ )) - if [ $(( $HIDE_CONTEXT_NAMES % 2 )) -eq 0 ] - then - ## Zero or even value -- show context names - unset HIDE_CONTEXTS_SUBSTITUTION - else - ## One or odd value -- hide context names - export HIDE_CONTEXTS_SUBSTITUTION='[[:space:]]@[[:graph:]]\{1,\}' - fi - ;; - '+' ) - ## HIDE_PROJECT_NAMES starts at zero (false); increment it to one - ## (true) the first time this flag is seen. Each time the flag - ## is seen after that, increment it again so that an even - ## number shows project names and an odd number hides project - ## names. - : $(( HIDE_PROJECT_NAMES++ )) - if [ $(( $HIDE_PROJECT_NAMES % 2 )) -eq 0 ] - then - ## Zero or even value -- show project names - unset HIDE_PROJECTS_SUBSTITUTION - else - ## One or odd value -- hide project names - export HIDE_PROJECTS_SUBSTITUTION='[[:space:]][+][[:graph:]]\{1,\}' - fi - ;; - a ) - OVR_TODOTXT_AUTO_ARCHIVE=0 - ;; - A ) - OVR_TODOTXT_AUTO_ARCHIVE=1 - ;; - c ) - OVR_TODOTXT_PLAIN=0 - ;; - d ) - TODOTXT_CFG_FILE=$OPTARG - ;; - f ) - OVR_TODOTXT_FORCE=1 - ;; - h ) - # Short-circuit option parsing and forward to the action. - # Cannot just invoke shorthelp() because we need the configuration - # processed to locate the add-on actions directory. - set -- '-h' 'shorthelp' - ;; - n ) - OVR_TODOTXT_PRESERVE_LINE_NUMBERS=0 - ;; - N ) - OVR_TODOTXT_PRESERVE_LINE_NUMBERS=1 - ;; - p ) - OVR_TODOTXT_PLAIN=1 - ;; - P ) - ## HIDE_PRIORITY_LABELS starts at zero (false); increment it to one - ## (true) the first time this flag is seen. Each time the flag - ## is seen after that, increment it again so that an even - ## number shows priority labels and an odd number hides priority - ## labels. - : $(( HIDE_PRIORITY_LABELS++ )) - if [ $(( $HIDE_PRIORITY_LABELS % 2 )) -eq 0 ] - then - ## Zero or even value -- show priority labels - unset HIDE_PRIORITY_SUBSTITUTION - else - ## One or odd value -- hide priority labels - export HIDE_PRIORITY_SUBSTITUTION="([A-Z])[[:space:]]" - fi - ;; - t ) - OVR_TODOTXT_DATE_ON_ADD=1 - ;; - T ) - OVR_TODOTXT_DATE_ON_ADD=0 - ;; - v ) - : $(( TODOTXT_VERBOSE++ )) - ;; - V ) - version - ;; - x ) - OVR_TODOTXT_DISABLE_FILTER=1 - ;; - esac -done -shift $(($OPTIND - 1)) - -# defaults if not yet defined -TODOTXT_VERBOSE=${TODOTXT_VERBOSE:-1} -TODOTXT_PLAIN=${TODOTXT_PLAIN:-0} -TODOTXT_CFG_FILE=${TODOTXT_CFG_FILE:-"$HOME/.todo/config"} -TODOTXT_FORCE=${TODOTXT_FORCE:-0} -TODOTXT_PRESERVE_LINE_NUMBERS=${TODOTXT_PRESERVE_LINE_NUMBERS:-1} -TODOTXT_AUTO_ARCHIVE=${TODOTXT_AUTO_ARCHIVE:-1} -TODOTXT_DATE_ON_ADD=${TODOTXT_DATE_ON_ADD:-0} -TODOTXT_DEFAULT_ACTION=${TODOTXT_DEFAULT_ACTION:-} -TODOTXT_SORT_COMMAND=${TODOTXT_SORT_COMMAND:-env LC_COLLATE=C sort -f -k2} -TODOTXT_DISABLE_FILTER=${TODOTXT_DISABLE_FILTER:-} -TODOTXT_FINAL_FILTER=${TODOTXT_FINAL_FILTER:-cat} - -# Export all TODOTXT_* variables -export ${!TODOTXT_@} - -# Default color map -export NONE='' -export BLACK='\\033[0;30m' -export RED='\\033[0;31m' -export GREEN='\\033[0;32m' -export BROWN='\\033[0;33m' -export BLUE='\\033[0;34m' -export PURPLE='\\033[0;35m' -export CYAN='\\033[0;36m' -export LIGHT_GREY='\\033[0;37m' -export DARK_GREY='\\033[1;30m' -export LIGHT_RED='\\033[1;31m' -export LIGHT_GREEN='\\033[1;32m' -export YELLOW='\\033[1;33m' -export LIGHT_BLUE='\\033[1;34m' -export LIGHT_PURPLE='\\033[1;35m' -export LIGHT_CYAN='\\033[1;36m' -export WHITE='\\033[1;37m' -export DEFAULT='\\033[0m' - -# Default priority->color map. -export PRI_A=$YELLOW # color for A priority -export PRI_B=$GREEN # color for B priority -export PRI_C=$LIGHT_BLUE # color for C priority -export PRI_X=$WHITE # color unless explicitly defined - -# Default highlight colors. -export COLOR_DONE=$LIGHT_GREY # color for done (but not yet archived) tasks - -# Default sentence delimiters for todo.sh append. -# If the text to be appended to the task begins with one of these characters, no -# whitespace is inserted in between. This makes appending to an enumeration -# (todo.sh add 42 ", foo") syntactically correct. -export SENTENCE_DELIMITERS=',.:;' - -[ -e "$TODOTXT_CFG_FILE" ] || { - CFG_FILE_ALT="$HOME/todo.cfg" - - if [ -e "$CFG_FILE_ALT" ] - then - TODOTXT_CFG_FILE="$CFG_FILE_ALT" - fi -} - -[ -e "$TODOTXT_CFG_FILE" ] || { - CFG_FILE_ALT="$HOME/.todo.cfg" - - if [ -e "$CFG_FILE_ALT" ] - then - TODOTXT_CFG_FILE="$CFG_FILE_ALT" - fi -} - -[ -e "$TODOTXT_CFG_FILE" ] || { - CFG_FILE_ALT=$(dirname "$0")"/todo.cfg" - - if [ -e "$CFG_FILE_ALT" ] - then - TODOTXT_CFG_FILE="$CFG_FILE_ALT" - fi -} - - -if [ -z "$TODO_ACTIONS_DIR" -o ! -d "$TODO_ACTIONS_DIR" ] -then - TODO_ACTIONS_DIR="$HOME/.todo/actions" - export TODO_ACTIONS_DIR -fi - -[ -d "$TODO_ACTIONS_DIR" ] || { - TODO_ACTIONS_DIR_ALT="$HOME/.todo.actions.d" - - if [ -d "$TODO_ACTIONS_DIR_ALT" ] - then - TODO_ACTIONS_DIR="$TODO_ACTIONS_DIR_ALT" - fi -} - -# === SANITY CHECKS (thanks Karl!) === -[ -r "$TODOTXT_CFG_FILE" ] || die "Fatal Error: Cannot read configuration file $TODOTXT_CFG_FILE" - -. "$TODOTXT_CFG_FILE" - -# === APPLY OVERRIDES -if [ -n "$OVR_TODOTXT_AUTO_ARCHIVE" ] ; then - TODOTXT_AUTO_ARCHIVE="$OVR_TODOTXT_AUTO_ARCHIVE" -fi -if [ -n "$OVR_TODOTXT_FORCE" ] ; then - TODOTXT_FORCE="$OVR_TODOTXT_FORCE" -fi -if [ -n "$OVR_TODOTXT_PRESERVE_LINE_NUMBERS" ] ; then - TODOTXT_PRESERVE_LINE_NUMBERS="$OVR_TODOTXT_PRESERVE_LINE_NUMBERS" -fi -if [ -n "$OVR_TODOTXT_PLAIN" ] ; then - TODOTXT_PLAIN="$OVR_TODOTXT_PLAIN" -fi -if [ -n "$OVR_TODOTXT_DATE_ON_ADD" ] ; then - TODOTXT_DATE_ON_ADD="$OVR_TODOTXT_DATE_ON_ADD" -fi -if [ -n "$OVR_TODOTXT_DISABLE_FILTER" ] ; then - TODOTXT_DISABLE_FILTER="$OVR_TODOTXT_DISABLE_FILTER" -fi -if [ -n "$OVR_TODOTXT_VERBOSE" ] ; then - TODOTXT_VERBOSE="$OVR_TODOTXT_VERBOSE" -fi -if [ -n "$OVR_TODOTXT_DEFAULT_ACTION" ] ; then - TODOTXT_DEFAULT_ACTION="$OVR_TODOTXT_DEFAULT_ACTION" -fi -if [ -n "$OVR_TODOTXT_SORT_COMMAND" ] ; then - TODOTXT_SORT_COMMAND="$OVR_TODOTXT_SORT_COMMAND" -fi -if [ -n "$OVR_TODOTXT_FINAL_FILTER" ] ; then - TODOTXT_FINAL_FILTER="$OVR_TODOTXT_FINAL_FILTER" -fi - -ACTION=${1:-$TODOTXT_DEFAULT_ACTION} - -[ -z "$ACTION" ] && usage -[ -d "$TODO_DIR" ] || die "Fatal Error: $TODO_DIR is not a directory" -( cd "$TODO_DIR" ) || die "Fatal Error: Unable to cd to $TODO_DIR" - -[ -f "$TODO_FILE" ] || cp /dev/null "$TODO_FILE" -[ -f "$DONE_FILE" ] || cp /dev/null "$DONE_FILE" -[ -f "$REPORT_FILE" ] || cp /dev/null "$REPORT_FILE" - -if [ $TODOTXT_PLAIN = 1 ]; then - for clr in ${!PRI_@}; do - export $clr=$NONE - done - PRI_X=$NONE - DEFAULT=$NONE - COLOR_DONE=$NONE -fi - -_addto() { - file="$1" - input="$2" - cleaninput - - if [[ $TODOTXT_DATE_ON_ADD = 1 ]]; then - now=$(date '+%Y-%m-%d') - input=$(echo "$input" | sed -e 's/^\(([A-Z]) \)\{0,1\}/\1'"$now /") - fi - echo "$input" >> "$file" - if [ $TODOTXT_VERBOSE -gt 0 ]; then - TASKNUM=$(sed -n '$ =' "$file") - echo "$TASKNUM $input" - echo "$(getPrefix "$file"): $TASKNUM added." - fi -} - -shellquote() -{ - typeset -r qq=\'; printf %s\\n "'${1//\'/${qq}\\${qq}${qq}}'"; -} - -filtercommand() -{ - filter=${1:-} - shift - post_filter=${1:-} - shift - - for search_term - do - ## See if the first character of $search_term is a dash - if [ "${search_term:0:1}" != '-' ] - then - ## First character isn't a dash: hide lines that don't match - ## this $search_term - filter="${filter:-}${filter:+ | }grep -i $(shellquote "$search_term")" - else - ## First character is a dash: hide lines that match this - ## $search_term - # - ## Remove the first character (-) before adding to our filter command - filter="${filter:-}${filter:+ | }grep -v -i $(shellquote "${search_term:1}")" - fi - done - - [ -n "$post_filter" ] && { - filter="${filter:-}${filter:+ | }${post_filter:-}" - } - - printf %s "$filter" -} - -_list() { - local FILE="$1" - ## If the file starts with a "/" use absolute path. Otherwise, - ## try to find it in either $TODO_DIR or using a relative path - if [ "${1:0:1}" == / ]; then - ## Absolute path - src="$FILE" - elif [ -f "$TODO_DIR/$FILE" ]; then - ## Path relative to todo.sh directory - src="$TODO_DIR/$FILE" - elif [ -f "$FILE" ]; then - ## Path relative to current working directory - src="$FILE" - elif [ -f "$TODO_DIR/${FILE}.txt" ]; then - ## Path relative to todo.sh directory, missing file extension - src="$TODO_DIR/${FILE}.txt" - else - die "TODO: File $FILE does not exist." - fi - - ## Get our search arguments, if any - shift ## was file name, new $1 is first search term - - _format "$src" '' "$@" - - if [ $TODOTXT_VERBOSE -gt 0 ]; then - echo "--" - echo "$(getPrefix "$src"): ${NUMTASKS:-0} of ${TOTALTASKS:-0} tasks shown" - fi -} -getPadding() -{ - ## We need one level of padding for each power of 10 $LINES uses. - LINES=$(sed -n '$ =' "${1:-$TODO_FILE}") - printf %s ${#LINES} -} -_format() -{ - # Parameters: $1: todo input file; when empty formats stdin - # $2: ITEM# number width; if empty auto-detects from $1 / $TODO_FILE. - # Precondition: None - # Postcondition: $NUMTASKS and $TOTALTASKS contain statistics (unless $TODOTXT_VERBOSE=0). - - FILE=$1 - shift - - ## Figure out how much padding we need to use, unless this was passed to us. - PADDING=${1:-$(getPadding "$FILE")} - shift - - ## Number the file, then run the filter command, - ## then sort and mangle output some more - if [[ $TODOTXT_DISABLE_FILTER = 1 ]]; then - TODOTXT_FINAL_FILTER="cat" - fi - items=$( - if [ "$FILE" ]; then - sed = "$FILE" - else - sed = - fi \ - | sed -e ''' - N - s/^/ / - s/ *\([ 0-9]\{'"$PADDING"',\}\)\n/\1 / - /^[ 0-9]\{1,\} *$/d - ''' - ) - - ## Build and apply the filter. - filter_command=$(filtercommand "${pre_filter_command:-}" "${post_filter_command:-}" "$@") - if [ "${filter_command}" ]; then - filtered_items=$(echo -n "$items" | eval "${filter_command}") - else - filtered_items=$items - fi - filtered_items=$( - echo -n "$filtered_items" \ - | sed ''' - s/^ /00000/; - s/^ /0000/; - s/^ /000/; - s/^ /00/; - s/^ /0/; - ''' \ - | eval ${TODOTXT_SORT_COMMAND} \ - | awk ''' - function highlight(colorVar, color) { - color = ENVIRON[colorVar] - gsub(/\\+033/, "\033", color) - return color - } - { - if (match($0, /^[0-9]+ x /)) { - print highlight("COLOR_DONE") $0 highlight("DEFAULT") - } else if (match($0, /^[0-9]+ \([A-Z]\) /)) { - clr = highlight("PRI_" substr($0, RSTART + RLENGTH - 3, 1)) - print \ - (clr ? clr : highlight("PRI_X")) \ - (ENVIRON["HIDE_PRIORITY_SUBSTITUTION"] == "" ? $0 : substr($0, 1, RLENGTH - 4) substr($0, RSTART + RLENGTH)) \ - highlight("DEFAULT") - } else { print } - } - ''' \ - | sed ''' - s/'"${HIDE_PROJECTS_SUBSTITUTION:-^}"'//g - s/'"${HIDE_CONTEXTS_SUBSTITUTION:-^}"'//g - s/'"${HIDE_CUSTOM_SUBSTITUTION:-^}"'//g - ''' \ - | eval ${TODOTXT_FINAL_FILTER} \ - ) - [ "$filtered_items" ] && echo "$filtered_items" - - if [ $TODOTXT_VERBOSE -gt 0 ]; then - NUMTASKS=$( echo -n "$filtered_items" | sed -n '$ =' ) - TOTALTASKS=$( echo -n "$items" | sed -n '$ =' ) - fi - if [ $TODOTXT_VERBOSE -gt 1 ]; then - echo "TODO DEBUG: Filter Command was: ${filter_command:-cat}" - fi -} - -export -f cleaninput getPrefix getTodo getNewtodo shellquote filtercommand _list getPadding _format die - -# == HANDLE ACTION == -action=$( printf "%s\n" "$ACTION" | tr 'A-Z' 'a-z' ) - -## If the first argument is "command", run the rest of the arguments -## using todo.sh builtins. -## Else, run a actions script with the name of the command if it exists -## or fallback to using a builtin -if [ "$action" == command ] -then - ## Get rid of "command" from arguments list - shift - ## Reset action to new first argument - action=$( printf "%s\n" "$1" | tr 'A-Z' 'a-z' ) -elif [ -d "$TODO_ACTIONS_DIR" -a -x "$TODO_ACTIONS_DIR/$action" ] -then - "$TODO_ACTIONS_DIR/$action" "$@" - exit $? -fi - -## Only run if $action isn't found in .todo.actions.d -case $action in -"add" | "a") - if [[ -z "$2" && $TODOTXT_FORCE = 0 ]]; then - echo -n "Add: " - read input - else - [ -z "$2" ] && die "usage: $TODO_SH add \"TODO ITEM\"" - shift - input=$* - fi - _addto "$TODO_FILE" "$input" - ;; - -"addm") - if [[ -z "$2" && $TODOTXT_FORCE = 0 ]]; then - echo -n "Add: " - read input - else - [ -z "$2" ] && die "usage: $TODO_SH addm \"TODO ITEM\"" - shift - input=$* - fi - - # Set Internal Field Seperator as newline so we can - # loop across multiple lines - SAVEIFS=$IFS - IFS=$'\n' - - # Treat each line seperately - for line in $input ; do - _addto "$TODO_FILE" "$line" - done - IFS=$SAVEIFS - ;; - -"addto" ) - [ -z "$2" ] && die "usage: $TODO_SH addto DEST \"TODO ITEM\"" - dest="$TODO_DIR/$2" - [ -z "$3" ] && die "usage: $TODO_SH addto DEST \"TODO ITEM\"" - shift - shift - input=$* - - if [ -f "$dest" ]; then - _addto "$dest" "$input" - else - die "TODO: Destination file $dest does not exist." - fi - ;; - -"append" | "app" ) - errmsg="usage: $TODO_SH append ITEM# \"TEXT TO APPEND\"" - shift; item=$1; shift - getTodo "$item" - - if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then - echo -n "Append: " - read input - else - input=$* - fi - case "$input" in - [$SENTENCE_DELIMITERS]*) appendspace=;; - *) appendspace=" ";; - esac - cleaninput "for sed" - - if sed -i.bak $item" s|^.*|&${appendspace}${input}|" "$TODO_FILE"; then - if [ $TODOTXT_VERBOSE -gt 0 ]; then - getNewtodo "$item" - echo "$item $newtodo" - fi - else - die "TODO: Error appending task $item." - fi - ;; - -"archive" ) - # defragment blank lines - sed -i.bak -e '/./!d' "$TODO_FILE" - [ $TODOTXT_VERBOSE -gt 0 ] && grep "^x " "$TODO_FILE" - grep "^x " "$TODO_FILE" >> "$DONE_FILE" - sed -i.bak '/^x /d' "$TODO_FILE" - if [ $TODOTXT_VERBOSE -gt 0 ]; then - echo "TODO: $TODO_FILE archived." - fi - ;; - -"del" | "rm" ) - # replace deleted line with a blank line when TODOTXT_PRESERVE_LINE_NUMBERS is 1 - errmsg="usage: $TODO_SH del ITEM# [TERM]" - item=$2 - getTodo "$item" - - if [ -z "$3" ]; then - if [ $TODOTXT_FORCE = 0 ]; then - echo "Delete '$todo'? (y/n)" - read ANSWER - else - ANSWER="y" - fi - if [ "$ANSWER" = "y" ]; then - if [ $TODOTXT_PRESERVE_LINE_NUMBERS = 0 ]; then - # delete line (changes line numbers) - sed -i.bak -e $item"s/^.*//" -e '/./!d' "$TODO_FILE" - else - # leave blank line behind (preserves line numbers) - sed -i.bak -e $item"s/^.*//" "$TODO_FILE" - fi - if [ $TODOTXT_VERBOSE -gt 0 ]; then - echo "$item $todo" - echo "TODO: $item deleted." - fi - else - echo "TODO: No tasks were deleted." - fi - else - sed -i.bak \ - -e $item"s/^\((.) \)\{0,1\} *$3 */\1/g" \ - -e $item"s/ *$3 *\$//g" \ - -e $item"s/ *$3 */ /g" \ - -e $item"s/ *$3 */ /g" \ - -e $item"s/$3//g" \ - "$TODO_FILE" - getNewtodo "$item" - if [ "$todo" = "$newtodo" ]; then - [ $TODOTXT_VERBOSE -gt 0 ] && echo "$item $todo" - die "TODO: '$3' not found; no removal done." - fi - if [ $TODOTXT_VERBOSE -gt 0 ]; then - echo "$item $todo" - echo "TODO: Removed '$3' from task." - echo "$item $newtodo" - fi - fi - ;; - -"depri" | "dp" ) - errmsg="usage: $TODO_SH depri ITEM#[, ITEM#, ITEM#, ...]" - shift; - [ $# -eq 0 ] && die "$errmsg" - - # Split multiple depri's, if comma separated change to whitespace separated - # Loop the 'depri' function for each item - for item in ${*//,/ }; do - getTodo "$item" - - if [[ "$todo" = \(?\)\ * ]]; then - sed -i.bak -e $item"s/^(.) //" "$TODO_FILE" - if [ $TODOTXT_VERBOSE -gt 0 ]; then - getNewtodo "$item" - echo "$item $newtodo" - echo "TODO: $item deprioritized." - fi - else - echo "TODO: $item is not prioritized." - fi - done - ;; - -"do" ) - errmsg="usage: $TODO_SH do ITEM#[, ITEM#, ITEM#, ...]" - # shift so we get arguments to the do request - shift; - [ "$#" -eq 0 ] && die "$errmsg" - - # Split multiple do's, if comma separated change to whitespace separated - # Loop the 'do' function for each item - for item in ${*//,/ }; do - getTodo "$item" - - # Check if this item has already been done - if [ "${todo:0:2}" != "x " ]; then - now=$(date '+%Y-%m-%d') - # remove priority once item is done - sed -i.bak $item"s/^(.) //" "$TODO_FILE" - sed -i.bak $item"s|^|x $now |" "$TODO_FILE" - if [ $TODOTXT_VERBOSE -gt 0 ]; then - getNewtodo "$item" - echo "$item $newtodo" - echo "TODO: $item marked as done." - fi - else - echo "TODO: $item is already marked done." - fi - done - - if [ $TODOTXT_AUTO_ARCHIVE = 1 ]; then - # Recursively invoke the script to allow overriding of the archive - # action. - "$TODO_FULL_SH" archive - fi - ;; - -"help" ) - if [ -t 1 ] ; then # STDOUT is a TTY - if which "${PAGER:-less}" >/dev/null 2>&1; then - # we have a working PAGER (or less as a default) - help | "${PAGER:-less}" && exit 0 - fi - fi - help # just in case something failed above, we go ahead and just spew to STDOUT - ;; - -"shorthelp" ) - if [ -t 1 ] ; then # STDOUT is a TTY - if which "${PAGER:-less}" >/dev/null 2>&1; then - # we have a working PAGER (or less as a default) - shorthelp | "${PAGER:-less}" && exit 0 - fi - fi - shorthelp # just in case something failed above, we go ahead and just spew to STDOUT - ;; - -"list" | "ls" ) - shift ## Was ls; new $1 is first search term - _list "$TODO_FILE" "$@" - ;; - -"listall" | "lsa" ) - shift ## Was lsa; new $1 is first search term - - TOTAL=$( sed -n '$ =' "$TODO_FILE" ) - PADDING=${#TOTAL} - - post_filter_command="awk -v TOTAL=$TOTAL -v PADDING=$PADDING '{ \$1 = sprintf(\"%\" PADDING \"d\", (\$1 > TOTAL ? 0 : \$1)); print }' " - cat "$TODO_FILE" "$DONE_FILE" | TODOTXT_VERBOSE=0 _format '' "$PADDING" "$@" - - if [ $TODOTXT_VERBOSE -gt 0 ]; then - TDONE=$( sed -n '$ =' "$DONE_FILE" ) - TASKNUM=$(TODOTXT_PLAIN=1 TODOTXT_VERBOSE=0 _format "$TODO_FILE" 1 "$@" | sed -n '$ =') - DONENUM=$(TODOTXT_PLAIN=1 TODOTXT_VERBOSE=0 _format "$DONE_FILE" 1 "$@" | sed -n '$ =') - echo "--" - echo "$(getPrefix "$TODO_FILE"): ${TASKNUM:-0} of ${TOTAL:-0} tasks shown" - echo "$(getPrefix "$DONE_FILE"): ${DONENUM:-0} of ${TDONE:-0} tasks shown" - echo "total $((TASKNUM + DONENUM)) of $((TOTAL + TDONE)) tasks shown" - fi - ;; - -"listfile" | "lf" ) - shift ## Was listfile, next $1 is file name - if [ $# -eq 0 ]; then - [ $TODOTXT_VERBOSE -gt 0 ] && echo "Files in the todo.txt directory:" - cd "$TODO_DIR" && ls -1 *.txt - else - FILE="$1" - shift ## Was filename; next $1 is first search term - - _list "$FILE" "$@" - fi - ;; - -"listcon" | "lsc" ) - FILE=$TODO_FILE - [ "$TODOTXT_SOURCEVAR" ] && eval "FILE=$TODOTXT_SOURCEVAR" - grep -ho '[^ ]*@[^ ]\+' "${FILE[@]}" | grep '^@' | sort -u - ;; - -"listproj" | "lsprj" ) - FILE=$TODO_FILE - [ "$TODOTXT_SOURCEVAR" ] && eval "FILE=$TODOTXT_SOURCEVAR" - shift - eval "$(filtercommand 'cat "${FILE[@]}"' '' "$@")" | grep -o '[^ ]*+[^ ]\+' | grep '^+' | sort -u - ;; - -"listpri" | "lsp" ) - shift ## was "listpri", new $1 is priority to list or first TERM - - pri=$(printf "%s\n" "$1" | tr 'a-z' 'A-Z' | grep -e '^[A-Z]$' -e '^[A-Z]-[A-Z]$') && shift || pri="A-Z" - post_filter_command="grep '^ *[0-9]\+ ([${pri}]) '" - _list "$TODO_FILE" "$@" - ;; - -"move" | "mv" ) - # replace moved line with a blank line when TODOTXT_PRESERVE_LINE_NUMBERS is 1 - errmsg="usage: $TODO_SH mv ITEM# DEST [SRC]" - item=$2 - dest="$TODO_DIR/$3" - src="$TODO_DIR/$4" - - [ -z "$4" ] && src="$TODO_FILE" - [ -z "$dest" ] && die "$errmsg" - - [ -f "$src" ] || die "TODO: Source file $src does not exist." - [ -f "$dest" ] || die "TODO: Destination file $dest does not exist." - - getTodo "$item" "$src" - [ -z "$todo" ] && die "$item: No such item in $src." - if [ $TODOTXT_FORCE = 0 ]; then - echo "Move '$todo' from $src to $dest? (y/n)" - read ANSWER - else - ANSWER="y" - fi - if [ "$ANSWER" = "y" ]; then - if [ $TODOTXT_PRESERVE_LINE_NUMBERS = 0 ]; then - # delete line (changes line numbers) - sed -i.bak -e $item"s/^.*//" -e '/./!d' "$src" - else - # leave blank line behind (preserves line numbers) - sed -i.bak -e $item"s/^.*//" "$src" - fi - echo "$todo" >> "$dest" - - if [ $TODOTXT_VERBOSE -gt 0 ]; then - echo "$item $todo" - echo "TODO: $item moved from '$src' to '$dest'." - fi - else - echo "TODO: No tasks moved." - fi - ;; - -"prepend" | "prep" ) - errmsg="usage: $TODO_SH prepend ITEM# \"TEXT TO PREPEND\"" - replaceOrPrepend 'prepend' "$@" - ;; - -"pri" | "p" ) - item=$2 - newpri=$( printf "%s\n" "$3" | tr 'a-z' 'A-Z' ) - - errmsg="usage: $TODO_SH pri ITEM# PRIORITY -note: PRIORITY must be anywhere from A to Z." - - [ "$#" -ne 3 ] && die "$errmsg" - [[ "$newpri" = @([A-Z]) ]] || die "$errmsg" - getTodo "$item" - - oldpri= - if [[ "$todo" = \(?\)\ * ]]; then - oldpri=${todo:1:1} - fi - - if [ "$oldpri" != "$newpri" ]; then - sed -i.bak -e $item"s/^(.) //" -e $item"s/^/($newpri) /" "$TODO_FILE" - fi - if [ $TODOTXT_VERBOSE -gt 0 ]; then - getNewtodo "$item" - echo "$item $newtodo" - if [ "$oldpri" != "$newpri" ]; then - if [ "$oldpri" ]; then - echo "TODO: $item re-prioritized from ($oldpri) to ($newpri)." - else - echo "TODO: $item prioritized ($newpri)." - fi - fi - fi - if [ "$oldpri" = "$newpri" ]; then - echo "TODO: $item already prioritized ($newpri)." - fi - ;; - -"replace" ) - errmsg="usage: $TODO_SH replace ITEM# \"UPDATED ITEM\"" - replaceOrPrepend 'replace' "$@" - ;; - -"report" ) - # archive first - # Recursively invoke the script to allow overriding of the archive - # action. - "$TODO_FULL_SH" archive - - TOTAL=$( sed -n '$ =' "$TODO_FILE" ) - TDONE=$( sed -n '$ =' "$DONE_FILE" ) - NEWDATA="${TOTAL:-0} ${TDONE:-0}" - LASTREPORT=$(sed -ne '$p' "$REPORT_FILE") - LASTDATA=${LASTREPORT#* } # Strip timestamp. - if [ "$LASTDATA" = "$NEWDATA" ]; then - echo "$LASTREPORT" - [ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: Report file is up-to-date." - else - NEWREPORT="$(date +%Y-%m-%dT%T) ${NEWDATA}" - echo "${NEWREPORT}" >> "$REPORT_FILE" - echo "${NEWREPORT}" - [ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: Report file updated." - fi - ;; - -"deduplicate" ) - if [ $TODOTXT_PRESERVE_LINE_NUMBERS = 0 ]; then - deduplicateSedCommand='d' - else - deduplicateSedCommand='s/^.*//; p' - fi - - # To determine the difference when deduplicated lines are preserved, only - # non-empty lines must be counted. - originalTaskNum=$( sed -e '/./!d' "$TODO_FILE" | sed -n '$ =' ) - - # Look for duplicate lines and discard the second occurrence. - # We start with an empty hold space on the first line. For each line: - # G - appends newline + hold space to the pattern space - # s/\n/&&/; - double up the first new line so we catch adjacent dups - # /^\([^\n]*\n\).*\n\1/b dedup - # If the first line of the hold space shows up again later as an - # entire line, it's a duplicate. Jump to the "dedup" label, where - # either of the following is executed, depending on whether empty - # lines should be preserved: - # d - Delete the current pattern space, quit this line and - # move on to the next, or: - # s/^.*//; p - Clear the task text, print this line and move on to - # the next. - # s/\n//; - else (no duplicate), drop the doubled newline - # h; - replace the hold space with the expanded pattern space - # P; - print up to the first newline (that is, the input line) - # b - end processing of the current line - sed -i.bak -n \ - -e 'G; s/\n/&&/; /^\([^\n]*\n\).*\n\1/b dedup' \ - -e 's/\n//; h; P; b' \ - -e ':dedup' \ - -e "$deduplicateSedCommand" \ - "$TODO_FILE" - - newTaskNum=$( sed -e '/./!d' "$TODO_FILE" | sed -n '$ =' ) - deduplicateNum=$(( originalTaskNum - newTaskNum )) - if [ $deduplicateNum -eq 0 ]; then - echo "TODO: No duplicate tasks found" - else - echo "TODO: $deduplicateNum duplicate task(s) removed" - fi - ;; - -"listaddons" ) - if [ -d "$TODO_ACTIONS_DIR" ]; then - cd "$TODO_ACTIONS_DIR" || exit $? - for action in * - do - if [ -f "$action" -a -x "$action" ]; then - echo "$action" - fi - done - fi - ;; - -* ) - usage;; -esac diff --git a/plugins/available/todo/todo_completion b/plugins/available/todo/todo_completion deleted file mode 100644 index 3f9d308a..00000000 --- a/plugins/available/todo/todo_completion +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/bash source-this-script -[ "$BASH_VERSION" ] || return - -_todo() -{ - local cur prev opts - COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - prev="${COMP_WORDS[COMP_CWORD-1]}" - - local -r OPTS="-@ -@@ -+ -++ -d -f -h -p -P -PP -a -n -t -v -vv -V -x" - local -r COMMANDS="\ - add a addto addm append app archive command del \ - rm depri dp do help list ls listaddons listall lsa listcon \ - lsc listfile lf listpri lsp listproj lsprj move \ - mv prepend prep pri p replace report shorthelp" - - local _todo_sh=${_todo_sh:-todo.sh} - local completions - if [ $COMP_CWORD -eq 1 ]; then - completions="$COMMANDS $(eval TODOTXT_VERBOSE=0 $_todo_sh command listaddons) $OPTS" - elif [[ $COMP_CWORD -gt 2 && ( \ - "${COMP_WORDS[COMP_CWORD-2]}" =~ ^(move|mv)$ || \ - "${COMP_WORDS[COMP_CWORD-3]}" =~ ^(move|mv)$ ) ]]; then - # "move ITEM# DEST [SRC]" has file arguments on positions 2 and 3. - completions=$(eval TODOTXT_VERBOSE=0 $_todo_sh command listfile) - else - case "$prev" in - command) - completions=$COMMANDS;; - addto|listfile|lf) - completions=$(eval TODOTXT_VERBOSE=0 $_todo_sh command listfile);; - -*) completions="$COMMANDS $(eval TODOTXT_VERBOSE=0 $_todo_sh command listaddons) $OPTS";; - *) case "$cur" in - +*) completions=$(eval TODOTXT_VERBOSE=0 $_todo_sh command listproj) - COMPREPLY=( $( compgen -W "$completions" -- $cur )) - [ ${#COMPREPLY[@]} -gt 0 ] && return 0 - # Fall back to projects extracted from done tasks. - completions=$(eval 'TODOTXT_VERBOSE=0 TODOTXT_SOURCEVAR=\$DONE_FILE' $_todo_sh command listproj) - ;; - @*) completions=$(eval TODOTXT_VERBOSE=0 $_todo_sh command listcon) - COMPREPLY=( $( compgen -W "$completions" -- $cur )) - [ ${#COMPREPLY[@]} -gt 0 ] && return 0 - # Fall back to contexts extracted from done tasks. - completions=$(eval 'TODOTXT_VERBOSE=0 TODOTXT_SOURCEVAR=\$DONE_FILE' $_todo_sh command listcon) - ;; - *) if [[ "$cur" =~ ^[0-9]+$ ]]; then - # Remove the (padded) task number; we prepend the - # user-provided $cur instead. - # Remove the timestamp prepended by the -t option, - # and the done date (for done tasks); there's no - # todo.txt option for that yet. - # But keep priority and "x"; they're short and may - # provide useful context. - # Remove any trailing whitespace; the Bash - # completion inserts a trailing space itself. - # Finally, limit the output to a single line just as - # a safety check of the ls action output. - local todo=$( \ - eval TODOTXT_VERBOSE=0 $_todo_sh '-@ -+ -p -x command ls "^ *${cur} "' | \ - sed -e 's/^ *[0-9]\{1,\} //' -e 's/\((.) \)[0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} /\1/' \ - -e 's/\([xX] \)\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} \)\{1,2\}/\1/' \ - -e 's/[[:space:]]*$//' \ - -e '1q' \ - ) - # Append task text as a shell comment. This - # completion can be a safety check before a - # destructive todo.txt operation. - [ "$todo" ] && COMPREPLY[0]="$cur # $todo" - return 0 - else - return 0 - fi - ;; - esac - ;; - esac - fi - - COMPREPLY=( $( compgen -W "$completions" -- $cur )) - return 0 -} -complete -F _todo todo.sh - -# If you define an alias (e.g. "t") to todo.sh, you need to explicitly enable -# completion for it, too: -#complete -F _todo t - -# If you have renamed the todo.sh executable, or if it is not accessible through -# PATH, you need to add and use a wrapper completion function, like this: -#_todoElsewhere() -#{ -# local _todo_sh='/path/to/todo2.sh' -# _todo "$@" -#} -#complete -F _todoElsewhere /path/to/todo2.sh - -# If you use aliases to use different configuration(s), you need to add and use -# a wrapper completion function for each configuration if you want to complete -# fron the actual configured task locations: -#alias todo2='todo.sh -d "$HOME/todo2.cfg"' -#_todo2() -#{ -# local _todo_sh='todo.sh -d "$HOME/todo2.cfg"' -# _todo "$@" -#} -#complete -F _todo2 todo2 From ffbeeacc54ae4b8dbaebd213caedf6d8ffd43add Mon Sep 17 00:00:00 2001 From: Konstantin Gredeskoul Date: Sat, 7 May 2016 04:19:03 -0700 Subject: [PATCH 185/216] Moving search into its own module before more work --- lib/helpers.bash | 54 -------------------------- lib/search.bash | 54 ++++++++++++++++++++++++++ test/lib/{helpers.bats => search.bats} | 1 + 3 files changed, 55 insertions(+), 54 deletions(-) create mode 100644 lib/search.bash rename test/lib/{helpers.bats => search.bats} (96%) diff --git a/lib/helpers.bash b/lib/helpers.bash index 775eb43f..6d7104dd 100755 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -146,60 +146,6 @@ _bash-it_update() { cd - &> /dev/null } -# This function returns list of aliases, plugins and completions in bash-it, -# whose name or description matches one of the search terms provided as arguments. -# -# Usage: -# ❯ bash-it search term1 [term2]... -# Example: -# ❯ bash-it search ruby rbenv rvm gem rake -# aliases: bundler -# plugins: chruby chruby-auto rbenv ruby rvm -# completions: gem rake -# - -_bash-it-search() { - _about 'searches for given terms amongst bash-it plugins, aliases and completions' - _param '1: term1' - _param '2: [ term2 ]...' - _example '$ _bash-it-search ruby rvm rake bundler' - - declare -a _components=(aliases plugins completions) - for _component in "${_components[@]}" ; do - _bash-it-search-component "${_component}" "$*" - done -} - -_bash-it-search-component() { - _about 'searches for given terms amongst a given component' - _param '1: component type, one of: [ aliases | plugins | completions ]' - _param '2: term1' - _param '3: [ term2 ]...' - _example '$ _bash-it-search-component aliases rake bundler' - - _component=$1 - local func=_bash-it-${_component} - local help=$($func) - - shift - declare -a terms=($@) - declare -a matches=() - local _grep=$(which egrep || which grep) - for term in "${terms[@]}"; do - local term_match=($(echo "${help}"| ${_grep} -i -- ${term} | cut -d ' ' -f 1 | tr '\n' ' ')) - [[ "${#term_match[@]}" -gt 0 ]] && { - matches=(${matches[@]} ${term_match[@]}) - } - done - [[ -n "$NO_COLOR" && color_on="" ]] || color_on="\e[1;32m" - [[ -n "$NO_COLOR" && color_off="" ]] || color_off="\e[0;0m" - - if [[ "${#matches[*]}" -gt 0 ]] ; then - printf "%-12s: ${color_on}%s${color_off}\n" "${_component}" "$(echo -n ${matches[*]} | tr ' ' '\n' | sort | uniq | tr '\n' ' ' | sed 's/ $//g')" - fi - unset matches -} - _bash-it-describe () { _about 'summarizes available bash_it components' diff --git a/lib/search.bash b/lib/search.bash new file mode 100644 index 00000000..5d7d9bb0 --- /dev/null +++ b/lib/search.bash @@ -0,0 +1,54 @@ + +# This function returns list of aliases, plugins and completions in bash-it, +# whose name or description matches one of the search terms provided as arguments. +# +# Usage: +# ❯ bash-it search term1 [term2]... +# Example: +# ❯ bash-it search ruby rbenv rvm gem rake +# aliases: bundler +# plugins: chruby chruby-auto rbenv ruby rvm +# completions: gem rake +# + +_bash-it-search() { + _about 'searches for given terms amongst bash-it plugins, aliases and completions' + _param '1: term1' + _param '2: [ term2 ]...' + _example '$ _bash-it-search ruby rvm rake bundler' + + declare -a _components=(aliases plugins completions) + for _component in "${_components[@]}" ; do + _bash-it-search-component "${_component}" "$*" + done +} + +_bash-it-search-component() { + _about 'searches for given terms amongst a given component' + _param '1: component type, one of: [ aliases | plugins | completions ]' + _param '2: term1' + _param '3: [ term2 ]...' + _example '$ _bash-it-search-component aliases rake bundler' + + _component=$1 + local func=_bash-it-${_component} + local help=$($func) + + shift + declare -a terms=($@) + declare -a matches=() + local _grep=$(which egrep || which grep) + for term in "${terms[@]}"; do + local term_match=($(echo "${help}"| ${_grep} -i -- ${term} | cut -d ' ' -f 1 | tr '\n' ' ')) + [[ "${#term_match[@]}" -gt 0 ]] && { + matches=(${matches[@]} ${term_match[@]}) + } + done + [[ -n "$NO_COLOR" && color_on="" ]] || color_on="\e[1;32m" + [[ -n "$NO_COLOR" && color_off="" ]] || color_off="\e[0;0m" + + if [[ "${#matches[*]}" -gt 0 ]] ; then + printf "%-12s: ${color_on}%s${color_off}\n" "${_component}" "$(echo -n ${matches[*]} | tr ' ' '\n' | sort | uniq | tr '\n' ' ' | sed 's/ $//g')" + fi + unset matches +} diff --git a/test/lib/helpers.bats b/test/lib/search.bats similarity index 96% rename from test/lib/helpers.bats rename to test/lib/search.bats index af9ae6b6..7a3efc84 100644 --- a/test/lib/helpers.bats +++ b/test/lib/search.bats @@ -6,6 +6,7 @@ load ../../plugins/available/base.plugin cite _about _param _example _group _author _version load ../../lib/helpers +load ../../lib/search NO_COLOR=true From fb6a6c80c00dd4a20889cbeedcb04ecfd33a45f8 Mon Sep 17 00:00:00 2001 From: Konstantin Gredeskoul Date: Sat, 7 May 2016 04:23:03 -0700 Subject: [PATCH 186/216] Highlighting color of enabled components --- lib/helpers.bash | 0 lib/history.bash | 0 lib/search.bash | 79 ++++++++++++++++++++++++++++++++++++++------ test/lib/search.bats | 6 ++-- 4 files changed, 72 insertions(+), 13 deletions(-) mode change 100755 => 100644 lib/helpers.bash mode change 100755 => 100644 lib/history.bash diff --git a/lib/helpers.bash b/lib/helpers.bash old mode 100755 new mode 100644 diff --git a/lib/history.bash b/lib/history.bash old mode 100755 new mode 100644 diff --git a/lib/search.bash b/lib/search.bash index 5d7d9bb0..1d7b302f 100644 --- a/lib/search.bash +++ b/lib/search.bash @@ -1,4 +1,3 @@ - # This function returns list of aliases, plugins and completions in bash-it, # whose name or description matches one of the search terms provided as arguments. # @@ -18,11 +17,23 @@ _bash-it-search() { _example '$ _bash-it-search ruby rvm rake bundler' declare -a _components=(aliases plugins completions) + for _component in "${_components[@]}" ; do - _bash-it-search-component "${_component}" "$*" + _bash-it-search-component "${_component}" "$@" done } +# +# array=("something to search for" "a string" "test2000") +# _bash-it-array-contains-element "a string" "${array[@]}" +# ( prints "true" or "false" ) +_bash-it-array-contains-element () { + local e + local r=false + for e in "${@:2}"; do [[ "$e" == "$1" ]] && r=true; done + echo -n $r +} + _bash-it-search-component() { _about 'searches for given terms amongst a given component' _param '1: component type, one of: [ aliases | plugins | completions ]' @@ -31,24 +42,72 @@ _bash-it-search-component() { _example '$ _bash-it-search-component aliases rake bundler' _component=$1 + local func=_bash-it-${_component} local help=$($func) - shift + + # if one of the search terms is --enable or --disable, we will apply + # this action to the result set interactively. + local cmd action component_singular + declare -a _search_commands=(enable disable) + for _search_command in "${_search_commands[@]}"; do + if [[ $(_bash-it-array-contains-element "--${_search_command}" "$@") == "true" ]]; then + cmd=$_search_command + component_singular=${_component} + component_singular=${component_singular/es/} # aliases -> alias + component_singular=${component_singular/ns/n} # plugins -> plugin + action="_${cmd}-${component_singular}" + break + fi + done + declare -a terms=($@) declare -a matches=() local _grep=$(which egrep || which grep) for term in "${terms[@]}"; do - local term_match=($(echo "${help}"| ${_grep} -i -- ${term} | cut -d ' ' -f 1 | tr '\n' ' ')) + if [[ "${term}" =~ "--" ]]; then + continue + fi + # print asterisk next to each command that is already enabled + local term_match=($(echo "${help}"| ${_grep} -i -- ${term} | cut -b -30 | sed 's/ *\[ \]//g;s/ *\[x\]/*/g;' )) [[ "${#term_match[@]}" -gt 0 ]] && { matches=(${matches[@]} ${term_match[@]}) } done - [[ -n "$NO_COLOR" && color_on="" ]] || color_on="\e[1;32m" - [[ -n "$NO_COLOR" && color_off="" ]] || color_off="\e[0;0m" - - if [[ "${#matches[*]}" -gt 0 ]] ; then - printf "%-12s: ${color_on}%s${color_off}\n" "${_component}" "$(echo -n ${matches[*]} | tr ' ' '\n' | sort | uniq | tr '\n' ' ' | sed 's/ $//g')" - fi + _bash-it-search-result $action # "${matches[@]}" unset matches } + +_bash-it-search-result() { + local action=shift + local color_component color_enable color_disable color_off + + [[ -z "$NO_COLOR" ]] && { + color_component='\e[0;33m' + color_enable='\e[1;32m' + color_disable='\e[0;0m' + color_off='\e[0;0m' + } + + [[ -n "$NO_COLOR" ]] && { + color_enable='*' + } + + if [[ "${#matches[*]}" -gt 0 ]] ; then + printf "${color_component}%-12s:${color_off} " "${_component}" + sorted_matches=($(echo "${matches[*]}" | tr ' ' '\n' | sort | uniq)) + for match in "${sorted_matches[@]}"; do + local match_color + if [[ $match =~ "*" ]]; then + match_color=$color_enable + else + match_color=$color_disable + fi + printf " ${match_color}${match/\*/}${color_off}" + done + + printf "\n" + fi + +} diff --git a/test/lib/search.bats b/test/lib/search.bats index 7a3efc84..9baede99 100644 --- a/test/lib/search.bats +++ b/test/lib/search.bats @@ -17,7 +17,7 @@ NO_COLOR=true @test "helpers search all ruby et al" { run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' 'rails' - [[ "${lines[0]}" == 'aliases : bundler rails' ]] - [[ "${lines[1]}" == 'plugins : chruby chruby-auto ruby' ]] - [[ "${lines[2]}" == 'completions : bundler gem rake' ]] + [[ "${lines[0]/\*/}" == 'aliases : bundler rails' ]] + [[ "${lines[1]/\*/}" == 'plugins : chruby chruby-auto ruby' ]] + [[ "${lines[2]/\*/}" == 'completions : bundler gem rake' ]] } From 9bb2d377a86fe1a1525b4748c6b7f03eb9190445 Mon Sep 17 00:00:00 2001 From: Konstantin Gredeskoul Date: Sat, 7 May 2016 06:26:30 -0700 Subject: [PATCH 187/216] Enable/Disable with negated search feature --- lib/helpers.bash | 2 +- lib/search.bash | 127 +++++++++++++++++++++++++++++++++---------- test/lib/search.bats | 15 ++++- 3 files changed, 112 insertions(+), 32 deletions(-) diff --git a/lib/helpers.bash b/lib/helpers.bash index 6d7104dd..c95f8d96 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -40,7 +40,7 @@ bash-it () example '$ bash-it enable plugin git [tmux]...' example '$ bash-it disable alias hg [tmux]...' example '$ bash-it update' - example '$ bash-it search ruby [rake]...' + example '$ bash-it search ruby [[-]rake]... [--enable | --disable]' typeset verb=${1:-} shift typeset component=${1:-} diff --git a/lib/search.bash b/lib/search.bash index 1d7b302f..f5b66096 100644 --- a/lib/search.bash +++ b/lib/search.bash @@ -1,13 +1,27 @@ +# +# Search by Konstantin Gredeskoul «github.com/kigster» +#——————————————————————————————————————————————————————————————————————————————— # This function returns list of aliases, plugins and completions in bash-it, # whose name or description matches one of the search terms provided as arguments. # # Usage: -# ❯ bash-it search term1 [term2]... +# ❯ bash-it search term1 [[-]term2] ... [[-]termN] [ --enable | --disable ] +# +# Exmplanation: +# Single dash, as in "-chruby", indicates a negative search term. +# Double dash indicates a command that is to be applied to the search result. +# At the moment only --enable and --disable are supported. +# # Example: -# ❯ bash-it search ruby rbenv rvm gem rake -# aliases: bundler -# plugins: chruby chruby-auto rbenv ruby rvm -# completions: gem rake +# ❯ bash-it search ruby rbenv rvm gem rake +# aliases : bundler +# plugins : chruby chruby-auto rbenv ruby rvm +# completions : gem rake + +# ❯ bash-it search ruby rbenv rvm gem rake -chruby +# aliases : bundler +# plugins : rbenv ruby rvm +# completions : gem rake # _bash-it-search() { @@ -23,7 +37,7 @@ _bash-it-search() { done } -# +#——————————————————————————————————————————————————————————————————————————————— # array=("something to search for" "a string" "test2000") # _bash-it-array-contains-element "a string" "${array[@]}" # ( prints "true" or "false" ) @@ -37,9 +51,9 @@ _bash-it-array-contains-element () { _bash-it-search-component() { _about 'searches for given terms amongst a given component' _param '1: component type, one of: [ aliases | plugins | completions ]' - _param '2: term1' - _param '3: [ term2 ]...' - _example '$ _bash-it-search-component aliases rake bundler' + _param '2: term1 ' + _param '3: [-]term2 [-]term3 ...' + _example '$ _bash-it-search-component aliases rake bundler -chruby' _component=$1 @@ -48,63 +62,120 @@ _bash-it-search-component() { shift # if one of the search terms is --enable or --disable, we will apply - # this action to the result set interactively. - local cmd action component_singular + # this action to the matches further down. + local action action_func component_singular declare -a _search_commands=(enable disable) for _search_command in "${_search_commands[@]}"; do if [[ $(_bash-it-array-contains-element "--${_search_command}" "$@") == "true" ]]; then - cmd=$_search_command + action=$_search_command component_singular=${_component} component_singular=${component_singular/es/} # aliases -> alias component_singular=${component_singular/ns/n} # plugins -> plugin - action="_${cmd}-${component_singular}" + action_func="_${action}-${component_singular}" break fi done - declare -a terms=($@) - declare -a matches=() local _grep=$(which egrep || which grep) + + declare -a terms=($@) # passed on the command line + declare -a matches=() # results that we found + declare -a negative_terms=() # terms that began with a dash + for term in "${terms[@]}"; do - if [[ "${term}" =~ "--" ]]; then - continue - fi - # print asterisk next to each command that is already enabled + # -- can only be used for the actions: enable/disable + [[ "${term:0:2}" == "--" ]] && continue + [[ "${term:0:1}" == "-" ]] && negative_terms=(${negative_terms[@]} ${term:1}) && continue + + # print asterisk next to each result that is already enabled by the user local term_match=($(echo "${help}"| ${_grep} -i -- ${term} | cut -b -30 | sed 's/ *\[ \]//g;s/ *\[x\]/*/g;' )) [[ "${#term_match[@]}" -gt 0 ]] && { - matches=(${matches[@]} ${term_match[@]}) + matches=(${matches[@]} ${term_match[@]}) # append to the list of results } done - _bash-it-search-result $action # "${matches[@]}" - unset matches + + # now check if we found any negative terms, and subtract them + [[ ${#negative_terms} -gt 0 ]] && { + declare -a filtered_matches=() + for match in "${matches[@]}"; do + local negations=0 + for nt in "${negative_terms[@]}"; do + [[ "${match}" =~ "${nt}" ]] && negations=$(($negations+1)) + done + [[ $negations -eq 0 ]] && filtered_matches=(${filtered_matches[@]} ${match}) + done + matches=(${filtered_matches[@]}) + } + + _bash-it-search-result $action $action_func + + unset matches filtered_matches terms } _bash-it-search-result() { - local action=shift + local action=$1; shift + local action_func=$1; shift local color_component color_enable color_disable color_off [[ -z "$NO_COLOR" ]] && { - color_component='\e[0;33m' + color_component='\e[1;34m' color_enable='\e[1;32m' color_disable='\e[0;0m' color_off='\e[0;0m' + color_sep=':' } [[ -n "$NO_COLOR" ]] && { - color_enable='*' + color_component='' + color_sep=' => ' + color_enable='✓' + color_disable='' + color_off='' } if [[ "${#matches[*]}" -gt 0 ]] ; then - printf "${color_component}%-12s:${color_off} " "${_component}" + printf "${color_component}%13s${color_sep} ${color_off}" "${_component}" + sorted_matches=($(echo "${matches[*]}" | tr ' ' '\n' | sort | uniq)) + for match in "${sorted_matches[@]}"; do - local match_color + local match_color compatible_action if [[ $match =~ "*" ]]; then match_color=$color_enable + compatible_action="disable" else match_color=$color_disable + compatible_action="enable" fi - printf " ${match_color}${match/\*/}${color_off}" + + match_value=${match/\*/} # remove asterisk + len=${#match_value} + if [[ -n $NO_COLOR ]]; then + local m="${match_color}${match_value}" + len=${#m} + fi + + printf " ${match_color}${match_value}" # print current state + + if [[ "${action}" == "${compatible_action}" ]]; then + # oh, i see – we need to either disable enabled, or enable disabled + # component. Let's start with the most important part: redrawing + # the search result backwards. Because style. + + printf "\033[${len}D" + for a in {0..30}; do + [[ $a -gt $len ]] && break + printf "%.*s" $a " " + sleep 0.07 # who knew you could sleep for fraction of the cost :) + done + printf "\033[${len}D" + result=$(${action_func} ${match_value}) + local temp="color_${compatible_action}" + match_color=${!temp} + printf "${match_color}${match_value}" + fi + + printf "${color_off}" done printf "\n" diff --git a/test/lib/search.bats b/test/lib/search.bats index 9baede99..f991d2f5 100644 --- a/test/lib/search.bats +++ b/test/lib/search.bats @@ -17,7 +17,16 @@ NO_COLOR=true @test "helpers search all ruby et al" { run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' 'rails' - [[ "${lines[0]/\*/}" == 'aliases : bundler rails' ]] - [[ "${lines[1]/\*/}" == 'plugins : chruby chruby-auto ruby' ]] - [[ "${lines[2]/\*/}" == 'completions : bundler gem rake' ]] + [[ "${lines[0]/✓/}" == ' aliases => bundler rails' ]] + [[ "${lines[1]/✓/}" == ' plugins => chruby chruby-auto ruby' ]] + [[ "${lines[2]/✓/}" == ' completions => bundler gem rake' ]] +} + +@test "search enable and disable" { + run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' 'rails' '--disable' + run _enable-alias 'rails' + run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' 'rails' + [[ "${lines[0]}" == ' aliases => bundler ✓rails' ]] + [[ "${lines[1]}" == ' plugins => chruby chruby-auto ruby' ]] + [[ "${lines[2]}" == ' completions => bundler gem rake' ]] } From 1a02db13bc56e66279e936a7cca92a56cbb3dbdf Mon Sep 17 00:00:00 2001 From: Konstantin Gredeskoul Date: Sat, 7 May 2016 06:39:40 -0700 Subject: [PATCH 188/216] Adding documentation --- README.md | 60 +++++++++++++++++++++++++++++++++++++++---------- lib/search.bash | 30 ++++++++++++++++--------- 2 files changed, 68 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index bd92e849..36779e83 100644 --- a/README.md +++ b/README.md @@ -56,25 +56,61 @@ bash-it help plugins # shows help for installed plugins ## Search If you need to quickly find out which of the plugins, aliases or completions -are available for a specific task or an environment, you can search for -multiple terms related to the commands you use frequently. Search will -find and output modules with the name or description matching the terms +are available for a specific framework, programming language, or an environment, you can _search_ for +multiple terms related to the commands you use frequently. Search will +find and print out modules with the name or description matching the terms provided. -``` -bash-it search term1 [term2] [term3].... +#### Syntax + +```bash + bash-it search term1 [[-]term2] [[-]term3].... ``` -For example, if you are a ruby developer, you might want to enable everything -related to the commands such as `ruby`, `rake`, `gem`, `bundler` and `rails`. -Search command helps you find related modules, so that you can decide which +As an example, a ruby developer might want to enable everything +related to the commands such as `ruby`, `rake`, `gem`, `bundler` and `rails`. +Search command helps you find related modules, so that you can decide which of them you'd like to use: +```bash +❯ bash-it search ruby rake gem bundle irb rails + aliases: bundler rails + plugins: chruby chruby-auto ruby + completions: bundler gem rake ``` -> bash-it search ruby rake gem bundle irb rails -aliases : bundler rails -plugins : chruby chruby-auto ruby -completions : bundler gem rake + +Currently enabled modules will be shown in green. + +#### Search with Negations + +You can prefix a search term with a "-" to exclude it from the results. In the above +example, if we wanted to hide `chruby` and `chruby-auto`, we could change the command as +follows: + +```bash +❯ bash-it search ruby rake gem bundle irb rails -chruby + aliases: bundler rails + plugins: ruby + completions: bundler gem rake +``` + +#### Using Search to Enable or Disable Components + +By adding a `--enable` or `--disable` to the search command, you can automatically +enable all modules that come up as a result of a search query. This could be quite +handy if you like to enable a bunch of components related to the same topic. + +#### Disabling ASCII Color + +To remove non-printing non-ASCII characters responsible for the coloring of the +search output, you can set environment variable `NO_COLOR`. Enabled components will +then be shown with a checkmark: + +```bash +❯ NO_COLOR=1 bash-it search ruby rake gem bundle irb rails -chruby + aliases => ✓bundler ✓rails + plugins => ✓ruby + completions => bundler gem rake ``` ## Your Custom scripts, aliases, themes, and functions diff --git a/lib/search.bash b/lib/search.bash index f5b66096..9afe3a3c 100644 --- a/lib/search.bash +++ b/lib/search.bash @@ -12,18 +12,28 @@ # Double dash indicates a command that is to be applied to the search result. # At the moment only --enable and --disable are supported. # -# Example: -# ❯ bash-it search ruby rbenv rvm gem rake -# aliases : bundler -# plugins : chruby chruby-auto rbenv ruby rvm -# completions : gem rake +# Examples: +# ❯ bash-it search ruby rbenv rvm gem rake +# aliases : bundler +# plugins : chruby chruby-auto rbenv ruby rvm +# completions : gem rake -# ❯ bash-it search ruby rbenv rvm gem rake -chruby -# aliases : bundler -# plugins : rbenv ruby rvm -# completions : gem rake +# ❯ bash-it search ruby rbenv rvm gem rake -chruby +# aliases : bundler +# plugins : rbenv ruby rvm +# completions : gem rake +# +# Examples of enabling or disabling results of the search: +# +# ❯ bash-it search ruby +# aliases => bundler +# plugins => chruby chruby-auto ruby +# +# ❯ bash-it search ruby -chruby --enable +# aliases => ✓bundler +# plugins => ✓ruby +# # - _bash-it-search() { _about 'searches for given terms amongst bash-it plugins, aliases and completions' _param '1: term1' From 81e3f1121b1cf1152eb682ac05ea9e08b86fbc3a Mon Sep 17 00:00:00 2001 From: Konstantin Gredeskoul Date: Sat, 7 May 2016 06:42:48 -0700 Subject: [PATCH 189/216] Get the test in a known state --- test/lib/search.bats | 1 + 1 file changed, 1 insertion(+) diff --git a/test/lib/search.bats b/test/lib/search.bats index f991d2f5..35b68d86 100644 --- a/test/lib/search.bats +++ b/test/lib/search.bats @@ -16,6 +16,7 @@ NO_COLOR=true } @test "helpers search all ruby et al" { + run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' 'rails' '--disable' run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' 'rails' [[ "${lines[0]/✓/}" == ' aliases => bundler rails' ]] [[ "${lines[1]/✓/}" == ' plugins => chruby chruby-auto ruby' ]] From e689e1fdb9180b5ee3930d47242a0c9992317972 Mon Sep 17 00:00:00 2001 From: ravenhall Date: Mon, 9 May 2016 18:27:57 -0500 Subject: [PATCH 190/216] Initial plenv plugin created. Fails silently when plenv not found, only munges path if plenv path exists --- plugins/available/plenv.plugin.bash | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 plugins/available/plenv.plugin.bash diff --git a/plugins/available/plenv.plugin.bash b/plugins/available/plenv.plugin.bash new file mode 100644 index 00000000..1e527b72 --- /dev/null +++ b/plugins/available/plenv.plugin.bash @@ -0,0 +1,21 @@ +# plugin for plenv + +cite about-plugin +about-plugin 'plenv plugin for Perl' + +if [[ -e "${HOME}/.plenv/bin" ]] ; then + + # load plenv bin dir into path if it exists + pathmunge "${HOME}/.plenv/bin" + +fi + +if [[ `which plenv` ]] ; then + + # init plenv + eval "$(plenv init -)" + + # Load the auto-completion script if it exists. + [[ -e "${HOME}/.plenv/completions/plenv.bash" ]] && source "${HOME}/.plenv/completions/plenv.bash" + +fi From 110828b3c5eae7beb11ede27d2aef98fce636612 Mon Sep 17 00:00:00 2001 From: ravenhall Date: Tue, 10 May 2016 15:37:34 -0500 Subject: [PATCH 191/216] Added convenience aliases for curl --- aliases/available/curl.aliases.bash | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 aliases/available/curl.aliases.bash diff --git a/aliases/available/curl.aliases.bash b/aliases/available/curl.aliases.bash new file mode 100644 index 00000000..4618dae1 --- /dev/null +++ b/aliases/available/curl.aliases.bash @@ -0,0 +1,23 @@ +#!/bin/bash + +cite 'about-alias' +about-alias 'Curl aliases for convenience.' + +# set apt aliases +function _set_pkg_aliases() +{ + if [ -x $(which curl) ]; then + # follow redirects + alias cl='curl -L' + # follow redirects, download as original name + alias clo='curl -L -O' + # follow redirects, download as original name, continue + alias cloc='curl -L -C - -O' + # follow redirects, download as original name, continue, retry 5 times + alias clocr='curl -L -C - -O --retry 5' + # follow redirects, fetch banner + alias clb='curl -L -I' + fi +} + +_set_pkg_aliases From 47f9689868b7ad8ac6b821b05a1c7fd926f49521 Mon Sep 17 00:00:00 2001 From: Telyn ZF Roat Date: Thu, 12 May 2016 11:55:23 +0100 Subject: [PATCH 192/216] Add rough port of oh-my-zsh's gallifrey theme --- themes/gallifrey/gallifrey.theme.bash | 41 +++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 themes/gallifrey/gallifrey.theme.bash diff --git a/themes/gallifrey/gallifrey.theme.bash b/themes/gallifrey/gallifrey.theme.bash new file mode 100644 index 00000000..a601db12 --- /dev/null +++ b/themes/gallifrey/gallifrey.theme.bash @@ -0,0 +1,41 @@ +# scm theming +SCM_THEME_PROMPT_PREFIX="${yellow}(" +SCM_THEME_PROMPT_SUFFIX=")${normal}" + +SCM_THEME_PROMPT_DIRTY="*" +SCM_THEME_PROMPT_CLEAN="" +SCM_GIT_CHAR="g" +SCM_SVN_CHAR="s" +SCM_HG_CHAR="h" + +### TODO: openSUSE has already colors enabled, check if those differs from stock +# LS colors, made with http://geoff.greer.fm/lscolors/ +# export LSCOLORS="Gxfxcxdxbxegedabagacad" +# export LS_COLORS='no=00:fi=00:di=01;34:ln=00;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=41;33;01:ex=00;32:*.cmd=00;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.btm=01;32:*.dll=01;32:*.tar=00;31:*.tbz=00;31:*.tgz=00;31:*.rpm=00;31:*.deb=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.zip=00;31:*.zoo=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.tb2=00;31:*.tz2=00;31:*.tbz2=00;31:*.avi=01;35:*.bmp=01;35:*.fli=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mng=01;35:*.mov=01;35:*.mpg=01;35:*.pcx=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.ppm=01;35:*.tga=01;35:*.tif=01;35:*.xbm=01;35:*.xpm=01;35:*.dl=01;35:*.gl=01;35:*.wmv=01;35:*.aiff=00;32:*.au=00;32:*.mid=00;32:*.mp3=00;32:*.ogg=00;32:*.voc=00;32:*.wav=00;32:' + +scm_prompt() { + CHAR=$(scm_char) + if [ $CHAR = $SCM_NONE_CHAR ] + then + return + else + echo "$(scm_prompt_info) " + fi +} + +pure_prompt() { + ps_host="${green}\h${normal}"; + ps_user_mark="${bold}\$${normal}"; + ps_root_mark="${normal}§" + ps_path="${normal}\w"; + + # make it work + case $(id -u) in + 0) PS1="$ps_host $ps_path $(scm_prompt)$ps_root_mark " + ;; + *) PS1="$ps_host $ps_path $(scm_prompt)$ps_user_mark " + ;; + esac +} + +PROMPT_COMMAND=pure_prompt; From db5061cf804c7ebe6924b4a8f6d5725718e1c7b9 Mon Sep 17 00:00:00 2001 From: Konstantin Gredeskoul Date: Thu, 12 May 2016 04:04:51 -0700 Subject: [PATCH 193/216] Better tests, more resilience and a bug fix --- lib/search.bash | 2 +- test/lib/helpers.bats | 10 ++++++++++ test/lib/search.bats | 34 +++++++++++++++++++++++++++------- 3 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 test/lib/helpers.bats diff --git a/lib/search.bash b/lib/search.bash index 9afe3a3c..aa9a13ea 100644 --- a/lib/search.bash +++ b/lib/search.bash @@ -98,7 +98,7 @@ _bash-it-search-component() { [[ "${term:0:1}" == "-" ]] && negative_terms=(${negative_terms[@]} ${term:1}) && continue # print asterisk next to each result that is already enabled by the user - local term_match=($(echo "${help}"| ${_grep} -i -- ${term} | cut -b -30 | sed 's/ *\[ \]//g;s/ *\[x\]/*/g;' )) + local term_match=($(echo "${help}"| ${_grep} -i -- ${term} | egrep '\[( |x)\]' | cut -b -30 | sed 's/ *\[ \]//g;s/ *\[x\]/*/g;' )) [[ "${#term_match[@]}" -gt 0 ]] && { matches=(${matches[@]} ${term_match[@]}) # append to the list of results } diff --git a/test/lib/helpers.bats b/test/lib/helpers.bats new file mode 100644 index 00000000..4f3e4ffa --- /dev/null +++ b/test/lib/helpers.bats @@ -0,0 +1,10 @@ +#!/usr/bin/env bats + +load ../../lib/composure +load ../../plugins/available/base.plugin + +cite _about _param _example _group _author _version + +load ../../lib/helpers + +## TODO: write some tests. diff --git a/test/lib/search.bats b/test/lib/search.bats index 35b68d86..dc4ba59a 100644 --- a/test/lib/search.bats +++ b/test/lib/search.bats @@ -15,19 +15,39 @@ NO_COLOR=true [[ "${lines[0]}" =~ 'plugins' && "${lines[0]}" =~ 'base' ]] } -@test "helpers search all ruby et al" { +@test "helpers search ruby gem bundle rake rails" { + # first disable them all, so that the output does not appear with a checkbox + # and we can compoare the result run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' 'rails' '--disable' + # Now perform the search run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' 'rails' - [[ "${lines[0]/✓/}" == ' aliases => bundler rails' ]] - [[ "${lines[1]/✓/}" == ' plugins => chruby chruby-auto ruby' ]] + # And verify + [[ "${lines[0]/✓/}" == ' aliases => bundler rails' ]] && \ + [[ "${lines[1]/✓/}" == ' plugins => chruby chruby-auto ruby' ]] && \ [[ "${lines[2]/✓/}" == ' completions => bundler gem rake' ]] } -@test "search enable and disable" { +@test "search ruby gem bundle -chruby rake rails" { + run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' 'rails' '--disable' + run _bash-it-search 'ruby' 'gem' 'bundle' '-chruby' 'rake' 'rails' + [[ "${lines[0]/✓/}" == ' aliases => bundler rails' ]] && \ + [[ "${lines[1]/✓/}" == ' plugins => ruby' ]] && \ + [[ "${lines[2]/✓/}" == ' completions => bundler gem rake' ]] +} + +@test "search (rails enabled) ruby gem bundle rake rails" { run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' 'rails' '--disable' run _enable-alias 'rails' run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' 'rails' - [[ "${lines[0]}" == ' aliases => bundler ✓rails' ]] - [[ "${lines[1]}" == ' plugins => chruby chruby-auto ruby' ]] - [[ "${lines[2]}" == ' completions => bundler gem rake' ]] + [[ "${lines[0]}" == ' aliases => bundler ✓rails' ]] && \ + [[ "${lines[1]}" == ' plugins => chruby chruby-auto ruby' ]] && \ + [[ "${lines[2]}" == ' completions => bundler gem rake' ]] +} + +@test "search (all enabled) ruby gem bundle rake rails" { + run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' '-chruby' 'rails' '--enable' + run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' '-chruby' 'rails' + [[ "${lines[0]}" == ' aliases => ✓bundler ✓rails' ]] && \ + [[ "${lines[1]}" == ' plugins => ✓ruby' ]] && \ + [[ "${lines[2]}" == ' completions => ✓bundler ✓gem ✓rake' ]] } From 871472d93d204d7bb404cc346b3dbb3c51be1ee9 Mon Sep 17 00:00:00 2001 From: Matt Broyles Date: Mon, 16 May 2016 20:17:47 -0500 Subject: [PATCH 194/216] Added function to kill daemonized rails server --- lib/killrails.bash | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 lib/killrails.bash diff --git a/lib/killrails.bash b/lib/killrails.bash new file mode 100644 index 00000000..00b4e3a5 --- /dev/null +++ b/lib/killrails.bash @@ -0,0 +1,11 @@ +# Quick function to kill a daemonized Rails server +function killrails() { + railsPid="$(cat tmp/pids/server.pid)" + if [ ! -z "$railsPid" ]; then + echo "[OK] Rails Server Process Id : ${railsPid}" + kill -9 $railsPid + echo "[OK] Process Killed" + else + echo "[FAIL] Error killing Rails server" + fi +} \ No newline at end of file From 05385d43d702b05faa381b1977e03b02429f9e19 Mon Sep 17 00:00:00 2001 From: Matt Broyles Date: Tue, 17 May 2016 16:10:54 -0500 Subject: [PATCH 195/216] Moved killrails to plugins, added newline, added meta information, cut indentation to 2 spaces. --- lib/killrails.bash | 11 ----------- plugins/available/killrails.plugin.bash | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 11 deletions(-) delete mode 100644 lib/killrails.bash create mode 100644 plugins/available/killrails.plugin.bash diff --git a/lib/killrails.bash b/lib/killrails.bash deleted file mode 100644 index 00b4e3a5..00000000 --- a/lib/killrails.bash +++ /dev/null @@ -1,11 +0,0 @@ -# Quick function to kill a daemonized Rails server -function killrails() { - railsPid="$(cat tmp/pids/server.pid)" - if [ ! -z "$railsPid" ]; then - echo "[OK] Rails Server Process Id : ${railsPid}" - kill -9 $railsPid - echo "[OK] Process Killed" - else - echo "[FAIL] Error killing Rails server" - fi -} \ No newline at end of file diff --git a/plugins/available/killrails.plugin.bash b/plugins/available/killrails.plugin.bash new file mode 100644 index 00000000..2c8d2779 --- /dev/null +++ b/plugins/available/killrails.plugin.bash @@ -0,0 +1,15 @@ +cite about-plugin +about-plugin 'Function to kill a daemonized Rails server.' + +# Quick function to kill a daemonized Rails server +function killrails() { + railsPid="$(cat tmp/pids/server.pid)" + if [ ! -z "$railsPid" ]; then + echo "[OK] Rails Server Process Id : ${railsPid}" + kill -9 $railsPid + echo "[OK] Process Killed" + else + echo "[FAIL] Error killing Rails server" + return 1 + fi +} From 76d026f2adb89a1edf3ba9896f009c379df7a78a Mon Sep 17 00:00:00 2001 From: Matt Broyles Date: Wed, 18 May 2016 09:33:12 -0500 Subject: [PATCH 196/216] added about and group metadata --- plugins/available/killrails.plugin.bash | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/available/killrails.plugin.bash b/plugins/available/killrails.plugin.bash index 2c8d2779..21983f82 100644 --- a/plugins/available/killrails.plugin.bash +++ b/plugins/available/killrails.plugin.bash @@ -3,6 +3,9 @@ about-plugin 'Function to kill a daemonized Rails server.' # Quick function to kill a daemonized Rails server function killrails() { + about 'Searches for a daemonized Rails server in tmp/pids and attempts to kill it.' + group 'server' + railsPid="$(cat tmp/pids/server.pid)" if [ ! -z "$railsPid" ]; then echo "[OK] Rails Server Process Id : ${railsPid}" From 18f9a8ebc4889e467c6f0856be43309aae445140 Mon Sep 17 00:00:00 2001 From: mairanteodoro Date: Wed, 18 May 2016 12:57:05 -0400 Subject: [PATCH 197/216] Add new theme 'mairan' (based on 'zork') --- themes/mairan/mairan.theme.bash | 99 +++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 themes/mairan/mairan.theme.bash diff --git a/themes/mairan/mairan.theme.bash b/themes/mairan/mairan.theme.bash new file mode 100644 index 00000000..ff9dc824 --- /dev/null +++ b/themes/mairan/mairan.theme.bash @@ -0,0 +1,99 @@ +# Mairan Bash Prompt, inspired by "Zork" + +SCM_THEME_PROMPT_PREFIX="" +SCM_THEME_PROMPT_SUFFIX="" + +SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗${normal}" +SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓${normal}" +SCM_GIT_CHAR="${bold_green}±${normal}" +SCM_SVN_CHAR="${bold_cyan}⑆${normal}" +SCM_HG_CHAR="${bold_red}☿${normal}" + +#Mysql Prompt +export MYSQL_PS1="(\u@\h) [\d]> " + +case $TERM in + xterm*) + TITLEBAR="\[\033]0;\w\007\]" + ;; + *) + TITLEBAR="" + ;; +esac + +PS3=">> " + +__my_rvm_ruby_version() { + local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}') + [ "$gemset" != "" ] && gemset="@$gemset" + local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}') + local full="$version$gemset" + [ "$full" != "" ] && echo "[$full]" +} + +is_vim_shell() { + if [ ! -z "$VIMRUNTIME" ] + then + echo "[${cyan}vim shell${normal}]" + fi +} + +modern_scm_prompt() { + CHAR=$(scm_char) + if [ $CHAR = $SCM_NONE_CHAR ] + then + return + else + echo "[$(scm_char)][$(scm_prompt_info)]" + fi +} + +# show chroot if exist +chroot(){ + if [ -n "$debian_chroot" ] + then + my_ps_chroot="${bold_cyan}$debian_chroot${normal}"; + echo "($my_ps_chroot)"; + fi + } + +# show virtualenvwrapper +my_ve(){ + if [ -n "$VIRTUAL_ENV" ] + then + my_ps_ve="${bold_purple}$ve${normal}"; + echo "($my_ps_ve)"; + fi + echo ""; + } + +prompt() { + + my_ps_host="${red}\h${normal}"; + # yes, these are the the same for now ... + my_ps_host_root="${red}\h${normal}"; + + my_ps_user="${bold_orange}\u${normal}" + my_ps_root="${bold_red}\u${normal}"; + + if [ -n "$VIRTUAL_ENV" ] + then + ve=`basename $VIRTUAL_ENV`; + fi + + # nice prompt + case "`id -u`" in + 0) PS1="\n${TITLEBAR}┌─$(my_ve)$(chroot)[$my_ps_root][$my_ps_host_root]$(modern_scm_prompt)$(__my_rvm_ruby_version)[${green}\w${normal}]$(is_vim_shell) +└─▪ " + ;; + *) PS1="\n${TITLEBAR}┌─$(my_ve)$(chroot)[$my_ps_user][$my_ps_host]$(modern_scm_prompt)$(__my_rvm_ruby_version)[${green}\w${normal}]$(is_vim_shell) +└─▪ " + ;; + esac +} + +PS2="└─▪ " + + + +PROMPT_COMMAND=prompt From bcc536f81aa1a518a540e6b1f12b06940a91ead2 Mon Sep 17 00:00:00 2001 From: mairanteodoro Date: Wed, 18 May 2016 16:50:31 -0400 Subject: [PATCH 198/216] New color scheme for 'mairan' theme. --- themes/mairan/mairan.theme.bash | 47 +++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/themes/mairan/mairan.theme.bash b/themes/mairan/mairan.theme.bash index ff9dc824..3451d3cb 100644 --- a/themes/mairan/mairan.theme.bash +++ b/themes/mairan/mairan.theme.bash @@ -1,5 +1,36 @@ # Mairan Bash Prompt, inspired by "Zork" +if tput setaf 1 &> /dev/null; then + if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then + MAGENTA=$(tput setaf 9) + ORANGE=$(tput setaf 172) + GREEN=$(tput setaf 190) + PURPLE=$(tput setaf 141) + WHITE=$(tput setaf 0) + else + MAGENTA=$(tput setaf 5) + ORANGE=$(tput setaf 4) + GREEN=$(tput setaf 2) + PURPLE=$(tput setaf 1) + WHITE=$(tput setaf 7) + fi + BOLD=$(tput bold) + RESET=$(tput sgr0) +else + MAGENTA="\033[1;31m" + ORANGE="\033[1;33m" + GREEN="\033[1;32m" + PURPLE="\033[1;35m" + WHITE="\033[1;37m" + BOLD="" + RESET="\033[m" +fi + +# prompt_symbol='λ' +# prompt_symbol='⚡' +prompt_symbol='' +BRACKET_COLOR=$ORANGE + SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_SUFFIX="" @@ -44,7 +75,7 @@ modern_scm_prompt() { then return else - echo "[$(scm_char)][$(scm_prompt_info)]" + echo "[$(scm_char)][$GREEN$(scm_prompt_info)]" fi } @@ -69,11 +100,11 @@ my_ve(){ prompt() { - my_ps_host="${red}\h${normal}"; + my_ps_host="$BOLD$ORANGE\h${normal}"; # yes, these are the the same for now ... - my_ps_host_root="${red}\h${normal}"; + my_ps_host_root="$ORANGE\h${normal}"; - my_ps_user="${bold_orange}\u${normal}" + my_ps_user="$BOLD$GREEN\u${normal}" my_ps_root="${bold_red}\u${normal}"; if [ -n "$VIRTUAL_ENV" ] @@ -83,11 +114,11 @@ prompt() { # nice prompt case "`id -u`" in - 0) PS1="\n${TITLEBAR}┌─$(my_ve)$(chroot)[$my_ps_root][$my_ps_host_root]$(modern_scm_prompt)$(__my_rvm_ruby_version)[${green}\w${normal}]$(is_vim_shell) -└─▪ " + 0) PS1="\n${TITLEBAR}${BRACKET_COLOR}┌─${normal}$(my_ve)$(chroot)[$my_ps_root][$my_ps_host_root]$(modern_scm_prompt)$(__my_rvm_ruby_version)[${green}\w${normal}]$(is_vim_shell)${BRACKET_COLOR} +└─▪ ${prompt_symbol} ${normal}" ;; - *) PS1="\n${TITLEBAR}┌─$(my_ve)$(chroot)[$my_ps_user][$my_ps_host]$(modern_scm_prompt)$(__my_rvm_ruby_version)[${green}\w${normal}]$(is_vim_shell) -└─▪ " + *) PS1="\n${TITLEBAR}${BRACKET_COLOR}┌─${normal}$(my_ve)$(chroot)[$my_ps_user][$my_ps_host]$(modern_scm_prompt)${normal}$(__my_rvm_ruby_version)[${green}\w${normal}]$(is_vim_shell)${BRACKET_COLOR} +└─▪ ${prompt_symbol} ${normal}" ;; esac } From 497f1a952016a38f8e61c5a8b175fa8fc2bef148 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Thu, 19 May 2016 09:03:01 +0200 Subject: [PATCH 199/216] Fixed indentation It was using a mixture of tabs and spaces. Converted to 2 spaces. --- plugins/available/killrails.plugin.bash | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/available/killrails.plugin.bash b/plugins/available/killrails.plugin.bash index 21983f82..10a62164 100644 --- a/plugins/available/killrails.plugin.bash +++ b/plugins/available/killrails.plugin.bash @@ -1,4 +1,4 @@ -cite about-plugin +cite about-plugin about-plugin 'Function to kill a daemonized Rails server.' # Quick function to kill a daemonized Rails server @@ -9,10 +9,10 @@ function killrails() { railsPid="$(cat tmp/pids/server.pid)" if [ ! -z "$railsPid" ]; then echo "[OK] Rails Server Process Id : ${railsPid}" - kill -9 $railsPid - echo "[OK] Process Killed" + kill -9 $railsPid + echo "[OK] Process Killed" else - echo "[FAIL] Error killing Rails server" - return 1 + echo "[FAIL] Error killing Rails server" + return 1 fi } From d32316bdf9b58c33e7132f36f191fa6c753786e4 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Thu, 19 May 2016 09:03:59 +0200 Subject: [PATCH 200/216] Fixed group meta tag --- plugins/available/killrails.plugin.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/available/killrails.plugin.bash b/plugins/available/killrails.plugin.bash index 10a62164..c5b2bbe6 100644 --- a/plugins/available/killrails.plugin.bash +++ b/plugins/available/killrails.plugin.bash @@ -4,7 +4,7 @@ about-plugin 'Function to kill a daemonized Rails server.' # Quick function to kill a daemonized Rails server function killrails() { about 'Searches for a daemonized Rails server in tmp/pids and attempts to kill it.' - group 'server' + group 'killrails' railsPid="$(cat tmp/pids/server.pid)" if [ ! -z "$railsPid" ]; then From 2618d2141fa75a36e79bf3628dc35e5023e50465 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Thu, 19 May 2016 09:09:37 +0200 Subject: [PATCH 201/216] Fixed unit tests --- test/lib/search.bats | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/lib/search.bats b/test/lib/search.bats index dc4ba59a..0871e3a2 100644 --- a/test/lib/search.bats +++ b/test/lib/search.bats @@ -23,7 +23,7 @@ NO_COLOR=true run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' 'rails' # And verify [[ "${lines[0]/✓/}" == ' aliases => bundler rails' ]] && \ - [[ "${lines[1]/✓/}" == ' plugins => chruby chruby-auto ruby' ]] && \ + [[ "${lines[1]/✓/}" == ' plugins => chruby chruby-auto killrails ruby' ]] && \ [[ "${lines[2]/✓/}" == ' completions => bundler gem rake' ]] } @@ -31,7 +31,7 @@ NO_COLOR=true run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' 'rails' '--disable' run _bash-it-search 'ruby' 'gem' 'bundle' '-chruby' 'rake' 'rails' [[ "${lines[0]/✓/}" == ' aliases => bundler rails' ]] && \ - [[ "${lines[1]/✓/}" == ' plugins => ruby' ]] && \ + [[ "${lines[1]/✓/}" == ' plugins => killrails ruby' ]] && \ [[ "${lines[2]/✓/}" == ' completions => bundler gem rake' ]] } @@ -40,7 +40,7 @@ NO_COLOR=true run _enable-alias 'rails' run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' 'rails' [[ "${lines[0]}" == ' aliases => bundler ✓rails' ]] && \ - [[ "${lines[1]}" == ' plugins => chruby chruby-auto ruby' ]] && \ + [[ "${lines[1]}" == ' plugins => chruby chruby-auto killrails ruby' ]] && \ [[ "${lines[2]}" == ' completions => bundler gem rake' ]] } @@ -48,6 +48,6 @@ NO_COLOR=true run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' '-chruby' 'rails' '--enable' run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' '-chruby' 'rails' [[ "${lines[0]}" == ' aliases => ✓bundler ✓rails' ]] && \ - [[ "${lines[1]}" == ' plugins => ✓ruby' ]] && \ + [[ "${lines[1]}" == ' plugins => ✓killrails ✓ruby' ]] && \ [[ "${lines[2]}" == ' completions => ✓bundler ✓gem ✓rake' ]] } From bf69bbc6129bf675e618098318cf8901ba78ed28 Mon Sep 17 00:00:00 2001 From: Shawn Hensley Date: Sun, 22 May 2016 01:00:46 -0500 Subject: [PATCH 202/216] Add history cite. Remove trailing semicolon and space. --- plugins/available/history.plugin.bash | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/available/history.plugin.bash b/plugins/available/history.plugin.bash index 386e05d1..efd33981 100644 --- a/plugins/available/history.plugin.bash +++ b/plugins/available/history.plugin.bash @@ -1,6 +1,8 @@ +cite about-plugin +about-plugin 'history manipulation' # enter a few characters and press UpArrow/DownArrow # to search backwards/forwards through the history -if [ -t 1 ]; +if [ -t 1 ] then bind '"":history-search-backward' bind '"":history-search-forward' From 64a620d9e26c30c43e16d92b87068e87e22c7e24 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Mon, 23 May 2016 08:39:18 +0200 Subject: [PATCH 203/216] Renamed killrails plugin to rails --- plugins/available/{killrails.plugin.bash => rails.plugin.bash} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename plugins/available/{killrails.plugin.bash => rails.plugin.bash} (100%) diff --git a/plugins/available/killrails.plugin.bash b/plugins/available/rails.plugin.bash similarity index 100% rename from plugins/available/killrails.plugin.bash rename to plugins/available/rails.plugin.bash From 8929b13c6e4559cf5131ba15e58196be5b848a19 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Mon, 23 May 2016 08:40:13 +0200 Subject: [PATCH 204/216] Updated meta information --- plugins/available/rails.plugin.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/available/rails.plugin.bash b/plugins/available/rails.plugin.bash index c5b2bbe6..414fd9f9 100644 --- a/plugins/available/rails.plugin.bash +++ b/plugins/available/rails.plugin.bash @@ -1,10 +1,10 @@ cite about-plugin -about-plugin 'Function to kill a daemonized Rails server.' +about-plugin 'Helper functions for Ruby on Rails' # Quick function to kill a daemonized Rails server function killrails() { about 'Searches for a daemonized Rails server in tmp/pids and attempts to kill it.' - group 'killrails' + group 'rails' railsPid="$(cat tmp/pids/server.pid)" if [ ! -z "$railsPid" ]; then From 58674d5a8916306070c642e41e83925305276580 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Mon, 23 May 2016 08:40:51 +0200 Subject: [PATCH 205/216] Updated unit tests --- test/lib/search.bats | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/lib/search.bats b/test/lib/search.bats index 0871e3a2..ae9e9a89 100644 --- a/test/lib/search.bats +++ b/test/lib/search.bats @@ -23,7 +23,7 @@ NO_COLOR=true run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' 'rails' # And verify [[ "${lines[0]/✓/}" == ' aliases => bundler rails' ]] && \ - [[ "${lines[1]/✓/}" == ' plugins => chruby chruby-auto killrails ruby' ]] && \ + [[ "${lines[1]/✓/}" == ' plugins => chruby chruby-auto rails ruby' ]] && \ [[ "${lines[2]/✓/}" == ' completions => bundler gem rake' ]] } @@ -31,7 +31,7 @@ NO_COLOR=true run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' 'rails' '--disable' run _bash-it-search 'ruby' 'gem' 'bundle' '-chruby' 'rake' 'rails' [[ "${lines[0]/✓/}" == ' aliases => bundler rails' ]] && \ - [[ "${lines[1]/✓/}" == ' plugins => killrails ruby' ]] && \ + [[ "${lines[1]/✓/}" == ' plugins => rails ruby' ]] && \ [[ "${lines[2]/✓/}" == ' completions => bundler gem rake' ]] } @@ -40,7 +40,7 @@ NO_COLOR=true run _enable-alias 'rails' run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' 'rails' [[ "${lines[0]}" == ' aliases => bundler ✓rails' ]] && \ - [[ "${lines[1]}" == ' plugins => chruby chruby-auto killrails ruby' ]] && \ + [[ "${lines[1]}" == ' plugins => chruby chruby-auto rails ruby' ]] && \ [[ "${lines[2]}" == ' completions => bundler gem rake' ]] } @@ -48,6 +48,6 @@ NO_COLOR=true run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' '-chruby' 'rails' '--enable' run _bash-it-search 'ruby' 'gem' 'bundle' 'rake' '-chruby' 'rails' [[ "${lines[0]}" == ' aliases => ✓bundler ✓rails' ]] && \ - [[ "${lines[1]}" == ' plugins => ✓killrails ✓ruby' ]] && \ + [[ "${lines[1]}" == ' plugins => ✓rails ✓ruby' ]] && \ [[ "${lines[2]}" == ' completions => ✓bundler ✓gem ✓rake' ]] } From 14525efefa8ece496dce3c1e42447667f852f72e Mon Sep 17 00:00:00 2001 From: Ron Waldon Date: Wed, 25 May 2016 17:32:33 +1000 Subject: [PATCH 206/216] load theme _after_ loading any plugins, etc --- bash_it.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bash_it.sh b/bash_it.sh index 21445034..9d877dd2 100755 --- a/bash_it.sh +++ b/bash_it.sh @@ -38,11 +38,14 @@ cite _about _param _example _group _author _version source "${BASH_IT}/themes/colors.theme.bash" source "${BASH_IT}/themes/base.theme.bash" -# library +# libraries, but skip appearance (themes) for now LIB="${BASH_IT}/lib/*.bash" +APPEARANCE_LIB="${BASH_IT}/lib/appearance.bash" for config_file in $LIB do - source $config_file + if [ $config_file != $APPEARANCE_LIB ]; then + source $config_file + fi done # Load enabled aliases, completion, plugins @@ -51,6 +54,9 @@ do _load_bash_it_files $file_type done +# appearance (themes) now, after all dependencies +source $APPEARANCE_LIB + # Load custom aliases, completion, plugins for file_type in "aliases" "completion" "plugins" do From 9103f4e758869d68bf2baf53dddbe90b200c45cc Mon Sep 17 00:00:00 2001 From: przepompownia Date: Sat, 28 May 2016 22:31:24 +0200 Subject: [PATCH 207/216] Replace static command list by generated. It requires version 2.1 of tmux --- completion/available/tmux.completion.bash | 108 +++------------------- 1 file changed, 12 insertions(+), 96 deletions(-) diff --git a/completion/available/tmux.completion.bash b/completion/available/tmux.completion.bash index a1b8f069..d47288d7 100644 --- a/completion/available/tmux.completion.bash +++ b/completion/available/tmux.completion.bash @@ -5,92 +5,8 @@ # Usage: Put "source bash_completion_tmux.sh" into your .bashrc # Based upon the example at http://paste-it.appspot.com/Pj4mLycDE - _tmux_cmds=" \ -attach-session \ -bind-key \ -break-pane \ -capture-pane \ -choose-client \ -choose-session \ -choose-window \ -clear-history \ -clock-mode \ -command-prompt \ -confirm-before \ -copy-buffer \ -copy-mode \ -delete-buffer \ -detach-client \ -display-message \ -display-panes \ -down-pane \ -find-window \ -has-session \ -if-shell \ -join-pane \ -kill-pane \ -kill-server \ -kill-session \ -kill-window \ -last-window \ -link-window \ -list-buffers \ -list-clients \ -list-commands \ -list-keys \ -list-panes \ -list-sessions \ -list-windows \ -load-buffer \ -lock-client \ -lock-server \ -lock-session \ -move-window \ -new-session \ -new-window \ -next-layout \ -next-window \ -paste-buffer \ -pipe-pane \ -previous-layout \ -previous-window \ -refresh-client \ -rename-session \ -rename-window \ -resize-pane \ -respawn-window \ -rotate-window \ -run-shell \ -save-buffer \ -select-layout \ -select-pane \ -select-prompt \ -select-window \ -send-keys \ -send-prefix \ -server-info \ -set-buffer \ -set-environment \ -set-option \ -set-window-option \ -show-buffer \ -show-environment \ -show-messages \ -show-options \ -show-window-options \ -source-file \ -split-window \ -start-server \ -suspend-client \ -swap-pane \ -swap-window \ -switch-client \ -unbind-key \ -unlink-window \ -up-pane" - -_tmux_expand () -{ +_tmux_expand () +{ [ "$cur" != "${cur%\\}" ] && cur="$cur"'\'; if [[ "$cur" == \~*/* ]]; then eval cur=$cur; @@ -103,8 +19,8 @@ _tmux_expand () fi } -_tmux_filedir () -{ +_tmux_filedir () +{ local IFS=' '; _tmux_expand || return 0; @@ -130,7 +46,7 @@ function _tmux_complete_window() { local cur="${1}" local session_name="$(echo "${cur}" | sed 's/\\//g' | cut -d ':' -f 1)" local sessions - + sessions="$(tmux -q list-sessions 2>/dev/null | sed -re 's/([^:]+:).*$/\1/')" if [[ -n "${session_name}" ]]; then sessions="${sessions} @@ -186,8 +102,8 @@ _tmux() { if [[ $COMP_CWORD -le $cmd_index ]]; then # The user has not specified a command yet - COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "${_tmux_cmds}" -- "${cur}") ) - else + COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux list-commands | cut -d' ' -f1)" -- "${cur}") ) + else case ${cmd} in attach-session|attach) case "$prev" in @@ -213,7 +129,7 @@ _tmux() { case "$prev" in -t) _tmux_complete_session "${cur}" ;; -[n|d|s]) options="-d -n -s -t --" ;; - *) + *) if [[ ${COMP_WORDS[option_index]} == -- ]]; then _command_offset ${option_index} else @@ -249,7 +165,7 @@ _tmux() { -t) _tmux_complete_session "${cur}" ;; *) options="-l -n -p -c -t" ;; esac ;; - + send-keys|send) case "$option" in -t) _tmux_complete_window "${cur}" ;; @@ -257,12 +173,12 @@ _tmux() { esac ;; esac # case ${cmd} fi # command specified - fi # not -f - + fi # not -f + if [[ -n "${options}" ]]; then COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "${options}" -- "${cur}") ) fi - + return 0 } From 71bbd9d41a23f28a82d5c12496f136e5437ff2f1 Mon Sep 17 00:00:00 2001 From: Sardorbek Imomaliev Date: Tue, 31 May 2016 21:44:08 +0600 Subject: [PATCH 208/216] fix tmux-completion when trying to use withiout running server --- completion/available/tmux.completion.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/completion/available/tmux.completion.bash b/completion/available/tmux.completion.bash index d47288d7..ddadcbd8 100644 --- a/completion/available/tmux.completion.bash +++ b/completion/available/tmux.completion.bash @@ -50,7 +50,7 @@ function _tmux_complete_window() { sessions="$(tmux -q list-sessions 2>/dev/null | sed -re 's/([^:]+:).*$/\1/')" if [[ -n "${session_name}" ]]; then sessions="${sessions} -$(tmux -q list-windows -t "${session_name}" 2>/dev/null | sed -re 's/^([^:]+):.*$/'"${session_name}"':\1/')" + $(tmux -q list-windows -t "${session_name}" 2>/dev/null | sed -re 's/^([^:]+):.*$/'"${session_name}"':\1/')" fi cur="$(echo "${cur}" | sed -e 's/:/\\\\:/')" sessions="$(echo "${sessions}" | sed -e 's/:/\\\\:/')" @@ -102,7 +102,7 @@ _tmux() { if [[ $COMP_CWORD -le $cmd_index ]]; then # The user has not specified a command yet - COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux list-commands | cut -d' ' -f1)" -- "${cur}") ) + COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux start-server \; list-commands | cut -d' ' -f1)" -- "${cur}") ) else case ${cmd} in attach-session|attach) From 6228fa5e72f1882f167d15c2ff7e515229f666f7 Mon Sep 17 00:00:00 2001 From: Gabriel Ricci Date: Wed, 1 Jun 2016 05:49:38 +0000 Subject: [PATCH 209/216] Adding support for rvm-promt to powerline-plain theme --- .../powerline-plain.theme.bash | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/themes/powerline-plain/powerline-plain.theme.bash b/themes/powerline-plain/powerline-plain.theme.bash index dbe0f7c2..5c3ca826 100644 --- a/themes/powerline-plain/powerline-plain.theme.bash +++ b/themes/powerline-plain/powerline-plain.theme.bash @@ -5,7 +5,10 @@ SHELL_THEME_PROMPT_COLOR=32 SHELL_SSH_THEME_PROMPT_COLOR=208 VIRTUALENV_CHAR="ⓔ " -VIRTUALENV_THEME_PROMPT_COLOR=35 +VIRTUALENV_THEME_PROMPT_COLOR=25 + +GEMSET_CHAR="ⓔ " +GEMSET_THEME_PROMPT_COLOR=25 SCM_NONE_CHAR="" SCM_GIT_CHAR="⎇ " @@ -59,6 +62,17 @@ function powerline_virtualenv_prompt { fi } +function powerline_gemset_prompt { + local gemset=$(rvm-prompt 2>/dev/null) + + if [[ -n "$gemset" ]]; then + GEMSET_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${GEMSET_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}$(set_rgb_color - ${GEMSET_THEME_PROMPT_COLOR}) ${VIRTUALENV_CHAR}$gemset ${normal}" + LAST_THEME_COLOR=${GEMSET_THEME_PROMPT_COLOR} + else + GEMSET_PROMPT="" + fi +} + function powerline_scm_prompt { scm_prompt_vars @@ -98,11 +112,12 @@ function powerline_prompt_command() { powerline_shell_prompt powerline_virtualenv_prompt + powerline_gemset_prompt powerline_scm_prompt powerline_cwd_prompt powerline_last_status_prompt LAST_STATUS - PS1="${SHELL_PROMPT}${VIRTUALENV_PROMPT}${SCM_PROMPT}${CWD_PROMPT}${LAST_STATUS_PROMPT} " + PS1="${SHELL_PROMPT}${GEMSET_PROMPT}${VIRTUALENV_PROMPT}${SCM_PROMPT}${CWD_PROMPT}${LAST_STATUS_PROMPT} " } PROMPT_COMMAND=powerline_prompt_command From 669d068b120b520b141c29cb46bdd1b557f955d5 Mon Sep 17 00:00:00 2001 From: Robert Rauch Date: Thu, 2 Jun 2016 10:36:37 +0200 Subject: [PATCH 210/216] Support HG_ROOT containing whitespaces --- themes/base.theme.bash | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 2f1bf4b3..d961b10d 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -256,16 +256,16 @@ function hg_prompt_vars { HG_ROOT=$(get_hg_root) - if [ -f $HG_ROOT/branch ]; then + if [ -f "$HG_ROOT/branch" ]; then # Mercurial holds it's current branch in .hg/branch file - SCM_BRANCH=$(cat $HG_ROOT/branch) + SCM_BRANCH=$(cat "$HG_ROOT/branch") else SCM_BRANCH=$(hg summary 2> /dev/null | grep branch: | awk '{print $2}') fi - if [ -f $HG_ROOT/dirstate ]; then + if [ -f "$HG_ROOT/dirstate" ]; then # Mercurial holds various information about the working directory in .hg/dirstate file. More on http://mercurial.selenic.com/wiki/DirState - SCM_CHANGE=$(hexdump -n 10 -e '1/1 "%02x"' $HG_ROOT/dirstate | cut -c-12) + SCM_CHANGE=$(hexdump -n 10 -e '1/1 "%02x"' "$HG_ROOT/dirstate" | cut -c-12) else SCM_CHANGE=$(hg summary 2> /dev/null | grep parent: | awk '{print $2}') fi From 734c937232a612b7e1e5bf13c36e585784d57b71 Mon Sep 17 00:00:00 2001 From: Cristian Lupascu Date: Wed, 8 Jun 2016 13:23:47 +0300 Subject: [PATCH 211/216] added the nwinkler_random_colors theme --- themes/nwinkler_random_colors/README.md | 29 +++++ .../nwinkler_random_colors.theme.bash | 112 ++++++++++++++++++ themes/nwinkler_random_colors/screenshot.png | Bin 0 -> 43510 bytes 3 files changed, 141 insertions(+) create mode 100644 themes/nwinkler_random_colors/README.md create mode 100644 themes/nwinkler_random_colors/nwinkler_random_colors.theme.bash create mode 100644 themes/nwinkler_random_colors/screenshot.png diff --git a/themes/nwinkler_random_colors/README.md b/themes/nwinkler_random_colors/README.md new file mode 100644 index 00000000..80620efb --- /dev/null +++ b/themes/nwinkler_random_colors/README.md @@ -0,0 +1,29 @@ +# Nwinkler Random Color Theme + +## Description + +The *Nwinkler Random Color* Theme is based on the [nwinkler theme](https://github.com/Bash-it/bash-it/wiki/Themes#nwinkler), but it randomizes the colors for: + +* time +* username +* hostname +* path + +The random colors are chosen the first time this theme is used and saved to the `~/.nwinkler_random_colors` file. So, the next time you connect to the same machine, you will get the same colors. + +To force new random colors to be selected, run the command: + +```sh +randomize_nwinkler +``` + +## Screenshot + +Here it is in action: + +![alt text](screenshot.png "Nwinkler Random Color Theme in Action!") + +## Usage Scenario + +This theme is especially useful when connecting to many different machines and switching between them often. Yes, the hostname *is* present in the prompt. But I argue that it's a lot faster to get a "feel" of what machine you are currently on because of the custom colors on that machine's prompt than by reading the hostname. + diff --git a/themes/nwinkler_random_colors/nwinkler_random_colors.theme.bash b/themes/nwinkler_random_colors/nwinkler_random_colors.theme.bash new file mode 100644 index 00000000..23634276 --- /dev/null +++ b/themes/nwinkler_random_colors/nwinkler_random_colors.theme.bash @@ -0,0 +1,112 @@ +#!/bin/bash + +# Two line prompt showing the following information: +# (time) SCM [username@hostname] pwd (SCM branch SCM status) +# → +# +# Example: +# (14:00:26) ± [foo@bar] ~/.bash_it (master ✓) +# → +# +# The arrow on the second line is showing the exit status of the last command: +# * Green: 0 exit status +# * Red: non-zero exit status +# +# The exit code functionality currently doesn't work if you are using the 'fasd' plugin, +# since 'fasd' is messing with the $PROMPT_COMMAND + +RANDOM_COLOR_FILE=$HOME/.nwinkler_random_colors + +function randomize_nwinkler { + declare -a AVAILABLE_COLORS + + AVAILABLE_COLORS=( + $black + $red + $green + $yellow + $blue + $purple + $cyan + $white + $orange + $bold_black + $bold_red + $bold_green + $bold_yellow + $bold_blue + $bold_purple + $bold_cyan + $bold_white + $bold_orange + ) + # Uncomment these to allow underlines: + #$underline_black + #$underline_red + #$underline_green + #$underline_yellow + #$underline_blue + #$underline_purple + #$underline_cyan + #$underline_white + #$underline_orange + #) + + USERNAME_COLOR=${AVAILABLE_COLORS[$RANDOM % ${#AVAILABLE_COLORS[@]} ]} + HOSTNAME_COLOR=${AVAILABLE_COLORS[$RANDOM % ${#AVAILABLE_COLORS[@]} ]} + TIME_COLOR=${AVAILABLE_COLORS[$RANDOM % ${#AVAILABLE_COLORS[@]} ]} + PATH_COLOR=${AVAILABLE_COLORS[$RANDOM % ${#AVAILABLE_COLORS[@]} ]} + + echo "$USERNAME_COLOR,$HOSTNAME_COLOR,$TIME_COLOR,$PATH_COLOR," > $RANDOM_COLOR_FILE +} + +if [ -f $RANDOM_COLOR_FILE ]; +then + # read the colors already stored in the file + IFS=',' read -ra COLORS < $RANDOM_COLOR_FILE + USERNAME_COLOR=${COLORS[0]} + HOSTNAME_COLOR=${COLORS[1]} + TIME_COLOR=${COLORS[2]} + PATH_COLOR=${COLORS[3]} +else + # No colors stored yet. Generate them! + randomize_nwinkler + + echo + echo "Looks like you are using the nwinkler_random_color bashit theme for the first time." + echo "Random colors have been generated to be used in your prompt." + echo "If you don't like them, run the command:" + echo " randomize_nwinkler" + echo "until you get a combination that you like." + echo +fi + +PROMPT_END_CLEAN="${green}→${reset_color}" +PROMPT_END_DIRTY="${red}→${reset_color}" + +function prompt_end() { + echo -e "$PROMPT_END" +} + +prompt_setter() { + local exit_status=$? + if [[ $exit_status -eq 0 ]]; then PROMPT_END=$PROMPT_END_CLEAN + else PROMPT_END=$PROMPT_END_DIRTY + fi + # Save history + history -a + history -c + history -r + PS1="(${TIME_COLOR}\t${reset_color}) $(scm_char) [${USERNAME_COLOR}\u${reset_color}@${HOSTNAME_COLOR}\H${reset_color}] ${PATH_COLOR}\w${reset_color}$(scm_prompt_info) ${reset_color}\n$(prompt_end) " + PS2='> ' + PS4='+ ' +} + +PROMPT_COMMAND=prompt_setter + +SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗${normal}" +SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓${normal}" +SCM_THEME_PROMPT_PREFIX=" (" +SCM_THEME_PROMPT_SUFFIX=")" +RVM_THEME_PROMPT_PREFIX=" (" +RVM_THEME_PROMPT_SUFFIX=")" diff --git a/themes/nwinkler_random_colors/screenshot.png b/themes/nwinkler_random_colors/screenshot.png new file mode 100644 index 0000000000000000000000000000000000000000..e8cc75d8948f04a0466206de558c2a19930ed310 GIT binary patch literal 43510 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 Date: Wed, 15 Jun 2016 20:38:55 -0500 Subject: [PATCH 212/216] Added gittowork plugin --- plugins/available/gittowork.plugin.bash | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 plugins/available/gittowork.plugin.bash diff --git a/plugins/available/gittowork.plugin.bash b/plugins/available/gittowork.plugin.bash new file mode 100644 index 00000000..9b68d27c --- /dev/null +++ b/plugins/available/gittowork.plugin.bash @@ -0,0 +1,23 @@ +cite about-plugin +about-plugin 'Downloads the latest .gitignore file by project type' + +function gittowork() { + about 'Places the latest .gitignore file for a given project type in the current directory, or concatenates onto an existing .gitignore' + group 'git' + + result=$(curl -L "Https://www.gitignore.io/api/$1" 2>/dev/null) + + if [[ $result =~ ERROR ]]; then + echo "Query '$1' has no match. See a list of possible queries with 'GitToWork List'" + elif [[ $1 = list ]]; then + echo "$result" + else + if [[ -f .gitignore ]]; then + result=`echo "$result" | grep -v "# Created by http://www.gitignore.io"` + echo ".gitignore already exists, appending..." + echo "$result" >> .gitignore + else + echo "$result" > .gitignore + fi + fi +} \ No newline at end of file From 478e8ddb1bba6b61be4ad7c297aa563e9b7ee34f Mon Sep 17 00:00:00 2001 From: Matt Broyles Date: Wed, 15 Jun 2016 20:40:19 -0500 Subject: [PATCH 213/216] Inserted newline after gittowork --- plugins/available/gittowork.plugin.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/available/gittowork.plugin.bash b/plugins/available/gittowork.plugin.bash index 9b68d27c..bcad46dd 100644 --- a/plugins/available/gittowork.plugin.bash +++ b/plugins/available/gittowork.plugin.bash @@ -4,7 +4,7 @@ about-plugin 'Downloads the latest .gitignore file by project type' function gittowork() { about 'Places the latest .gitignore file for a given project type in the current directory, or concatenates onto an existing .gitignore' group 'git' - + result=$(curl -L "Https://www.gitignore.io/api/$1" 2>/dev/null) if [[ $result =~ ERROR ]]; then @@ -20,4 +20,4 @@ function gittowork() { echo "$result" > .gitignore fi fi -} \ No newline at end of file +} From fe8254b574f522a5aa96cbdc451ff9382bc6d630 Mon Sep 17 00:00:00 2001 From: Matt Broyles Date: Mon, 20 Jun 2016 10:32:01 -0500 Subject: [PATCH 214/216] Moved gittowork to git.plugin.bash, removed gittowork.plugin.bash --- plugins/available/git.plugin.bash | 22 ++++++++++++++++++++++ plugins/available/gittowork.plugin.bash | 23 ----------------------- 2 files changed, 22 insertions(+), 23 deletions(-) delete mode 100644 plugins/available/gittowork.plugin.bash diff --git a/plugins/available/git.plugin.bash b/plugins/available/git.plugin.bash index 6506ca45..27de163f 100644 --- a/plugins/available/git.plugin.bash +++ b/plugins/available/git.plugin.bash @@ -198,3 +198,25 @@ else fi } +function gittowork() { + about 'Places the latest .gitignore file for a given project type in the current directory, or concatenates onto an existing .gitignore' + group 'git' + + result=$(curl -L "Https://www.gitignore.io/api/$1" 2>/dev/null) + + if [[ $result =~ ERROR ]]; then + echo "Query '$1' has no match. See a list of possible queries with 'gittowork List'" + elif [[ $1 = list ]]; then + echo "$result" + else + if [[ -f .gitignore ]]; then + result=`echo "$result" | grep -v "# Created by http://www.gitignore.io"` + echo ".gitignore already exists, appending..." + echo "$result" >> .gitignore + else + echo "$result" > .gitignore + fi + fi +} + + diff --git a/plugins/available/gittowork.plugin.bash b/plugins/available/gittowork.plugin.bash deleted file mode 100644 index bcad46dd..00000000 --- a/plugins/available/gittowork.plugin.bash +++ /dev/null @@ -1,23 +0,0 @@ -cite about-plugin -about-plugin 'Downloads the latest .gitignore file by project type' - -function gittowork() { - about 'Places the latest .gitignore file for a given project type in the current directory, or concatenates onto an existing .gitignore' - group 'git' - - result=$(curl -L "Https://www.gitignore.io/api/$1" 2>/dev/null) - - if [[ $result =~ ERROR ]]; then - echo "Query '$1' has no match. See a list of possible queries with 'GitToWork List'" - elif [[ $1 = list ]]; then - echo "$result" - else - if [[ -f .gitignore ]]; then - result=`echo "$result" | grep -v "# Created by http://www.gitignore.io"` - echo ".gitignore already exists, appending..." - echo "$result" >> .gitignore - else - echo "$result" > .gitignore - fi - fi -} From 932a9512943ed4d840914411924ebaef5a0d5e87 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Tue, 21 Jun 2016 13:16:43 +0200 Subject: [PATCH 215/216] Added missing meta tags for gittowork Also fixed some typos in the function. --- plugins/available/git.plugin.bash | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/available/git.plugin.bash b/plugins/available/git.plugin.bash index 27de163f..00bd2d42 100644 --- a/plugins/available/git.plugin.bash +++ b/plugins/available/git.plugin.bash @@ -201,11 +201,13 @@ fi function gittowork() { about 'Places the latest .gitignore file for a given project type in the current directory, or concatenates onto an existing .gitignore' group 'git' + param '1: the language/type of the project, used for determining the contents of the .gitignore file' + example '$ gittowork java' - result=$(curl -L "Https://www.gitignore.io/api/$1" 2>/dev/null) + result=$(curl -L "https://www.gitignore.io/api/$1" 2>/dev/null) if [[ $result =~ ERROR ]]; then - echo "Query '$1' has no match. See a list of possible queries with 'gittowork List'" + echo "Query '$1' has no match. See a list of possible queries with 'gittowork list'" elif [[ $1 = list ]]; then echo "$result" else From fbca9c92a5c18e14d2f41f447f6abc4f5b48e8bf Mon Sep 17 00:00:00 2001 From: Matt Broyles Date: Mon, 27 Jun 2016 15:02:34 -0500 Subject: [PATCH 216/216] Added gitignore-reload plugin --- plugins/available/git.plugin.bash | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/plugins/available/git.plugin.bash b/plugins/available/git.plugin.bash index 00bd2d42..d5aa6d8f 100644 --- a/plugins/available/git.plugin.bash +++ b/plugins/available/git.plugin.bash @@ -221,4 +221,57 @@ function gittowork() { fi } +function gitignore-reload() { + about 'Empties the git cache, and readds all files not blacklisted by .gitignore' + group 'git' + example '$ gitignore-reload' + + # The .gitignore file should not be reloaded if there are uncommited changes. + # Firstly, require a clean work tree. The function require_clean_work_tree() + # was stolen with love from https://www.spinics.net/lists/git/msg142043.html + + # Begin require_clean_work_tree() + + # Update the index + git update-index -q --ignore-submodules --refresh + err=0 + + # Disallow unstaged changes in the working tree + if ! git diff-files --quiet --ignore-submodules -- + then + echo >&2 "ERROR: Cannot reload .gitignore: Your index contains unstaged changes." + git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2 + err=1 + fi + + # Disallow uncommited changes in the index + if ! git diff-index --cached --quiet HEAD --ignore-submodules + then + echo >&2 "ERROR: Cannot reload .gitignore: Your index contains uncommited changes." + git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2 + err=1 + fi + + # Prompt user to commit or stash changes and exit + if [ $err = 1 ] + then + echo >&2 "Please commit or stash them." + fi + + # End require_clean_work_tree() + + # If we're here, then there are no uncommited or unstaged changes dangling around. + # Proceed to reload .gitignore + if [ $err = 0 ]; then + # Remove all cached files + git rm -r --cached . + + # Re-add everything. The changed .gitignore will be picked up here and will exclude the files + # now blacklisted by .gitignore + echo >&2 "Running git add ." + git add . + echo >&2 "Files readded. Commit your new changes now." + fi +} +