diff --git a/README.md b/README.md index 022ce442..13a991da 100644 --- a/README.md +++ b/README.md @@ -59,10 +59,10 @@ When you run without the `--no-modify-config` switch, the Bash-it installer auto Use the `--no-modify-config` switch to avoid unwanted modifications, e.g. if your Bash config file already contains the code that loads Bash-it. **NOTE**: Keep in mind how Bash load its configuration files, -`.bash_profile` for login shells (and in macOS in terminal emulators like [Terminal.app](http://www.apple.com/osx/apps/) or +`.bash_profile` for login shells (and in macOS in terminal emulators like [Terminal.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. +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`: ``` @@ -76,8 +76,8 @@ Refer to the official [Bash documentation](https://www.gnu.org/software/bash/man ### Install using Docker -You can try Bash-it in an isolated environment without changing any local files via a [Docker](https://www.docker.com/) Container. -(Bash Shell v4.4 with Bash-it, [bats](https://github.com/sstephenson/bats) and bash-completion based on [Alpine Linux](https://alpinelinux.org/)). +You can try Bash-it in an isolated environment without changing any local files via a [Docker](https://www.docker.com/) Container. +(Bash Shell v4.4 with Bash-it, [bats](https://github.com/sstephenson/bats) and bash-completion based on [Alpine Linux](https://alpinelinux.org/)). `docker pull ellerbrock/bash-it` @@ -140,7 +140,7 @@ Currently enabled modules will be shown in green. ### Searching with Negations -You can prefix a search term with a "-" to exclude it from the results. +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: @@ -189,6 +189,7 @@ There are over 50+ Bash-it themes to pick from in `$BASH_IT/themes`. The default theme is `bobby`. Set `BASH_IT_THEME` to the theme name you want, or if you've developed your own custom theme outside of `$BASH_IT/themes`, point the `BASH_IT_THEME` variable directly to the theme file. +To disable theming completely, leave the variable empty. Examples: @@ -198,6 +199,9 @@ export BASH_IT_THEME="powerline-multiline" # Use a theme outside of the Bash-it folder export BASH_IT_THEME="/home/foo/my_theme/my_theme.theme.bash" + +# Disable theming +export BASH_IT_THEME="" ``` You can easily preview the themes in your own shell using `BASH_PREVIEW=true bash-it reload`. @@ -294,8 +298,8 @@ Set `SCM_GIT_SHOW_REMOTE_INFO` to 'false' to **disable the feature**: ### Untracked files -By default, the `git status` command shows information about *untracked* files. -This behavior can be controlled through command-line flags or git configuration files. +By default, the `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, it can be useful to instruct Bash-it to ignore these files. You can control this behavior with the flag `SCM_GIT_IGNORE_UNTRACKED`: @@ -312,6 +316,19 @@ 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. +### Stash item count + +When `SCM_GIT_SHOW_DETAILS` is enabled, you can get the count of *stashed* items. This feature can be useful when a user has a lot of stash items. +This feature is controlled through the flag `SCM_GIT_SHOW_STASH_INFO` as follows: + +Set `SCM_GIT_SHOW_STASH_INFO` to 'true' (the default value) to **show** the count of stashed items: + +* `export SCM_GIT_SHOW_STASH_INFO=true` + +Set `SCM_GIT_SHOW_STASH_INFO` to 'false' to **don't show** it: + +* `export SCM_GIT_SHOW_STASH_INFO=false` + ### Git user In some environments, it is useful to know the value of the current git user, which is used to mark all new commits. @@ -333,7 +350,7 @@ You can control the prefix and the suffix of this component using the two variab And -* `export SCM_THEME_CURRENT_USER_SUFFIX=' ☺︎ '` +* `export SCM_THEME_CURRENT_USER_SUFFIX=' ☺︎ '` **NOTE:** If using `SCM_GIT_SHOW_MINIMAL_INFO=true`, then the value of `SCM_GIT_SHOW_CURRENT_USER` is ignored. diff --git a/aliases/available/bolt.aliases.bash b/aliases/available/bolt.aliases.bash new file mode 100644 index 00000000..8490f710 --- /dev/null +++ b/aliases/available/bolt.aliases.bash @@ -0,0 +1,8 @@ +cite 'about-alias' +about-alias 'puppet bolt aliases' + +# Aliases +alias bolt='bolt command run --tty --no-host-key-check' +alias boltas='bolt -p -u' +alias sudobolt='bolt --run-as root --sudo-password' +alias sudoboltas='sudobolt -p -u' diff --git a/aliases/available/docker-compose.aliases.bash b/aliases/available/docker-compose.aliases.bash index 01eb62fb..f23c2689 100644 --- a/aliases/available/docker-compose.aliases.bash +++ b/aliases/available/docker-compose.aliases.bash @@ -4,3 +4,4 @@ about-alias 'docker-compose abbreviations' alias dco="docker-compose" alias dcofresh="docker-compose-fresh" alias dcol="docker-compose logs -f --tail 100" +alias dcou="docker-compose up" diff --git a/aliases/available/docker.aliases.bash b/aliases/available/docker.aliases.bash index e3601d6f..011135c6 100644 --- a/aliases/available/docker.aliases.bash +++ b/aliases/available/docker.aliases.bash @@ -25,3 +25,9 @@ alias dkrmi='docker-remove-images' # Delete images for supplied IDs or all if n alias dkideps='docker-image-dependencies' # Output a graph of image dependencies using Graphiz alias dkre='docker-runtime-environment' # List environmental variables of the supplied image ID alias dkelc='docker exec -it `dklcid` bash' # Enter last container (works with Docker 1.3 and above) +alias dkex='docker exec -it ' # Useful to run any commands into container without leaving host + +# Added more recent cleanup options from newer docker versions +alias dkip='docker image prune -a -f' +alias dkvp='docker volume prune -f' +alias dksp='docker system prune -a -f' diff --git a/aliases/available/homebrew-cask.aliases.bash b/aliases/available/homebrew-cask.aliases.bash index 090622b0..57d8161c 100644 --- a/aliases/available/homebrew-cask.aliases.bash +++ b/aliases/available/homebrew-cask.aliases.bash @@ -7,7 +7,6 @@ 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' diff --git a/aliases/available/kubectl.aliases.bash b/aliases/available/kubectl.aliases.bash new file mode 100644 index 00000000..58670ce5 --- /dev/null +++ b/aliases/available/kubectl.aliases.bash @@ -0,0 +1,24 @@ +#!/bin/bash +# +# -binaryanomaly + +cite 'about-alias' +about-alias 'kubectl aliases' + +# set apt aliases +function _set_pkg_aliases() +{ + if [ -x $(which kubectl) ]; then + alias kc='kubectl' + alias kcgp='kubectl get pods' + alias kcgd='kubectl get deployments' + alias kcgn='kubectl get nodes' + alias kcdp='kubectl describe pod' + alias kcdd='kubectl describe deployment' + alias kcdn='kubectl describe node' + alias kcgpan='kubectl get pods --all-namespaces' + alias kcgdan='kubectl get deployments --all-namespaces' + fi +} + +_set_pkg_aliases diff --git a/aliases/available/maven.aliases.bash b/aliases/available/maven.aliases.bash index 4cd89d27..f8a44a1c 100644 --- a/aliases/available/maven.aliases.bash +++ b/aliases/available/maven.aliases.bash @@ -3,9 +3,12 @@ about-alias 'maven abbreviations' alias mci='mvn clean install' alias mi='mvn install' +alias mcp='mvn clean package' +alias mp='mvn package' 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' +alias mcpsk='mcp -Dmaven.test.skip=true' diff --git a/aliases/available/puppet.aliases.bash b/aliases/available/puppet.aliases.bash new file mode 100644 index 00000000..bb5b4a1a --- /dev/null +++ b/aliases/available/puppet.aliases.bash @@ -0,0 +1,10 @@ +cite 'about-alias' +about-alias 'puppet aliases' + +# Aliases +alias pupval="puppet parser validate *.pp" +alias puplint="puppet-lint *.pp" +alias pupagt="puppet agent -t" +alias pupagtd="puppet agent -t --debug" +alias pupapp="puppet apply" + diff --git a/bash_it.sh b/bash_it.sh index 8eea4c6a..e2b00de7 100755 --- a/bash_it.sh +++ b/bash_it.sh @@ -46,19 +46,22 @@ do _load_bash_it_files $file_type done -# Load colors and helpers first so they can be used in base theme -# shellcheck source=./themes/colors.theme.bash -source "${BASH_IT}/themes/colors.theme.bash" -# shellcheck source=./themes/githelpers.theme.bash -source "${BASH_IT}/themes/githelpers.theme.bash" -# shellcheck source=./themes/p4helpers.theme.bash -source "${BASH_IT}/themes/p4helpers.theme.bash" -# shellcheck source=./themes/base.theme.bash -source "${BASH_IT}/themes/base.theme.bash" +# Load theme, if a theme was set +if [[ ! -z "${BASH_IT_THEME}" ]]; then + # Load colors and helpers first so they can be used in base theme + # shellcheck source=./themes/colors.theme.bash + source "${BASH_IT}/themes/colors.theme.bash" + # shellcheck source=./themes/githelpers.theme.bash + source "${BASH_IT}/themes/githelpers.theme.bash" + # shellcheck source=./themes/p4helpers.theme.bash + source "${BASH_IT}/themes/p4helpers.theme.bash" + # shellcheck source=./themes/base.theme.bash + source "${BASH_IT}/themes/base.theme.bash" -# appearance (themes) now, after all dependencies -# shellcheck source=./lib/appearance.bash -source "$APPEARANCE_LIB" + # appearance (themes) now, after all dependencies + # shellcheck source=./lib/appearance.bash + source "$APPEARANCE_LIB" +fi # Load custom aliases, completion, plugins for file_type in "aliases" "completion" "plugins" diff --git a/completion/available/bundler.completion.bash b/completion/available/bundler.completion.bash index 274a4a36..cdb7cf54 100644 --- a/completion/available/bundler.completion.bash +++ b/completion/available/bundler.completion.bash @@ -21,6 +21,9 @@ __bundle() { if [[ -z $bundle_command ]]; then options="$options --version --help" fi + elif [[ $bundle_command = "exec" ]]; then + _bundle_exec_completions + return else if [[ -z $bundle_command || $bundle_command = help ]]; then options="help install update package exec config check list show @@ -53,3 +56,10 @@ __bundle_get_command() { complete -F __bundle -o bashdefault -o default bundle # vim: ai ft=sh sw=4 sts=2 et + +_bundle_exec_completions() +{ + if [[ $COMP_CWORD = 2 ]]; then + COMPREPLY=($(compgen -c -- "$2")) + fi +} diff --git a/completion/available/fabric-completion.bash b/completion/available/fabric.completion.bash similarity index 100% rename from completion/available/fabric-completion.bash rename to completion/available/fabric.completion.bash diff --git a/completion/available/lerna.completion.bash b/completion/available/lerna.completion.bash new file mode 100644 index 00000000..792ea27b --- /dev/null +++ b/completion/available/lerna.completion.bash @@ -0,0 +1,19 @@ +#!/bin/bash +# Lerna autocompletion. +function _lerna_completions() { + local cur compls + + # The currently-being-completed word. + cur="${COMP_WORDS[COMP_CWORD]}" + + # Options + compls="add bootstrap changed clean create diff exec \ + import init link list publish run version \ + --loglevel --concurrency --reject-cycles \ + --progress --sort --no-sort --help \ + --version" + + # Tell complete what stuff to show. + COMPREPLY=($(compgen -W "$compls" -- "$cur")) +} +complete -o default -F _lerna_completions lerna diff --git a/completion/available/minikube.completion.bash b/completion/available/minikube.completion.bash new file mode 100644 index 00000000..f1d19b87 --- /dev/null +++ b/completion/available/minikube.completion.bash @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# minikube (Local Kubernetes) completion + +if command -v minikube &>/dev/null +then + eval "$(minikube completion bash)" +fi diff --git a/completion/available/sdkman.completion.bash b/completion/available/sdkman.completion.bash index f5af6c6a..b4d62da1 100644 --- a/completion/available/sdkman.completion.bash +++ b/completion/available/sdkman.completion.bash @@ -27,10 +27,14 @@ _sdkman_complete() esac elif [ $COMP_CWORD -eq 3 ]; then case "${COMP_WORDS[COMP_CWORD-2]}" in - "install" | "uninstall" | "rm" | "use" | "default" ) + "uninstall" | "rm" | "use" | "default" ) _sdkman_candidate_versions ${COMP_WORDS[COMP_CWORD-1]} COMPREPLY=( $(compgen -W "$CANDIDATE_VERSIONS" -- ${COMP_WORDS[COMP_CWORD]}) ) ;; + "install") + _sdkman_candidate_not_installed_versions ${COMP_WORDS[COMP_CWORD-1]} + COMPREPLY=( $(compgen -W "$CANDIDATE_VERSIONS" -- ${COMP_WORDS[COMP_CWORD]}) ) + ;; *) ;; esac @@ -51,6 +55,14 @@ _sdkman_candidate_versions(){ } +_sdkman_candidate_not_installed_versions(){ + CANDIDATE_LOCAL_VERSIONS=$(__sdkman_cleanup_local_versions $1) + if [ "$SDKMAN_OFFLINE_MODE" = "false" ]; then + CANDIDATE_ONLINE_VERSIONS="$(__sdkman_list_versions $1 | grep " " | grep "\." | cut -c 6-)" + CANDIDATE_VERSIONS="$(echo $CANDIDATE_ONLINE_VERSIONS $CANDIDATE_LOCAL_VERSIONS | tr ' ' '\n' | sort | uniq -u) " + fi +} + __sdkman_cleanup_local_versions(){ __sdkman_build_version_csv $1 | tr ',' ' ' diff --git a/completion/available/ssh.completion.bash b/completion/available/ssh.completion.bash index b54202bd..d5cd6e61 100644 --- a/completion/available/ssh.completion.bash +++ b/completion/available/ssh.completion.bash @@ -11,11 +11,16 @@ _sshcomplete() { local OPTIONS=" -- ${CURRENT_PROMPT}" fi - - # parse all defined hosts from .ssh/config - if [ -r "$HOME/.ssh/config" ]; then - COMPREPLY=($(compgen -W "$(grep -i ^Host "$HOME/.ssh/config" | awk '{for (i=2; i<=NF; i++) print $i}' )" ${OPTIONS}) ) - fi + # parse all defined hosts from .ssh/config and files included there + for fl in "$HOME/.ssh/config" \ + $(grep "^\s*Include" "$HOME/.ssh/config" | + awk '{for (i=2; i<=NF; i++) print $i}' | + sed "s|^~/|$HOME/|") + do + if [ -r "$fl" ]; then + COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$(grep -i ^Host "$fl" |grep -v '[*!]' | awk '{for (i=2; i<=NF; i++) print $i}' )" ${OPTIONS}) ) + fi + done # parse all hosts found in .ssh/known_hosts if [ -r "$HOME/.ssh/known_hosts" ]; then diff --git a/completion/available/system.completion.bash b/completion/available/system.completion.bash index b044627c..f9a3b29f 100644 --- a/completion/available/system.completion.bash +++ b/completion/available/system.completion.bash @@ -20,8 +20,8 @@ if [ $(uname) = "Darwin" ] && command -v brew &>/dev/null ; then . "$BREW_PREFIX"/etc/bash_completion fi - # homebrew/versions/bash-completion2 (required for projects.completion.bash) is installed to this path - if [ -f "$BREW_PREFIX"/share/bash-completion/bash_completion ]; then + # homebrew/versions/bash-completion2 (required for projects.completion.bash) is installed to this path + if [ "${BASH_VERSINFO}" -ge 4 ] && [ -f "$BREW_PREFIX"/share/bash-completion/bash_completion ]; then . "$BREW_PREFIX"/share/bash-completion/bash_completion fi fi diff --git a/lib/helpers.bash b/lib/helpers.bash index e8fc19ba..a2c0d3aa 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -61,7 +61,7 @@ function reload_plugins() { bash-it () { about 'Bash-it help and maintenance' - param '1: verb [one of: help | show | enable | disable | migrate | update | search | version | reload ] ' + param '1: verb [one of: help | show | enable | disable | migrate | update | search | version | reload ] ' 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' @@ -79,28 +79,28 @@ bash-it () shift typeset func case $verb in - show) - func=_bash-it-$component;; - enable) - func=_enable-$component;; - disable) - func=_disable-$component;; - help) - func=_help-$component;; - search) - _bash-it-search $component "$@" - return;; - update) - func=_bash-it_update;; - migrate) - func=_bash-it-migrate;; - version) - func=_bash-it-version;; - reload) - func=_bash-it-reload;; - *) - reference bash-it - return;; + show) + func=_bash-it-$component;; + enable) + func=_enable-$component;; + disable) + func=_disable-$component;; + help) + func=_help-$component;; + search) + _bash-it-search $component "$@" + return;; + update) + func=_bash-it_update;; + migrate) + func=_bash-it-migrate;; + version) + func=_bash-it-version;; + reload) + func=_bash-it-reload;; + *) + reference bash-it + return;; esac # pluralize component if necessary @@ -187,7 +187,7 @@ _bash-it_update() { _bash-it-migrate echo "" echo "All done, enjoy!" - reload + bash-it reload else echo "Error updating Bash-it, please, check if your Bash-it installation folder (${BASH_IT}) is clean." fi @@ -270,7 +270,7 @@ _bash-it-reload() { source ~/.bashrc ;; esac - + cd - &> /dev/null || return } diff --git a/plugins/available/aws.plugin.bash b/plugins/available/aws.plugin.bash index 1519f77b..66021267 100644 --- a/plugins/available/aws.plugin.bash +++ b/plugins/available/aws.plugin.bash @@ -1,11 +1,14 @@ cite about-plugin about-plugin 'AWS helper functions' +AWS_CONFIG_FILE="${AWS_CONFIG_FILE:-$HOME/.aws/config}" +AWS_SHARED_CREDENTIALS_FILE="${AWS_SHARED_CREDENTIALS_FILE:-$HOME/.aws/credentials}" + function awskeys { about 'helper function for AWS credentials file' group 'aws' - if [[ ! -f ~/.aws/credentials ]]; then + if [[ ! -f "${AWS_SHARED_CREDENTIALS_FILE}" ]]; then echo "AWS credentials file not found" return 1 fi @@ -35,14 +38,14 @@ function __awskeys_help { } function __awskeys_get { - local ln=$(grep -n "\[ *$1 *\]" ~/.aws/credentials | cut -d ":" -f 1) + local ln=$(grep -n "\[ *$1 *\]" "${AWS_SHARED_CREDENTIALS_FILE}" | cut -d ":" -f 1) if [[ -n "${ln}" ]]; then - tail -n +${ln} ~/.aws/credentials | egrep -m 2 "aws_access_key_id|aws_secret_access_key" + tail -n +${ln} "${AWS_SHARED_CREDENTIALS_FILE}" | egrep -m 3 "aws_access_key_id|aws_secret_access_key|aws_session_token" fi } function __awskeys_list { - local credentials_list="$((egrep '^\[ *[a-zA-Z0-9_-]+ *\]$' ~/.aws/credentials; grep "\[profile" ~/.aws/config | sed "s|\[profile |\[|g") | sort | uniq)" + local credentials_list="$((egrep '^\[ *[a-zA-Z0-9_-]+ *\]$' "${AWS_SHARED_CREDENTIALS_FILE}"; grep "\[profile" "${AWS_CONFIG_FILE}" | sed "s|\[profile |\[|g") | sort | uniq)" if [[ -n $"{credentials_list}" ]]; then echo -e "Available credentials profiles:\n" for profile in ${credentials_list}; do @@ -72,14 +75,14 @@ function __awskeys_export { export "$(echo ${key} | tr [:lower:] [:upper:])=${p_key#*=}" done fi - export AWS_DEFAULT_PROFILE="$1" + export AWS_PROFILE="$1" else echo "Profile $1 not found in credentials file" fi } function __awskeys_unset { - unset AWS_DEFAULT_PROFILE AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY + unset AWS_PROFILE AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN } function __awskeys_comp { diff --git a/plugins/available/fzf.plugin.bash b/plugins/available/fzf.plugin.bash index 69775c75..f2eddeb1 100644 --- a/plugins/available/fzf.plugin.bash +++ b/plugins/available/fzf.plugin.bash @@ -6,6 +6,10 @@ about-plugin 'load fzf, if you are using it' [ -f ~/.fzf.bash ] && source ~/.fzf.bash +if [ -z ${FZF_DEFAULT_COMMAND+x} ]; then + command -v fd &> /dev/null && export FZF_DEFAULT_COMMAND='fd --type f' +fi + fe() { about "Open the selected file in the default editor" group "fzf" diff --git a/plugins/available/go.plugin.bash b/plugins/available/go.plugin.bash old mode 100644 new mode 100755 index c9fcdff8..827ac388 --- a/plugins/available/go.plugin.bash +++ b/plugins/available/go.plugin.bash @@ -5,7 +5,7 @@ about-plugin 'go environment variables & path configuration' [ ! command -v go &>/dev/null ] && return -export GOROOT=${GOROOT:-$(go env | grep GOROOT | cut -d'"' -f2)} +export GOROOT=${GOROOT:-$(go env GOROOT)} pathmunge "${GOROOT}/bin" -export GOPATH=${GOPATH:-"$HOME/go"} +export GOPATH=${GOPATH:-$(go env GOPATH)} pathmunge "${GOPATH}/bin" diff --git a/plugins/available/jump.plugin.bash b/plugins/available/jump.plugin.bash new file mode 100755 index 00000000..bc6f85e1 --- /dev/null +++ b/plugins/available/jump.plugin.bash @@ -0,0 +1,9 @@ +cite about-plugin +about-plugin 'initialize jump (see https://github.com/gsamokovarov/jump)' + +__init_jump() { + command -v jump &> /dev/null || return + eval "$(jump shell --bind=z)" +} + +__init_jump diff --git a/plugins/available/osx.plugin.bash b/plugins/available/osx.plugin.bash index 2dba0279..0e74ab8d 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 - PROMPT_COMMAND="$PROMPT_COMMAND;update_terminal_cwd" + PROMPT_COMMAND="${PROMPT_COMMAND%;};update_terminal_cwd" declared="$(declare -p PROMPT_COMMAND)" [[ "$declared" =~ \ -[aAilrtu]*x[aAilrtu]*\ ]] 2>/dev/null [[ $? -eq 0 ]] && export PROMPT_COMMAND diff --git a/plugins/available/postgres.plugin.bash b/plugins/available/postgres.plugin.bash index b90d8d76..e481d734 100644 --- a/plugins/available/postgres.plugin.bash +++ b/plugins/available/postgres.plugin.bash @@ -20,23 +20,23 @@ done function postgres_start { - about 'Starts PostgresSQL server' + about 'Starts PostgreSQL server' group 'postgres' - echo 'Starting PostgresSQL Server....'; + echo 'Starting Postgres....'; $POSTGRES_BIN/pg_ctl -D $PGDATA -l $PGDATA/logfile start } function postgres_stop { - about 'Steps PostgresSQL server' + about 'Stops PostgreSQL server' group 'postgres' - echo 'Stopping PostgresSQL Server....'; + echo 'Stopping Postgres....'; $POSTGRES_BIN/pg_ctl -D $PGDATA -l $PGDATA/logfile stop -s -m fast } function postgres_status { - about 'Returns status of PostgresSQL server' + about 'Returns status of PostgreSQL server' group 'postgres' # $POSTGRES_BIN/pg_ctl -D $PGDATA status @@ -55,7 +55,7 @@ function is_postgres_running { function postgres_restart { - about 'Restarts status of PostgresSQL server' + about 'Restarts status of PostgreSQL server' group 'postgres' echo 'Restarting Postgres....'; diff --git a/plugins/available/powerline.plugin.bash b/plugins/available/powerline.plugin.bash new file mode 100644 index 00000000..0388aa37 --- /dev/null +++ b/plugins/available/powerline.plugin.bash @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +cite about-plugin +about-plugin 'enables powerline daemon' + +command -v powerline-daemon &>/dev/null || return +powerline-daemon -q + +#the following should not be executed if bashit powerline themes in use +case "$BASH_IT_THEME" in + *powerline*) + return + ;; +esac +POWERLINE_BASH_CONTINUATION=1 +POWERLINE_BASH_SELECT=1 +bashPowerlineInit=$(python -c \ + "import os; \ + import powerline;\ + print(os.path.join(os.path.dirname(\ + powerline.__file__),\ + 'bindings', \ + 'bash', \ + 'powerline.sh'))") +[ -e $bashPowerlineInit ] || return +. $bashPowerlineInit diff --git a/plugins/available/rbenv.plugin.bash b/plugins/available/rbenv.plugin.bash index b1388017..75d24154 100644 --- a/plugins/available/rbenv.plugin.bash +++ b/plugins/available/rbenv.plugin.bash @@ -1,9 +1,10 @@ -# Load rbebv, if you are using it - cite about-plugin about-plugin 'load rbenv, if you are using it' -pathmunge "$HOME"/.rbenv/bin -[ -x `which rbenv` ] && eval "$(rbenv init -)" +export RBENV_ROOT="$HOME/.rbenv" +pathmunge "$RBENV_ROOT/bin" -[ -d "$HOME"/.rbenv/plugins/ruby-build ] && pathmunge "$HOME"/.rbenv/plugins/ruby-build/bin +[[ `which rbenv` ]] && eval "$(rbenv init -)" + +# Load the auto-completion script if rbenv was loaded. +[[ -e $RBENV_ROOT/completions/rbenv.bash ]] && source $RBENV_ROOT/completions/rbenv.bash diff --git a/template/bash_profile.template.bash b/template/bash_profile.template.bash index 01097960..5e877900 100755 --- a/template/bash_profile.template.bash +++ b/template/bash_profile.template.bash @@ -3,7 +3,8 @@ # Path to the bash it configuration export BASH_IT="{{BASH_IT}}" -# Lock and Load a custom theme file +# Lock and Load a custom theme file. +# Leave empty to disable theming. # location /.bash_it/themes/ export BASH_IT_THEME='bobby' diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 12df1d8a..51d5f359 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -32,6 +32,7 @@ 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_SHOW_MINIMAL_INFO=${SCM_GIT_SHOW_MINIMAL_INFO:=false} +SCM_GIT_SHOW_STASH_INFO=${SCM_GIT_SHOW_STASH_INFO:=true} SCM_GIT='git' SCM_GIT_CHAR='±' @@ -181,9 +182,11 @@ function git_prompt_vars { [[ "${commits_ahead}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_AHEAD_CHAR}${commits_ahead}" [[ "${commits_behind}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_BEHIND_CHAR}${commits_behind}" - local stash_count - stash_count="$(git stash list 2> /dev/null | wc -l | tr -d ' ')" - [[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_STASH_CHAR_PREFIX}${stash_count}${SCM_GIT_STASH_CHAR_SUFFIX}" + if [[ "${SCM_GIT_SHOW_STASH_INFO}" = "true" ]]; then + local stash_count + stash_count="$(git stash list 2> /dev/null | wc -l | tr -d ' ')" + [[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_STASH_CHAR_PREFIX}${stash_count}${SCM_GIT_STASH_CHAR_SUFFIX}" + fi SCM_STATE=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} if ! _git-hide-status; then @@ -347,7 +350,7 @@ function condaenv_prompt { } function py_interp_prompt { - py_version=$(python --version 2>&1 | awk '{print "py-"$2;}') || return + py_version=$(python --version 2>&1 | awk 'NR==1{print "py-"$2;}') || return echo -e "${PYTHON_THEME_PROMPT_PREFIX}${py_version}${PYTHON_THEME_PROMPT_SUFFIX}" } @@ -393,6 +396,7 @@ function user_host_prompt { # backwards-compatibility function git_prompt_info { + _git-hide-status && return git_prompt_vars echo -e "${SCM_PREFIX}${SCM_BRANCH}${SCM_STATE}${SCM_SUFFIX}" } diff --git a/themes/demula/demula.theme.bash b/themes/demula/demula.theme.bash index 515d096d..e85c18f7 100644 --- a/themes/demula/demula.theme.bash +++ b/themes/demula/demula.theme.bash @@ -100,8 +100,7 @@ prompt() { if [ $(uname) = "Linux" ]; then - PS1="${TITLEBAR} -${SAVE_CURSOR}${MOVE_CURSOR_RIGHTMOST}${MOVE_CURSOR_5_LEFT}\ + PS1="${TITLEBAR}${SAVE_CURSOR}${MOVE_CURSOR_RIGHTMOST}${MOVE_CURSOR_5_LEFT} $(safe_battery_charge)${RESTORE_CURSOR}\ ${D_USER_COLOR}\u ${D_INTERMEDIATE_COLOR}\ at ${D_MACHINE_COLOR}\h ${D_INTERMEDIATE_COLOR}\ @@ -113,7 +112,7 @@ ${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}" else PS1="${TITLEBAR} ${D_USER_COLOR}\u ${D_INTERMEDIATE_COLOR}\ -at ${D_MACHINE_COLOR}\h ${D_INTERMEDIATE_COLOR}\ +at ${D_MACHINE_COLOR}\h ${D_INTERMEDIATE_COLOR}\ in ${D_DIR_COLOR}\w ${D_INTERMEDIATE_COLOR}\ ${LAST_COMMAND_FAILED}\ $(demula_vcprompt)\ diff --git a/themes/elixr/elixr.theme.bash b/themes/elixr/elixr.theme.bash index 0e37f94c..266abbad 100644 --- a/themes/elixr/elixr.theme.bash +++ b/themes/elixr/elixr.theme.bash @@ -17,7 +17,7 @@ RVM_THEME_PROMPT_SUFFIX=" d|" BOLD="\[\e[1m\]" function prompt_command() { - PS1="\n${bold_cyan}$(scm_prompt_char_info) ${bold_cyan}\w :${reset_color}${normal}${BOLD} " + PS1="\n${bold_cyan}$(scm_prompt_char_info)$(virtualenv_prompt) ${bold_cyan}\w :${reset_color}${normal}${BOLD} " } safe_append_prompt_command prompt_command diff --git a/themes/powerline-multiline/README.md b/themes/powerline-multiline/README.md index acc199ac..ee6095dd 100644 --- a/themes/powerline-multiline/README.md +++ b/themes/powerline-multiline/README.md @@ -46,6 +46,7 @@ The time/date is printed by the `date` command, so refer to its man page to chan 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: +* `aws_profile` - Show the current value of the `AWS_PROFILE` environment variable * `battery` - Battery information (you'll need to enable the `battery` plugin) * `clock` - Current time in `HH:MM:SS` format * `cwd` - Current working directory including full folder hierarchy (c.f. `wd`) diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index a62a7060..ad64fb18 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -20,6 +20,7 @@ PYTHON_VENV_THEME_PROMPT_COLOR=35 SCM_NONE_CHAR="" SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "} +SCM_HG_CHAR=${POWERLINE_SCM_HG_CHAR:="☿ "} SCM_THEME_PROMPT_CLEAN="" SCM_THEME_PROMPT_DIRTY="" SCM_THEME_PROMPT_CLEAN_COLOR=25 @@ -35,6 +36,9 @@ RBENV_THEME_PROMPT_SUFFIX="" RUBY_THEME_PROMPT_COLOR=161 RUBY_CHAR=${POWERLINE_RUBY_CHAR:="❲r❳ "} +AWS_PROFILE_CHAR="${POWERLINE_AWS_PROFILE_CHAR:=❲aws❳ }" +AWS_PROFILE_PROMPT_COLOR=208 + CWD_THEME_PROMPT_COLOR=240 LAST_STATUS_THEME_PROMPT_COLOR=196 diff --git a/themes/powerline-naked/README.md b/themes/powerline-naked/README.md index 510e0301..62238bd5 100644 --- a/themes/powerline-naked/README.md +++ b/themes/powerline-naked/README.md @@ -42,6 +42,7 @@ The time/date is printed by the `date` command, so refer to its man page to chan The contents of the prompt can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are: +* `aws_profile` - Show the current value of the `AWS_PROFILE` environment variable * `battery` - Battery information (you'll need to enable the `battery` plugin) * `clock` - Current time in `HH:MM:SS` format * `cwd` - Current working directory including full folder hierarchy (c.f. `wd`) diff --git a/themes/powerline-naked/powerline-naked.theme.bash b/themes/powerline-naked/powerline-naked.theme.bash index 1897a6ba..4e06273c 100644 --- a/themes/powerline-naked/powerline-naked.theme.bash +++ b/themes/powerline-naked/powerline-naked.theme.bash @@ -16,6 +16,7 @@ PYTHON_VENV_THEME_PROMPT_COLOR=35 SCM_NONE_CHAR="" SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "} +SCM_HG_CHAR=${POWERLINE_SCM_HG_CHAR:="☿ "} SCM_THEME_PROMPT_CLEAN="" SCM_THEME_PROMPT_DIRTY="" SCM_THEME_PROMPT_COLOR=238 @@ -32,6 +33,9 @@ RBENV_THEME_PROMPT_SUFFIX="" RUBY_THEME_PROMPT_COLOR=161 RUBY_CHAR=${POWERLINE_RUBY_CHAR:="❲r❳ "} +AWS_PROFILE_CHAR="${POWERLINE_AWS_PROFILE_CHAR:=❲aws❳ }" +AWS_PROFILE_PROMPT_COLOR=208 + CWD_THEME_PROMPT_COLOR=254 LAST_STATUS_THEME_PROMPT_COLOR=124 diff --git a/themes/powerline-plain/README.md b/themes/powerline-plain/README.md index 8c8647e3..ef773cd8 100644 --- a/themes/powerline-plain/README.md +++ b/themes/powerline-plain/README.md @@ -40,6 +40,7 @@ The time/date is printed by the `date` command, so refer to its man page to chan The contents of the prompt can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are: +* `aws_profile` - Show the current value of the `AWS_PROFILE` environment variable * `battery` - Battery information (you'll need to enable the `battery` plugin) * `clock` - Current time in `HH:MM:SS` format * `cwd` - Current working directory including full folder hierarchy (c.f. `wd`) diff --git a/themes/powerline-plain/powerline-plain.theme.bash b/themes/powerline-plain/powerline-plain.theme.bash index ce7943c7..0757dc9e 100644 --- a/themes/powerline-plain/powerline-plain.theme.bash +++ b/themes/powerline-plain/powerline-plain.theme.bash @@ -12,6 +12,7 @@ PYTHON_VENV_THEME_PROMPT_COLOR=35 SCM_NONE_CHAR="" SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:="⎇ "} +SCM_HG_CHAR=${POWERLINE_SCM_HG_CHAR:="☿ "} SCM_THEME_PROMPT_CLEAN="" SCM_THEME_PROMPT_DIRTY="" SCM_THEME_PROMPT_CLEAN_COLOR=25 @@ -25,7 +26,10 @@ RVM_THEME_PROMPT_SUFFIX="" RBENV_THEME_PROMPT_PREFIX="" RBENV_THEME_PROMPT_SUFFIX="" RUBY_THEME_PROMPT_COLOR=161 -RUBY_CHAR=${POWERLINE_RUBY_CHAR:="ⓔ "} +RUBY_CHAR=${POWERLINE_RUBY_CHAR:="💎 "} + +AWS_PROFILE_CHAR="${POWERLINE_AWS_PROFILE_CHAR:=❲aws❳ }" +AWS_PROFILE_PROMPT_COLOR=208 CWD_THEME_PROMPT_COLOR=240 diff --git a/themes/powerline/README.md b/themes/powerline/README.md index 7c1a135c..d3f7fbca 100644 --- a/themes/powerline/README.md +++ b/themes/powerline/README.md @@ -44,6 +44,7 @@ The time/date is printed by the `date` command, so refer to its man page to chan The contents of the prompt can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are: +* `aws_profile` - Show the current value of the `AWS_PROFILE` environment variable * `battery` - Battery information (you'll need to enable the `battery` plugin) * `clock` - Current time in `HH:MM:SS` format * `cwd` - Current working directory including full folder hierarchy (c.f. `wd`) diff --git a/themes/powerline/powerline.base.bash b/themes/powerline/powerline.base.bash index ade246e9..7dded057 100644 --- a/themes/powerline/powerline.base.bash +++ b/themes/powerline/powerline.base.bash @@ -86,6 +86,8 @@ function __powerline_scm_prompt { scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" elif [[ "${SCM_P4_CHAR}" == "${SCM_CHAR}" ]]; then scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" + elif [[ "${SCM_HG_CHAR}" == "${SCM_CHAR}" ]]; then + scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" fi echo "${scm_prompt}${scm}|${color}" fi @@ -134,6 +136,12 @@ function __powerline_in_vim_prompt { fi } +function __powerline_aws_profile_prompt { + if [[ -n "${AWS_PROFILE}" ]]; then + echo "${AWS_PROFILE_CHAR}${AWS_PROFILE}|${AWS_PROFILE_PROMPT_COLOR}" + fi +} + function __powerline_left_segment { local OLD_IFS="${IFS}"; IFS="|" local params=( $1 ) diff --git a/themes/powerline/powerline.theme.bash b/themes/powerline/powerline.theme.bash index df72a73f..9f0e6f04 100644 --- a/themes/powerline/powerline.theme.bash +++ b/themes/powerline/powerline.theme.bash @@ -15,6 +15,7 @@ PYTHON_VENV_THEME_PROMPT_COLOR=35 SCM_NONE_CHAR="" SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "} +SCM_HG_CHAR=${POWERLINE_SCM_HG_CHAR:="☿ "} SCM_THEME_PROMPT_CLEAN="" SCM_THEME_PROMPT_DIRTY="" SCM_THEME_PROMPT_CLEAN_COLOR=25 @@ -30,6 +31,9 @@ RBENV_THEME_PROMPT_SUFFIX="" RUBY_THEME_PROMPT_COLOR=161 RUBY_CHAR=${POWERLINE_RUBY_CHAR:="❲r❳ "} +AWS_PROFILE_CHAR="${POWERLINE_AWS_PROFILE_CHAR:=❲aws❳ }" +AWS_PROFILE_PROMPT_COLOR=208 + CWD_THEME_PROMPT_COLOR=240 LAST_STATUS_THEME_PROMPT_COLOR=52 diff --git a/themes/zork/zork.theme.bash b/themes/zork/zork.theme.bash index 75bc17d6..07f30e12 100644 --- a/themes/zork/zork.theme.bash +++ b/themes/zork/zork.theme.bash @@ -57,7 +57,12 @@ chroot(){ # show virtualenvwrapper my_ve(){ - if [ -n "$VIRTUAL_ENV" ] + + if [ -n "$CONDA_DEFAULT_ENV" ] + then + my_ps_ve="${bold_purple}${CONDA_DEFAULT_ENV}${normal}"; + echo "($my_ps_ve)"; + elif [ -n "$VIRTUAL_ENV" ] then my_ps_ve="${bold_purple}$ve${normal}"; echo "($my_ps_ve)";