From 0bdcf196aaaffbc2af4884570a05144831e012f3 Mon Sep 17 00:00:00 2001 From: Miguel Morales Date: Tue, 12 May 2015 11:30:49 -0500 Subject: [PATCH 01/14] Add pretty cat plugin for cat with syntax highlighting --- plugins/available/pretty-cat.plugin.bash | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 plugins/available/pretty-cat.plugin.bash diff --git a/plugins/available/pretty-cat.plugin.bash b/plugins/available/pretty-cat.plugin.bash new file mode 100644 index 00000000..6e5f57c9 --- /dev/null +++ b/plugins/available/pretty-cat.plugin.bash @@ -0,0 +1,21 @@ +cite about-plugin +about-plugin 'pygmentize instead of cat to terminal if possible' + +if [ -z $(which pygmentize) ] +then + echo "Pygments is required to use this pluging" + echo "Install it by doing 'pip install Pygments' as the superuser" + exit +fi + +# get the actual cat binary +CAT_BIN=$(which cat) + +# replace the cat binary for a pygmentize if possible +cat() +{ + for var; + do + pygmentize "$var" 2>/dev/null || "$CAT_BIN" "$var"; + done +} From af2f0304cbf8fe22ad3e29b1445879981e27fd19 Mon Sep 17 00:00:00 2001 From: Miguel Morales Date: Tue, 12 May 2015 15:57:39 -0500 Subject: [PATCH 02/14] Add proper exit code --- plugins/available/pretty-cat.plugin.bash | 30 ++++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/available/pretty-cat.plugin.bash b/plugins/available/pretty-cat.plugin.bash index 6e5f57c9..93d66c80 100644 --- a/plugins/available/pretty-cat.plugin.bash +++ b/plugins/available/pretty-cat.plugin.bash @@ -1,21 +1,21 @@ cite about-plugin about-plugin 'pygmentize instead of cat to terminal if possible' -if [ -z $(which pygmentize) ] -then - echo "Pygments is required to use this pluging" - echo "Install it by doing 'pip install Pygments' as the superuser" - exit -fi +if [ -z $(which pygmentize) ] +then + echo "Pygments is required to use this pluging" + echo "Install it by doing 'pip install Pygments' as the superuser" + exit 1 +fi -# get the actual cat binary -CAT_BIN=$(which cat) +# get the actual cat binary +CAT_BIN=$(which cat) -# replace the cat binary for a pygmentize if possible -cat() -{ - for var; - do - pygmentize "$var" 2>/dev/null || "$CAT_BIN" "$var"; - done +# replace the cat binary for a pygmentize if possible +cat() +{ + for var; + do + pygmentize "$var" 2>/dev/null || "$CAT_BIN" "$var"; + done } From 3f98e953cd5abfd6ef01d7fc8d4baf1d3f783a6d Mon Sep 17 00:00:00 2001 From: Miguel Morales Date: Tue, 12 May 2015 16:26:18 -0500 Subject: [PATCH 03/14] Fix typo --- plugins/available/pretty-cat.plugin.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/available/pretty-cat.plugin.bash b/plugins/available/pretty-cat.plugin.bash index 93d66c80..c9def54b 100644 --- a/plugins/available/pretty-cat.plugin.bash +++ b/plugins/available/pretty-cat.plugin.bash @@ -3,7 +3,7 @@ about-plugin 'pygmentize instead of cat to terminal if possible' if [ -z $(which pygmentize) ] then - echo "Pygments is required to use this pluging" + echo "Pygments is required to use this plugin" echo "Install it by doing 'pip install Pygments' as the superuser" exit 1 fi From 6b1789e385aa1d06ef8db5c583fa9d22076cefc2 Mon Sep 17 00:00:00 2001 From: Miguel Morales Date: Tue, 12 May 2015 16:36:07 -0500 Subject: [PATCH 04/14] Add cat function documentation --- plugins/available/pretty-cat.plugin.bash | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/available/pretty-cat.plugin.bash b/plugins/available/pretty-cat.plugin.bash index c9def54b..ab5bda62 100644 --- a/plugins/available/pretty-cat.plugin.bash +++ b/plugins/available/pretty-cat.plugin.bash @@ -14,6 +14,9 @@ CAT_BIN=$(which cat) # replace the cat binary for a pygmentize if possible cat() { + about 'runs either pygmentize or cat on each file passed in' + param '*: files to concatenate (as normally passed to cat' + example 'cat mysite/manage.py dir/text-file.txt' for var; do pygmentize "$var" 2>/dev/null || "$CAT_BIN" "$var"; From 6821b6c0dcc94f5b9a4c50ea0ef2db117bc9f8be Mon Sep 17 00:00:00 2001 From: Miguel Morales Date: Sun, 24 May 2015 18:04:42 -0500 Subject: [PATCH 05/14] Add less and remove hard exit --- ...t.plugin.bash => less-pretty-cat.plugin.bash} | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) rename plugins/available/{pretty-cat.plugin.bash => less-pretty-cat.plugin.bash} (62%) diff --git a/plugins/available/pretty-cat.plugin.bash b/plugins/available/less-pretty-cat.plugin.bash similarity index 62% rename from plugins/available/pretty-cat.plugin.bash rename to plugins/available/less-pretty-cat.plugin.bash index ab5bda62..7b1a280c 100644 --- a/plugins/available/pretty-cat.plugin.bash +++ b/plugins/available/less-pretty-cat.plugin.bash @@ -5,20 +5,28 @@ if [ -z $(which pygmentize) ] then echo "Pygments is required to use this plugin" echo "Install it by doing 'pip install Pygments' as the superuser" - exit 1 fi -# get the actual cat binary +# get the full paths to binaries CAT_BIN=$(which cat) +LESS_BIN=$(which less) -# replace the cat binary for a pygmentize if possible +# pigmentize cat and less outputs cat() { about 'runs either pygmentize or cat on each file passed in' - param '*: files to concatenate (as normally passed to cat' + param '*: files to concatenate (as normally passed to cat)' example 'cat mysite/manage.py dir/text-file.txt' for var; do pygmentize "$var" 2>/dev/null || "$CAT_BIN" "$var"; done } + +less() +{ + 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 "$1" | "$LESS_BIN" -R +} From 80c7874ebc459fcd1995bba4896182b62e01f729 Mon Sep 17 00:00:00 2001 From: Ian Huston Date: Sat, 6 Jun 2015 10:44:56 +0100 Subject: [PATCH 06/14] Add Python version and Conda environment prompt functions. --- themes/base.theme.bash | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 584fb9ce..f6e4da83 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -250,6 +250,22 @@ function virtualenv_prompt { fi } +function condaenv_prompt { + if [[ $CONDA_DEFAULT_ENV ]]; then + echo -e "${CONDAENV_THEME_PROMPT_PREFIX}${CONDA_DEFAULT_ENV}${CONDAENV_THEME_PROMPT_SUFFIX}" + fi +} + +function py_interp_prompt { + py_version=$(python --version 2>&1 | awk '{print "py-"$2;}') || return + echo -e "${PYTHON_THEME_PROMPT_PREFIX}${py_version}${PYTHON_THEME_PROMPT_SUFFIX}" +} + +function python_version_prompt { + echo -e "$(virtualenv_prompt)$(condaenv_prompt)$(py_interp_prompt)" +} + + # backwards-compatibility function git_prompt_info { git_prompt_vars From 1b9dab7bc6374532e0834eab27c85d641b8e0dec Mon Sep 17 00:00:00 2001 From: Ian Huston Date: Sat, 6 Jun 2015 10:51:35 +0100 Subject: [PATCH 07/14] Modified version of the bobby theme which shows Python version, Virtualenv directory and Conda environment name. --- themes/bobby-python/bobby-python.theme.bash | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 themes/bobby-python/bobby-python.theme.bash diff --git a/themes/bobby-python/bobby-python.theme.bash b/themes/bobby-python/bobby-python.theme.bash new file mode 100644 index 00000000..962ebca7 --- /dev/null +++ b/themes/bobby-python/bobby-python.theme.bash @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +SCM_THEME_PROMPT_DIRTY=" ${red}✗" +SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓" +SCM_THEME_PROMPT_PREFIX=" |" +SCM_THEME_PROMPT_SUFFIX="${green}|" + +GIT_THEME_PROMPT_DIRTY=" ${red}✗" +GIT_THEME_PROMPT_CLEAN=" ${bold_green}✓" +GIT_THEME_PROMPT_PREFIX=" ${green}|" +GIT_THEME_PROMPT_SUFFIX="${green}|" + +CONDAENV_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}$(python_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 dabf0e8c42027ae83e3ae0eea26ed610062c1932 Mon Sep 17 00:00:00 2001 From: Ivan Povalyukhin Date: Sun, 7 Jun 2015 20:08:39 -0700 Subject: [PATCH 08/14] [pathmunge] remove duplicate entry into PATH variable on reload command --- plugins/available/latex.plugin.bash | 2 +- plugins/available/pipsi.plugin.bash | 2 +- plugins/available/pyenv.plugin.bash | 3 ++- plugins/available/rbenv.plugin.bash | 3 ++- plugins/available/ruby.plugin.bash | 2 +- plugins/available/todo.plugin.bash | 3 ++- 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/plugins/available/latex.plugin.bash b/plugins/available/latex.plugin.bash index eefec59d..6ebb70d3 100644 --- a/plugins/available/latex.plugin.bash +++ b/plugins/available/latex.plugin.bash @@ -4,6 +4,6 @@ about-plugin 'use mactex' # add mactex to the path if its present MACTEX_PATH=/usr/local/texlive/2009/bin/universal-darwin if [[ -d $MACTEX_PATH ]]; then - export PATH=$PATH:$MACTEX_PATH + pathmunge $MACTEX_PATH after fi unset MACTEX_PATH diff --git a/plugins/available/pipsi.plugin.bash b/plugins/available/pipsi.plugin.bash index 305e83cc..916d86d2 100644 --- a/plugins/available/pipsi.plugin.bash +++ b/plugins/available/pipsi.plugin.bash @@ -3,5 +3,5 @@ about-plugin 'load pipsi, if you are using it' if [[ -f "$HOME/.local/bin/pipsi" ]] then - export PATH=~/.local/bin:$PATH + pathmunge ~/.local/bin fi diff --git a/plugins/available/pyenv.plugin.bash b/plugins/available/pyenv.plugin.bash index 7ed2d3cd..8e4f1edd 100644 --- a/plugins/available/pyenv.plugin.bash +++ b/plugins/available/pyenv.plugin.bash @@ -2,7 +2,8 @@ cite about-plugin about-plugin 'load pyenv, if you are using it' export PYENV_ROOT="$HOME/.pyenv" -export PATH="$PYENV_ROOT/bin:$PATH" +pathmunge $PYENV_ROOT + [[ `which pyenv` ]] && eval "$(pyenv init -)" #Load pyenv virtualenv if the virtualenv plugin is installed. diff --git a/plugins/available/rbenv.plugin.bash b/plugins/available/rbenv.plugin.bash index 70fe62c3..a6c25559 100644 --- a/plugins/available/rbenv.plugin.bash +++ b/plugins/available/rbenv.plugin.bash @@ -3,7 +3,8 @@ cite about-plugin about-plugin 'load rbenv, if you are using it' -export PATH="$HOME/.rbenv/bin:$PATH" +pathmunge "${HOME}/.rbenv/bin" + [[ `which rbenv` ]] && eval "$(rbenv init -)" # Load the auto-completion script if rbenv was loaded. diff --git a/plugins/available/ruby.plugin.bash b/plugins/available/ruby.plugin.bash index b320cb30..4ab891d9 100644 --- a/plugins/available/ruby.plugin.bash +++ b/plugins/available/ruby.plugin.bash @@ -4,7 +4,7 @@ about-plugin 'ruby and rubygems specific functions and settings' # Make commands installed with 'gem install --user-install' available # ~/.gem/ruby/${RUBY_VERSION}/bin/ if which ruby >/dev/null && which gem >/dev/null; then - PATH="$PATH:$(ruby -e 'print Gem.user_dir')/bin"; + pathmunge "$(ruby -e 'print Gem.user_dir')/bin" after fi function remove_gem { diff --git a/plugins/available/todo.plugin.bash b/plugins/available/todo.plugin.bash index 28559def..ef9266e2 100755 --- a/plugins/available/todo.plugin.bash +++ b/plugins/available/todo.plugin.bash @@ -15,6 +15,7 @@ fi # respect ENV var set in .bash_profile, default is 't' alias $TODO='$TODO_SRC_DIR/todo.sh -d $TODO_SRC_DIR/todo.cfg' -export PATH=$PATH:$TODO_SRC_DIR +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 From 1cb9093c9c4cfd741eea165aa5d36d499407ac28 Mon Sep 17 00:00:00 2001 From: Ivan Povalyukhin Date: Sun, 7 Jun 2015 20:23:19 -0700 Subject: [PATCH 09/14] [pathmunge] fix test and modify metadata syntax in the function pathmunge to be easier supported in the test --- lib/helpers.bash | 8 ++++---- test/plugins/ruby.plugin.bats | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/helpers.bash b/lib/helpers.bash index c5ae9cd1..ebd68119 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -365,10 +365,10 @@ all_groups () if ! type pathmunge > /dev/null 2>&1 then function pathmunge () { - _about 'prevent duplicate directories in you PATH variable' - _group 'lib helpers' - _example 'pathmunge /path/to/dir is equivalent to PATH=/path/to/dir:$PATH' - _example 'pathmunge /path/to/dir after is equivalent to PATH=$PATH:/path/to/dir' + about 'prevent duplicate directories in you PATH variable' + group 'lib helpers' + example 'pathmunge /path/to/dir is equivalent to PATH=/path/to/dir:$PATH' + example 'pathmunge /path/to/dir after is equivalent to PATH=$PATH:/path/to/dir' if ! [[ $PATH =~ (^|:)$1($|:) ]] ; then if [ "$2" = "after" ] ; then diff --git a/test/plugins/ruby.plugin.bats b/test/plugins/ruby.plugin.bats index d3bbd70d..b9d9f56c 100755 --- a/test/plugins/ruby.plugin.bats +++ b/test/plugins/ruby.plugin.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats load ../test_helper +load ../../lib/helpers load ../../lib/composure load ../../plugins/available/ruby.plugin From e143d4f6969eb1774a0d83cf378c171967d0487f Mon Sep 17 00:00:00 2001 From: Miguel Morales Date: Tue, 9 Jun 2015 07:46:32 -0500 Subject: [PATCH 10/14] Allow for passing arguments to pygmentize --- 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 7b1a280c..a68975e5 100644 --- a/plugins/available/less-pretty-cat.plugin.bash +++ b/plugins/available/less-pretty-cat.plugin.bash @@ -28,5 +28,5 @@ less() 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 "$1" | "$LESS_BIN" -R + pygmentize "$*" | "$LESS_BIN" -R } From 7d05e25dbb65588c4f65b71b58d498e6b6e7c821 Mon Sep 17 00:00:00 2001 From: Antti Ahti Date: Tue, 9 Jun 2015 16:17:23 +0300 Subject: [PATCH 11/14] npm autocompletion --- completion/available/npm.completion.bash | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 completion/available/npm.completion.bash diff --git a/completion/available/npm.completion.bash b/completion/available/npm.completion.bash new file mode 100644 index 00000000..10ee87bb --- /dev/null +++ b/completion/available/npm.completion.bash @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# npm (Node Package Manager) completion + +if command -v npm &>/dev/null +then + eval "$(npm completion)" +fi From be25f925c774fc825bac39b366ad191361c107ee Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Tue, 9 Jun 2015 23:16:47 +0200 Subject: [PATCH 12/14] Added completion to AWS plugin --- plugins/available/aws.plugin.bash | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/plugins/available/aws.plugin.bash b/plugins/available/aws.plugin.bash index c8920e38..c28cf20e 100644 --- a/plugins/available/aws.plugin.bash +++ b/plugins/available/aws.plugin.bash @@ -73,3 +73,29 @@ function __awskeys_export { function __awskeys_unset { unset AWS_DEFAULT_PROFILE AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY } + +function __awskeys_comp { + local cur prev opts prevprev + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + + opts="help list show export unset" + + case "${prev}" in + help|list|unset) + return 0 + ;; + show|export) + local profile_list="$(__awskeys_list | grep " ")" + COMPREPLY=( $(compgen -W "${profile_list}" -- ${cur}) ) + return 0 + ;; + esac + + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + + return 0 +} + +complete -F __awskeys_comp awskeys From d4c1ded1cc00f83b1732bacab573033e00c48ee5 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Thu, 11 Jun 2015 00:26:25 +0200 Subject: [PATCH 13/14] Check for AWS credentials file in AWS plugin --- plugins/available/aws.plugin.bash | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/available/aws.plugin.bash b/plugins/available/aws.plugin.bash index c28cf20e..35e7eccf 100644 --- a/plugins/available/aws.plugin.bash +++ b/plugins/available/aws.plugin.bash @@ -4,6 +4,12 @@ about-plugin 'AWS helper functions' function awskeys { about 'helper function for AWS credentials file' group 'aws' + + if [[ ! -f ~/.aws/credentials ]]; then + echo "AWS credentials file not found" + return 1 + fi + if [[ $# -eq 1 ]] && [[ "$1" = "list" ]]; then __awskeys_list "$2" elif [[ $# -eq 1 ]] && [[ "$1" = "unset" ]]; then @@ -39,8 +45,8 @@ function __awskeys_list { local credentials_list="$(egrep '^\[ *[a-zA-Z0-9_-]+ *\]$' ~/.aws/credentials)" if [[ -n $"{credentials_list}" ]]; then echo -e "Available credentials profiles:\n" - for cred in ${credentials_list}; do - echo " $(echo ${cred} | tr -d "[]")" + for profile in ${credentials_list}; do + echo " $(echo ${profile} | tr -d "[]")" done echo else From de9736445abd5881e7c13e1a55c3531c77fbdf33 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Mon, 8 Jun 2015 11:22:44 +0100 Subject: [PATCH 14/14] Added apmup alias --- 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 e9d427c7..f067697d 100644 --- a/aliases/available/atom.aliases.bash +++ b/aliases/available/atom.aliases.bash @@ -3,3 +3,4 @@ about-alias 'Atom.io editor abbreviations' alias a='atom' alias ah='atom .' +alias apmup='apm update --no-confirm'