Merge remote-tracking branch 'antono/fix-xterm-plugin'
diff --git a/aliases/available/maven.aliases.bash b/aliases/available/maven.aliases.bash
new file mode 100644
index 0000000..349f9d8
--- /dev/null
+++ b/aliases/available/maven.aliases.bash
@@ -0,0 +1,22 @@
+alias mci="mvn clean install"
+alias mi="mvn install"
+alias mrprep="mvn release:prepare"
+alias mrperf="mvn release:perform"
+alias mrrb="mvn release:rollback"
+alias mdep="mvn dependency:tree"
+alias mpom="mvn help:effective-pom"
+alias mcisk="mci -Dmaven.test.skip=true"
+
+function maven-help() {
+ echo "Maven Custom Aliases Usage"
+ echo
+ echo " mci = mvn clean install"
+ echo " mi = mvn install"
+ echo " mrprep = mvn release:prepare"
+ echo " mrperf = mvn release:perform"
+ echo " mrrb = mvn release:rollback"
+ echo " mdep = mvn dependency:tree"
+ echo " mpom = mvn help:effective-pom"
+ echo " mcisk = mvn clean install -Dmaven.test.skip=true"
+ echo
+}
diff --git a/completion/available/defaults.completion.bash b/completion/available/defaults.completion.bash
new file mode 100644
index 0000000..5a8d034
--- /dev/null
+++ b/completion/available/defaults.completion.bash
@@ -0,0 +1,175 @@
+# defaults
+# Bash command line completion for defaults
+#
+# Created by Jonathon Mah on 2006-11-08.
+# Copyright 2006 Playhaus. All rights reserved.
+#
+# Version 1.0 (2006-11-08)
+
+
+_defaults_domains()
+{
+ local cur
+ COMPREPLY=()
+ cur=${COMP_WORDS[COMP_CWORD]}
+
+ local domains=$( defaults domains | sed -e 's/, /:/g' | tr : '\n' | sed -e 's/ /\\ /g' | grep -i "^$cur" )
+ local IFS=$'\n'
+ COMPREPLY=( $domains )
+ if [[ $( echo '-app' | grep "^$cur" ) ]]; then
+ COMPREPLY[${#COMPREPLY[@]}]="-app"
+ fi
+
+ return 0
+}
+
+
+_defaults()
+{
+ local cur prev host_opts cmds cmd domain keys key_index
+ cur=${COMP_WORDS[COMP_CWORD]}
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ host_opts='-currentHost -host'
+ cmds='read read-type write rename delete domains find help'
+
+ if [[ $COMP_CWORD -eq 1 ]]; then
+ COMPREPLY=( $( compgen -W "$host_opts $cmds" -- $cur ) )
+ return 0
+ elif [[ $COMP_CWORD -eq 2 ]]; then
+ if [[ "$prev" == "-currentHost" ]]; then
+ COMPREPLY=( $( compgen -W "$cmds" -- $cur ) )
+ return 0
+ elif [[ "$prev" == "-host" ]]; then
+ return 0
+ _known_hosts -a
+ else
+ _defaults_domains
+ return 0
+ fi
+ elif [[ $COMP_CWORD -eq 3 ]]; then
+ if [[ ${COMP_WORDS[1]} == "-host" ]]; then
+ _defaults_domains
+ return 0
+ fi
+ fi
+
+ # Both a domain and command have been specified
+
+ if [[ ${COMP_WORDS[1]} == [${cmds// /|}] ]]; then
+ cmd=${COMP_WORDS[1]}
+ domain=${COMP_WORDS[2]}
+ key_index=3
+ if [[ "$domain" == "-app" ]]; then
+ if [[ $COMP_CWORD -eq 3 ]]; then
+ # Completing application name. Can't help here, sorry
+ return 0
+ fi
+ domain="-app ${COMP_WORDS[3]}"
+ key_index=4
+ fi
+ elif [[ ${COMP_WORDS[2]} == "-currentHost" ]] && [[ ${COMP_WORDS[2]} == [${cmds// /|}] ]]; then
+ cmd=${COMP_WORDS[2]}
+ domain=${COMP_WORDS[3]}
+ key_index=4
+ if [[ "$domain" == "-app" ]]; then
+ if [[ $COMP_CWORD -eq 4 ]]; then
+ # Completing application name. Can't help here, sorry
+ return 0
+ fi
+ domain="-app ${COMP_WORDS[4]}"
+ key_index=5
+ fi
+ elif [[ ${COMP_WORDS[3]} == "-host" ]] && [[ ${COMP_WORDS[3]} == [${cmds// /|}] ]]; then
+ cmd=${COMP_WORDS[3]}
+ domain=${COMP_WORDS[4]}
+ key_index=5
+ if [[ "$domain" == "-app" ]]; then
+ if [[ $COMP_CWORD -eq 5 ]]; then
+ # Completing application name. Can't help here, sorry
+ return 0
+ fi
+ domain="-app ${COMP_WORDS[5]}"
+ key_index=6
+ fi
+ fi
+
+ keys=$( defaults read $domain 2>/dev/null | sed -n -e '/^ [^}) ]/p' | sed -e 's/^ \([^" ]\{1,\}\) = .*$/\1/g' -e 's/^ "\([^"]\{1,\}\)" = .*$/\1/g' | sed -e 's/ /\\ /g' )
+
+ case $cmd in
+ read|read-type)
+ # Complete key
+ local IFS=$'\n'
+ COMPREPLY=( $( echo "$keys" | grep -i "^${cur//\\/\\\\}" ) )
+ ;;
+ write)
+ if [[ $key_index -eq $COMP_CWORD ]]; then
+ # Complete key
+ local IFS=$'\n'
+ COMPREPLY=( $( echo "$keys" | grep -i "^${cur//\\/\\\\}" ) )
+ elif [[ $((key_index+1)) -eq $COMP_CWORD ]]; then
+ # Complete value type
+ # Unfortunately ${COMP_WORDS[key_index]} fails on keys with spaces
+ local value_types='-string -data -integer -float -boolean -date -array -array-add -dict -dict-add'
+ local cur_type=$( defaults read-type $domain ${COMP_WORDS[key_index]} 2>/dev/null | sed -e 's/^Type is \(.*\)/-\1/' -e's/dictionary/dict/' | grep "^$cur" )
+ if [[ $cur_type ]]; then
+ COMPREPLY=( $cur_type )
+ else
+ COMPREPLY=( $( compgen -W "$value_types" -- $cur ) )
+ fi
+ elif [[ $((key_index+2)) -eq $COMP_CWORD ]]; then
+ # Complete value
+ # Unfortunately ${COMP_WORDS[key_index]} fails on keys with spaces
+ COMPREPLY=( $( defaults read $domain ${COMP_WORDS[key_index]} 2>/dev/null | grep -i "^${cur//\\/\\\\}" ) )
+ fi
+ ;;
+ rename)
+ if [[ $key_index -eq $COMP_CWORD ]] ||
+ [[ $((key_index+1)) -eq $COMP_CWORD ]]; then
+ # Complete source and destination keys
+ local IFS=$'\n'
+ COMPREPLY=( $( echo "$keys" | grep -i "^${cur//\\/\\\\}" ) )
+ fi
+ ;;
+ delete)
+ if [[ $key_index -eq $COMP_CWORD ]]; then
+ # Complete key
+ local IFS=$'\n'
+ COMPREPLY=( $( echo "$keys" | grep -i "^${cur//\\/\\\\}" ) )
+ fi
+ ;;
+ esac
+
+ return 0
+}
+
+complete -F _defaults -o default defaults
+
+
+# This file is licensed under the BSD license, as follows:
+#
+# Copyright (c) 2006, Playhaus
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+# * Neither the name of the Playhaus nor the names of its contributors may be
+# used to endorse or promote products derived from this software without
+# specific prior written permission.
+#
+# This software is provided by the copyright holders and contributors "as is"
+# and any express or implied warranties, including, but not limited to, the
+# implied warranties of merchantability and fitness for a particular purpose are
+# disclaimed. In no event shall the copyright owner or contributors be liable
+# for any direct, indirect, incidental, special, exemplary, or consequential
+# damages (including, but not limited to, procurement of substitute goods or
+# services; loss of use, data, or profits; or business interruption) however
+# caused and on any theory of liability, whether in contract, strict liability,
+# or tort (including negligence or otherwise) arising in any way out of the use
+# of this software, even if advised of the possibility of such damage.
diff --git a/completion/available/fabric-completion.bash b/completion/available/fabric-completion.bash
new file mode 100644
index 0000000..a4aa90f
--- /dev/null
+++ b/completion/available/fabric-completion.bash
@@ -0,0 +1,133 @@
+#!/bin/bash
+#
+# Bash completion support for Fabric (http://fabfile.org/)
+#
+#
+# Copyright (C) 2011 by Konstantin Bakulin
+#
+# 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.
+#
+# Thanks to:
+# - Adam Vandenberg,
+# https://github.com/adamv/dotfiles/blob/master/completion_scripts/fab_completion.bash
+#
+# - Enrico Batista da Luz,
+# https://github.com/ricobl/dotfiles/blob/master/bin/fab_bash_completion
+#
+
+
+# Use cache files for fab tasks or not.
+# If set to "false" command "fab --shortlist" will be executed every time.
+export FAB_COMPLETION_CACHE_TASKS=true
+
+# File name where tasks cache will be stored (in current dir).
+export FAB_COMPLETION_CACHED_TASKS_FILENAME=".fab_tasks~"
+
+
+# Set command to get time of last file modification as seconds since Epoch
+case `uname` in
+ Darwin|FreeBSD)
+ __FAB_COMPLETION_MTIME_COMMAND="stat -f '%m'"
+ ;;
+ *)
+ __FAB_COMPLETION_MTIME_COMMAND="stat -c '%Y'"
+ ;;
+esac
+
+
+#
+# Get time of last fab cache file modification as seconds since Epoch
+#
+function __fab_chache_mtime() {
+ ${__FAB_COMPLETION_MTIME_COMMAND} \
+ $FAB_COMPLETION_CACHED_TASKS_FILENAME | xargs -n 1 expr
+}
+
+
+#
+# Get time of last fabfile file/module modification as seconds since Epoch
+#
+function __fab_fabfile_mtime() {
+ local f="fabfile"
+ if [[ -e "$f.py" ]]; then
+ ${__FAB_COMPLETION_MTIME_COMMAND} "$f.py" | xargs -n 1 expr
+ else
+ # Suppose that it's a fabfile dir
+ find $f/*.py -exec ${__FAB_COMPLETION_MTIME_COMMAND} {} + \
+ | xargs -n 1 expr | sort -n -r | head -1
+ fi
+}
+
+
+#
+# Completion for "fab" command
+#
+function __fab_completion() {
+ # Return if "fab" command doesn't exists
+ [[ -e `which fab 2> /dev/null` ]] || return 0
+
+ # Variables to hold the current word and possible matches
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ local opts=()
+
+ # Generate possible matches and store them in variable "opts"
+ case "${cur}" in
+ -*)
+ if [[ -z "${__FAB_COMPLETION_LONG_OPT}" ]]; then
+ export __FAB_COMPLETION_LONG_OPT=$(
+ fab --help | egrep -o "\-\-[A-Za-z_\-]+\=?" | sort -u)
+ fi
+ opts="${__FAB_COMPLETION_LONG_OPT}"
+ ;;
+
+ # Completion for short options is not nessary.
+ # It's left here just for history.
+ # -*)
+ # if [[ -z "${__FAB_COMPLETION_SHORT_OPT}" ]]; then
+ # export __FAB_COMPLETION_SHORT_OPT=$(
+ # fab --help | egrep -o "^ +\-[A-Za-z_\]" | sort -u)
+ # fi
+ # opts="${__FAB_COMPLETION_SHORT_OPT}"
+ # ;;
+
+ *)
+ # If "fabfile.py" or "fabfile" dir with "__init__.py" file exists
+ local f="fabfile"
+ if [[ -e "$f.py" || (-d "$f" && -e "$f/__init__.py") ]]; then
+ # Build a list of the available tasks
+ if $FAB_COMPLETION_CACHE_TASKS; then
+ # If use cache
+ if [[ ! -s ${FAB_COMPLETION_CACHED_TASKS_FILENAME} ||
+ $(__fab_fabfile_mtime) -gt $(__fab_chache_mtime) ]]; then
+ fab --shortlist > ${FAB_COMPLETION_CACHED_TASKS_FILENAME} \
+ 2> /dev/null
+ fi
+ opts=$(cat ${FAB_COMPLETION_CACHED_TASKS_FILENAME})
+ else
+ # Without cache
+ opts=$(fab --shortlist 2> /dev/null)
+ fi
+ fi
+ ;;
+ esac
+
+ # Set possible completions
+ COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
+}
+complete -o default -o nospace -F __fab_completion fab
diff --git a/completion/available/tmux.completion.bash b/completion/available/tmux.completion.bash
new file mode 100644
index 0000000..e8ee5e7
--- /dev/null
+++ b/completion/available/tmux.completion.bash
@@ -0,0 +1,189 @@
+#!/bin/bash
+
+# tmux completion
+# See: http://www.debian-administration.org/articles/317 for how to write more.
+# Usage: Put "source bash_completion_tmux.sh" into your .bashrc
+# Based upon the example at http://paste-it.appspot.com/Pj4mLycDE
+
+_tmux_expand ()
+{
+ [ "$cur" != "${cur%\\}" ] && cur="$cur"'\';
+ if [[ "$cur" == \~*/* ]]; then
+ eval cur=$cur;
+ else
+ if [[ "$cur" == \~* ]]; then
+ cur=${cur#\~};
+ COMPREPLY=($( compgen -P '~' -u $cur ));
+ return ${#COMPREPLY[@]};
+ fi;
+ fi
+}
+
+_tmux_filedir ()
+{
+ local IFS='
+';
+ _tmux_expand || return 0;
+ if [ "$1" = -d ]; then
+ COMPREPLY=(${COMPREPLY[@]} $( compgen -d -- $cur ));
+ return 0;
+ fi;
+ COMPREPLY=(${COMPREPLY[@]} $( eval compgen -f -- \"$cur\" ))
+}
+
+function _tmux_complete_client() {
+ local IFS=$'\n'
+ local cur="${1}"
+ COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux -q list-clients | cut -f 1 -d ':')" -- "${cur}") )
+}
+function _tmux_complete_session() {
+ local IFS=$'\n'
+ local cur="${1}"
+ COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux -q list-sessions | cut -f 1 -d ':')" -- "${cur}") )
+}
+function _tmux_complete_window() {
+ local IFS=$'\n'
+ local cur="${1}"
+ local session_name="$(echo "${cur}" | sed 's/\\//g' | cut -d ':' -f 1)"
+ local sessions
+
+ sessions="$(tmux -q list-sessions | sed -re 's/([^:]+:).*$/\1/')"
+ if [[ -n "${session_name}" ]]; then
+ sessions="${sessions}
+$(tmux -q list-windows -t "${session_name}" | sed -re 's/^([^:]+):.*$/'"${session_name}"':\1/')"
+ fi
+ cur="$(echo "${cur}" | sed -e 's/:/\\\\:/')"
+ sessions="$(echo "${sessions}" | sed -e 's/:/\\\\:/')"
+ COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "${sessions}" -- "${cur}") )
+}
+
+_tmux() {
+ local cur prev
+ local i cmd cmd_index option option_index
+ local opts=""
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+
+ if [ ${prev} == -f ]; then
+ _tmux_filedir
+ else
+ # Search for the command
+ local skip_next=0
+ for ((i=1; $i<=$COMP_CWORD; i++)); do
+ if [[ ${skip_next} -eq 1 ]]; then
+ #echo "Skipping"
+ skip_next=0;
+ elif [[ ${COMP_WORDS[i]} != -* ]]; then
+ cmd="${COMP_WORDS[i]}"
+ cmd_index=${i}
+ break
+ elif [[ ${COMP_WORDS[i]} == -f ]]; then
+ skip_next=1
+ fi
+ done
+
+ # Search for the last option command
+ skip_next=0
+ for ((i=1; $i<=$COMP_CWORD; i++)); do
+ if [[ ${skip_next} -eq 1 ]]; then
+ #echo "Skipping"
+ skip_next=0;
+ elif [[ ${COMP_WORDS[i]} == -* ]]; then
+ option="${COMP_WORDS[i]}"
+ option_index=${i}
+ if [[ ${COMP_WORDS[i]} == -- ]]; then
+ break;
+ fi
+ elif [[ ${COMP_WORDS[i]} == -f ]]; then
+ skip_next=1
+ fi
+ done
+
+ if [[ $COMP_CWORD -le $cmd_index ]]; then
+ # The user has not specified a command yet
+ local all_commands="$(tmux -q list-commands | cut -f 1 -d ' ')"
+ COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "${all_commands}" -- "${cur}") )
+ else
+ case ${cmd} in
+ attach-session|attach)
+ case "$prev" in
+ -t) _tmux_complete_session "${cur}" ;;
+ *) options="-t -d" ;;
+ esac ;;
+ detach-client|detach)
+ case "$prev" in
+ -t) _tmux_complete_client "${cur}" ;;
+ *) options="-t" ;;
+ esac ;;
+ lock-client|lockc)
+ case "$prev" in
+ -t) _tmux_complete_client "${cur}" ;;
+ *) options="-t" ;;
+ esac ;;
+ lock-session|locks)
+ case "$prev" in
+ -t) _tmux_complete_session "${cur}" ;;
+ *) options="-t -d" ;;
+ esac ;;
+ new-session|new)
+ 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
+ options="-d -n -s -t --"
+ fi
+ ;;
+ esac
+ ;;
+ refresh-client|refresh)
+ case "$prev" in
+ -t) _tmux_complete_client "${cur}" ;;
+ *) options="-t" ;;
+ esac ;;
+ rename-session|rename)
+ case "$prev" in
+ -t) _tmux_complete_session "${cur}" ;;
+ *) options="-t" ;;
+ esac ;;
+ source-file|source) _tmux_filedir ;;
+ has-session|has|kill-session)
+ case "$prev" in
+ -t) _tmux_complete_session "${cur}" ;;
+ *) options="-t" ;;
+ esac ;;
+ suspend-client|suspendc)
+ case "$prev" in
+ -t) _tmux_complete_client "${cur}" ;;
+ *) options="-t" ;;
+ esac ;;
+ switch-client|switchc)
+ case "$prev" in
+ -c) _tmux_complete_client "${cur}" ;;
+ -t) _tmux_complete_session "${cur}" ;;
+ *) options="-l -n -p -c -t" ;;
+ esac ;;
+
+ send-keys|send)
+ case "$option" in
+ -t) _tmux_complete_window "${cur}" ;;
+ *) options="-t" ;;
+ esac ;;
+ esac # case ${cmd}
+ fi # command specified
+ fi # not -f
+
+ if [[ -n "${options}" ]]; then
+ COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "${options}" -- "${cur}") )
+ fi
+
+ return 0
+
+}
+complete -F _tmux tmux
+
+# END tmux completion
+
diff --git a/plugins/available/nvm.plugin.bash b/plugins/available/nvm.plugin.bash
index a5145ec..3f489dd 100644
--- a/plugins/available/nvm.plugin.bash
+++ b/plugins/available/nvm.plugin.bash
@@ -16,62 +16,61 @@
export NVM_DIR=$(cd $(dirname ${BASH_SOURCE[0]:-$0}); pwd)
fi
-# Emulate curl with wget, if necessary
-if [ ! `which curl` ]; then
- if [ `which wget` ]; then
- curl() {
- ARGS="$* "
- ARGS=${ARGS/-s /-q }
- ARGS=${ARGS/-\# /}
- ARGS=${ARGS/-C - /-c }
- ARGS=${ARGS/-o /-O }
-
- wget $ARGS
- }
- else
- NOCURL='nocurl'
- curl() { echo 'Need curl or wget to proceed.' >&2; }
- fi
-fi
-
# Expand a version using the version cache
nvm_version()
{
PATTERN=$1
- VERSION=''
+ # 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
- VERSION="$PATTERN"
+ 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
- # The default version is the current one
- if [ ! "$PATTERN" -o "$PATTERN" = 'current' ]; then
- VERSION=`node -v 2>/dev/null`
- fi
- if [ "$PATTERN" = 'stable' ]; then
- PATTERN='*.*[02468].'
- fi
- if [ "$PATTERN" = 'latest' ]; then
- PATTERN='*.*.'
- fi
- if [ "$PATTERN" = 'all' ]; then
- (cd $NVM_DIR; \ls -dG v* 2>/dev/null || echo "N/A")
+ if [ ! "$VERSIONS" ]; then
+ echo "N/A"
return
fi
- if [ ! "$VERSION" ]; then
- VERSION=`(cd $NVM_DIR; \ls -d v${PATTERN}* 2>/dev/null) | sort -t. -k 2,1n -k 2,2n -k 3,3n | tail -n1`
- fi
- if [ ! "$VERSION" ]; then
- echo "N/A"
- return 13
- elif [ -e "$NVM_DIR/$VERSION" ]; then
- (cd $NVM_DIR; \ls -dG "$VERSION")
- else
- echo "$VERSION"
- 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()
@@ -90,30 +89,35 @@
echo " nvm install <version> Download and install a <version>"
echo " nvm uninstall <version> Uninstall a version"
echo " nvm use <version> Modify PATH to use <version>"
- echo " nvm ls List versions (installed versions are blue)"
+ echo " nvm run <version> [<args>] Run <version> with <args> as arguments"
+ echo " nvm ls List installed versions"
echo " nvm ls <version> List versions matching a given description"
echo " nvm deactivate Undo effects of NVM on current shell"
- echo " nvm sync Update the local cache of available versions"
echo " nvm alias [<pattern>] Show all aliases beginning with <pattern>"
echo " nvm alias <name> <version> Set an alias named <name> pointing to <version>"
echo " nvm unalias <name> Deletes the alias named <name>"
echo " nvm copy-packages <version> Install global NPM packages contained in <version> to current version"
echo
echo "Example:"
- echo " nvm install v0.4.0 Install a specific version number"
- echo " nvm use stable Use the stable release"
- echo " nvm install latest Install the latest, possibly unstable version"
+ 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 alias default v0.4.0 Set v0.4.0 as the default"
+ 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
- [ "$NOCURL" ] && curl && return
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"
@@ -124,7 +128,7 @@
[ ! -z $tarball ] && \
mkdir -p "$NVM_DIR/src" && \
cd "$NVM_DIR/src" && \
- curl -C - -# $tarball -o "node-$VERSION.tar.gz" && \
+ curl -C - --progress-bar $tarball -o "node-$VERSION.tar.gz" && \
tar -xzf "node-$VERSION.tar.gz" && \
cd "node-$VERSION" && \
./configure --prefix="$NVM_DIR/$VERSION" && \
@@ -136,8 +140,17 @@
nvm use $VERSION
if ! which npm ; then
echo "Installing npm..."
- # TODO: if node version 0.2.x add npm_install=0.2.19 before sh
- curl http://npmjs.org/install.sh | clean=yes sh
+ 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!"
@@ -156,10 +169,9 @@
fi
# Delete all files related to target version.
- (cd "$NVM_DIR" && \
- rm -rf "node-$VERSION" 2>/dev/null && \
- mkdir -p "$NVM_DIR/src" && \
+ (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"
@@ -170,8 +182,6 @@
nvm unalias `basename $A`
done
- # Run sync in order to restore version stub file in $NVM_DIR.
- nvm sync 1>/dev/null
;;
"deactivate" )
if [[ $PATH == *$NVM_DIR/*/bin* ]]; then
@@ -215,17 +225,27 @@
export NVM_BIN="$NVM_DIR/$VERSION/bin"
echo "Now using node $VERSION"
;;
- "ls" )
- if [ $# -ne 1 ]; then
- nvm_version $2
+ "run" )
+ # run given version of node
+ if [ $# -lt 2 ]; then
+ nvm help
return
fi
- nvm_version all
- for P in {stable,latest,current}; do
- echo -ne "$P: \t"; nvm_version $P
- done
- nvm alias
- echo "# use 'nvm sync' to update from nodejs.org"
+ 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
@@ -254,7 +274,6 @@
echo $3 > "$NVM_DIR/alias/$2"
if [ ! "$3" = "$VERSION" ]; then
echo "$2 -> $3 (-> $VERSION)"
- echo "! WARNING: Moving target. Aliases to implicit versions may change without warning."
else
echo "$2 -> $3"
fi
@@ -266,21 +285,6 @@
rm -f $NVM_DIR/alias/$2
echo "Deleted alias $2"
;;
- "sync" )
- [ "$NOCURL" ] && curl && return
- LATEST=`nvm_version latest`
- STABLE=`nvm_version stable`
- (cd $NVM_DIR
- rm -f v* 2>/dev/null
- printf "# syncing with nodejs.org..."
- for VER in `curl -s http://nodejs.org/dist/ -o - | grep 'v[0-9].*' | sed -e 's/.*node-//' -e 's/\.tar\.gz.*//' -e 's/<[^>]*>//' -e 's/\/<[^>]*>.*//'`; do
- touch $VER
- done
- echo " done."
- )
- [ "$STABLE" = `nvm_version stable` ] || echo "NEW stable: `nvm_version stable`"
- [ "$LATEST" = `nvm_version latest` ] || echo "NEW latest: `nvm_version latest`"
- ;;
"copy-packages" )
if [ $# -ne 2 ]; then
nvm help
@@ -296,7 +300,7 @@
echo "Cache cleared."
;;
"version" )
- nvm_version $2
+ print_versions "`nvm_version $2`"
;;
* )
nvm help
diff --git a/plugins/available/z_autoenv.plugins.bash b/plugins/available/z_autoenv.plugins.bash
new file mode 100644
index 0000000..04efa85
--- /dev/null
+++ b/plugins/available/z_autoenv.plugins.bash
@@ -0,0 +1,43 @@
+#!/usr/bin/env bash
+if [[ -n "${ZSH_VERSION}" ]]
+then __array_offset=0
+else __array_offset=1
+fi
+
+autoenv_init()
+{
+ typeset target home _file
+ typeset -a _files
+ target=$1
+ home="$(dirname $HOME)"
+
+ _files=( $(
+ while [[ "$PWD" != "/" && "$PWD" != "$home" ]]
+ do
+ _file="$PWD/.env"
+ if [[ -e "${_file}" ]]
+ then echo "${_file}"
+ fi
+ builtin cd ..
+ done
+ ) )
+
+ _file=${#_files[@]}
+ while (( _file > 0 ))
+ do
+ source "${_files[_file-__array_offset]}"
+ : $(( _file -= 1 ))
+ done
+}
+
+cd()
+{
+ if builtin cd "$@"
+ then
+ autoenv_init
+ return 0
+ else
+ echo "else?"
+ return $?
+ fi
+}
diff --git a/themes/colors.theme.bash b/themes/colors.theme.bash
index 0516e1c..a04c8e4 100644
--- a/themes/colors.theme.bash
+++ b/themes/colors.theme.bash
@@ -1,89 +1,270 @@
#!/bin/bash
-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[1;37m\]"
-orange="\[\e[33;40m\]"
+function __ {
+ echo "$@"
+}
+
+function __make_ansi {
+ next=$1 && shift
+ echo "\[\e[$(__$next $@)m\]"
+}
+
+function __make_echo {
+ next=$1 && shift
+ echo "\033[$(__$next $@)m"
+}
-bold_black="\[\e[1;30m\]"
-bold_red="\[\e[1;31m\]"
-bold_green="\[\e[1;32m\]"
-bold_yellow="\[\e[1;33m\]"
-bold_blue="\[\e[1;34m\]"
-bold_purple="\[\e[1;35m\]"
-bold_cyan="\[\e[1;36m\]"
-bold_white="\[\e[1;37m\]"
-bold_orange="\[\e[1;33;40m\]"
+function __reset {
+ next=$1 && shift
+ out="$(__$next $@)"
+ echo "0${out:+;${out}}"
+}
-underline_black="\[\e[4;30m\]"
-underline_red="\[\e[4;31m\]"
-underline_green="\[\e[4;32m\]"
-underline_yellow="\[\e[4;33m\]"
-underline_blue="\[\e[4;34m\]"
-underline_purple="\[\e[4;35m\]"
-underline_cyan="\[\e[4;36m\]"
-underline_white="\[\e[4;37m\]"
-underline_orange="\[\e[4;33;40m\]"
+function __bold {
+ next=$1 && shift
+ out="$(__$next $@)"
+ echo "${out:+${out};}1"
+}
-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[47m\]"
+function __faint {
+ next=$1 && shift
+ out="$(__$next $@)"
+ echo "${out:+${out};}2"
+}
+
+function __italic {
+ next=$1 && shift
+ out="$(__$next $@)"
+ echo "${out:+${out};}3"
+}
+
+function __underline {
+ next=$1 && shift
+ out="$(__$next $@)"
+ echo "${out:+${out};}4"
+}
+
+function __negative {
+ next=$1 && shift
+ out="$(__$next $@)"
+ echo "${out:+${out};}7"
+}
+
+function __crossed {
+ next=$1 && shift
+ out="$(__$next $@)"
+ echo "${out:+${out};}8"
+}
-normal="\[\e[00m\]"
-reset_color="\[\e[39m\]"
+function __color_normal_fg {
+ echo "3$1"
+}
+
+function __color_normal_bg {
+ echo "4$1"
+}
+
+function __color_bright_fg {
+ echo "9$1"
+}
+
+function __color_bright_bg {
+ echo "10$1"
+}
+
+
+function __color_black {
+ echo "0"
+}
+
+function __color_red {
+ echo "1"
+}
+
+function __color_green {
+ echo "2"
+}
+
+function __color_yellow {
+ echo "3"
+}
+
+function __color_blue {
+ echo "4"
+}
+
+function __color_magenta {
+ echo "5"
+}
+
+function __color_cyan {
+ echo "6"
+}
+
+function __color_white {
+ echo "7"
+}
+
+function __color_rgb {
+ r=$1 && g=$2 && b=$3
+ [[ r == g && g == b ]] && echo $(( $r / 11 + 232 )) && return # gray range above 232
+ echo "8;5;$(( ($r * 36 + $b * 6 + $g) / 51 + 16 ))"
+}
+
+function __color {
+ color=$1 && shift
+ case "$1" in
+ fg|bg) side="$1" && shift ;;
+ *) side=fg;;
+ esac
+ case "$1" in
+ normal|bright) mode="$1" && shift;;
+ *) mode=normal;;
+ esac
+ [[ $color == "rgb" ]] && rgb="$1 $2 $3" && shift 3
+
+ next=$1 && shift
+ out="$(__$next $@)"
+ echo "$(__color_${mode}_${side} $(__color_${color} $rgb))${out:+;${out}}"
+}
+
+
+function __black {
+ echo "$(__color black $@)"
+}
+
+function __red {
+ echo "$(__color red $@)"
+}
+
+function __green {
+ echo "$(__color green $@)"
+}
+
+function __yellow {
+ echo "$(__color yellow $@)"
+}
+
+function __blue {
+ echo "$(__color blue $@)"
+}
+
+function __magenta {
+ echo "$(__color magenta $@)"
+}
+
+function __cyan {
+ echo "$(__color cyan $@)"
+}
+
+function __white {
+ echo "$(__color white $@)"
+}
+
+function __rgb {
+ echo "$(__color rgb $@)"
+}
+
+
+function __color_parse {
+ next=$1 && shift
+ echo "$(__$next $@)"
+}
+
+function color {
+ echo "$(__color_parse make_ansi $@)"
+}
+
+function echo_color {
+ echo "$(__color_parse make_echo $@)"
+}
+
+
+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)"
+
+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)"
+
+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)"
+
+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)"
+
+normal="$(color reset)"
+reset_color="$(__make_ansi '' 39)"
# These colors are meant to be used with `echo -e`
-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[1;37m"
-echo_orange="\033[33;40m"
+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_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[1;30m"
-echo_bold_red="\033[1;31m"
-echo_bold_green="\033[1;32m"
-echo_bold_yellow="\033[1;33m"
-echo_bold_blue="\033[1;34m"
-echo_bold_purple="\033[1;35m"
-echo_bold_cyan="\033[1;36m"
-echo_bold_white="\033[1;37m"
-echo_bold_orange="\033[1;33;40m"
+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[4;30m"
-echo_underline_red="\033[4;31m"
-echo_underline_green="\033[4;32m"
-echo_underline_yellow="\033[4;33m"
-echo_underline_blue="\033[4;34m"
-echo_underline_purple="\033[4;35m"
-echo_underline_cyan="\033[4;36m"
-echo_underline_white="\033[4;37m"
-echo_underline_orange="\033[4;33;40m"
+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[47m"
-
-echo_normal="\033[00m"
-echo_reset_color="\033[39m"
+echo_normal="$(echo_color reset)"
+echo_reset_color="$(__make_echo '' 39)"
diff --git a/themes/doubletime_multiline/doubletime_multiline.theme.bash b/themes/doubletime_multiline/doubletime_multiline.theme.bash
new file mode 100644
index 0000000..b2215a8
--- /dev/null
+++ b/themes/doubletime_multiline/doubletime_multiline.theme.bash
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+source "$BASH_IT/themes/doubletime/doubletime.theme.bash"
+
+function prompt_setter() {
+ # Save history
+ history -a
+ history -c
+ history -r
+ if [[ -z "$THEME_PROMPT_CLOCK_FORMAT" ]]
+ then
+ clock="\t"
+ else
+ clock=$THEME_PROMPT_CLOCK_FORMAT
+ fi
+ PS1="
+$clock $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)$(ruby_version_prompt)
+\w
+$(doubletime_scm_prompt)$reset_color $ "
+ PS2='> '
+ PS4='+ '
+}
+
+PROMPT_COMMAND=prompt_setter