diff --git a/aliases/available/apt.aliases.bash b/aliases/available/apt.aliases.bash index 2f444931..b7ef274c 100644 --- a/aliases/available/apt.aliases.bash +++ b/aliases/available/apt.aliases.bash @@ -1,4 +1,4 @@ -#!/bin/bash +# shellcheck shell=bash # # -binaryanomaly @@ -8,7 +8,8 @@ about-alias 'Apt and dpkg aliases for Ubuntu and Debian distros.' # set apt aliases function _set_pkg_aliases() { - if [ -x $(which apt) ]; then + if _command_exists apt + then alias apts='apt-cache search' alias aptshow='apt-cache show' alias aptinst='sudo apt-get install -V' diff --git a/aliases/available/curl.aliases.bash b/aliases/available/curl.aliases.bash index 3ced1bb5..a6b2b344 100644 --- a/aliases/available/curl.aliases.bash +++ b/aliases/available/curl.aliases.bash @@ -6,7 +6,8 @@ about-alias 'Curl aliases for convenience.' # set apt aliases function _set_pkg_aliases() { - if [ -x $(which curl) ]; then + if _command_exists curl + then # follow redirects alias cl='curl -L' # follow redirects, download as original name diff --git a/aliases/available/general.aliases.bash b/aliases/available/general.aliases.bash index 0c7bcd9d..61ebe538 100644 --- a/aliases/available/general.aliases.bash +++ b/aliases/available/general.aliases.bash @@ -30,7 +30,7 @@ then alias grep='grep --color=auto' fi -if which gshuf &> /dev/null +if _command_exists gshuf then alias shuf=gshuf fi @@ -65,7 +65,7 @@ alias -- -='cd -' # Go back alias h='history' # Tree -if [ ! -x "$(which tree 2>/dev/null)" ] +if ! _command_exists tree then alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'" fi diff --git a/aliases/available/vim.aliases.bash b/aliases/available/vim.aliases.bash index d19057d0..d5dcdc54 100644 --- a/aliases/available/vim.aliases.bash +++ b/aliases/available/vim.aliases.bash @@ -2,11 +2,7 @@ cite 'about-alias' about-alias 'vim abbreviations' -VIM=$(command -v vim) -GVIM=$(command -v gvim) -MVIM=$(command -v mvim) - -if [[ -n $VIM ]]; then +if _command_exists vim; then alias v='$VIM' # open the vim help in fullscreen incorporated from # https://stackoverflow.com/a/4687513 @@ -17,9 +13,9 @@ fi # http://stackoverflow.com/questions/936501/let-gvim-always-run-a-single-instancek case $OSTYPE in darwin*) - [[ -n $MVIM ]] && function mvimt { command mvim --remote-tab-silent "$@" || command mvim "$@"; } + _command_exists mvim && function mvimt { command mvim --remote-tab-silent "$@" || command mvim "$@"; } ;; *) - [[ -n $GVIM ]] && function gvimt { command gvim --remote-tab-silent "$@" || command gvim "$@"; } + _command_exists gvim && function gvimt { command gvim --remote-tab-silent "$@" || command gvim "$@"; } ;; esac diff --git a/bash_it.sh b/bash_it.sh index 679ffdaf..215c33c7 100755 --- a/bash_it.sh +++ b/bash_it.sh @@ -145,7 +145,7 @@ if [ -e "$HOME/.jekyllconfig" ]; then fi # BASH_IT_RELOAD_LEGACY is set. -if ! command -v reload &> /dev/null && [ -n "${BASH_IT_RELOAD_LEGACY:-}" ]; then +if ! _command_exists reload && [[ -n "${BASH_IT_RELOAD_LEGACY:-}" ]]; then case $OSTYPE in darwin*) alias reload='source ~/.bash_profile' diff --git a/clean_files.txt b/clean_files.txt index b8fcee4f..2242ef5e 100644 --- a/clean_files.txt +++ b/clean_files.txt @@ -77,8 +77,10 @@ completion/available/wpscan.completion.bash # plugins # plugins/available/alias-completion.plugin.bash +plugins/available/autojump.plugin.bash plugins/available/basher.plugin.bash plugins/available/cmd-returned-notify.plugin.bash +plugins/available/direnv.plugin.bash plugins/available/docker-machine.plugin.bash plugins/available/git.plugin.bash plugins/available/go.plugin.bash @@ -86,6 +88,14 @@ plugins/available/goenv.plugin.bash plugins/available/history-search.plugin.bash plugins/available/history-substring-search.plugin.bash plugins/available/history.plugin.bash +plugins/available/hub.plugin.bash +plugins/available/jump.plugin.bash +plugins/available/node.plugin.bash +plugins/available/nodenv.plugin.bash +plugins/available/plenv.plugin.bash +plugins/available/pyenv.plugin.bash +plugins/available/rbenv.plugin.bash +plugins/available/textmate.plugin.bash plugins/available/xterm.plugin.bash # tests diff --git a/completion/available/awscli.completion.bash b/completion/available/awscli.completion.bash index 530bdd27..a3041837 100644 --- a/completion/available/awscli.completion.bash +++ b/completion/available/awscli.completion.bash @@ -1 +1,6 @@ -[[ -x "$(which aws_completer)" ]] && complete -C "$(which aws_completer)" aws +# shellcheck shell=bash + +if _command_exists aws_completer +then + complete -C "$(command -v aws_completer)" aws +fi diff --git a/completion/available/consul.completion.bash b/completion/available/consul.completion.bash index 3697ffc5..511cf372 100644 --- a/completion/available/consul.completion.bash +++ b/completion/available/consul.completion.bash @@ -3,5 +3,5 @@ cite "about-completion" about-completion "Hashicorp consul completion" if _command_exists consul; then - complete -C "$(which consul)" consul + complete -C "$(command -v consul)" consul fi diff --git a/completion/available/docker-compose.completion.bash b/completion/available/docker-compose.completion.bash old mode 100644 new mode 100755 index bf2c13fb..1102f5d9 --- a/completion/available/docker-compose.completion.bash +++ b/completion/available/docker-compose.completion.bash @@ -676,7 +676,7 @@ _docker_compose() { done local completions_func=_docker_compose_${command//-/_} - declare -F $completions_func >/dev/null && $completions_func + _is_function $completions_func && $completions_func eval "$previous_extglob_setting" return 0 diff --git a/completion/available/git_flow.completion.bash b/completion/available/git_flow.completion.bash index 04f20ccd..7bfc9ef4 100644 --- a/completion/available/git_flow.completion.bash +++ b/completion/available/git_flow.completion.bash @@ -172,6 +172,7 @@ __git_flow_list_hotfixes () } # temporarily wrap __git_find_on_cmdline() for backwards compatibility -if [ -z "`type -t __git_find_subcommand`" ]; then +if ! _command_exists __git_find_subcommand +then alias __git_find_subcommand=__git_find_on_cmdline fi diff --git a/completion/available/git_flow_avh.completion.bash b/completion/available/git_flow_avh.completion.bash index 0b73a0be..abb51bf8 100644 --- a/completion/available/git_flow_avh.completion.bash +++ b/completion/available/git_flow_avh.completion.bash @@ -505,6 +505,7 @@ __git_flow_list_branches () } # alias __git_find_on_cmdline for backwards compatibility -if [ -z "`type -t __git_find_on_cmdline`" ]; then +if ! _command_exists __git_find_on_cmdline +then alias __git_find_on_cmdline=__git_find_subcommand fi diff --git a/completion/available/gradle.completion.bash b/completion/available/gradle.completion.bash index 6ec8c697..786450a6 100644 --- a/completion/available/gradle.completion.bash +++ b/completion/available/gradle.completion.bash @@ -58,9 +58,9 @@ __gradle-set-cache-name() { __gradle-set-files-checksum() { # Cache MD5 sum of all Gradle scripts and modified timestamps - if builtin command -v md5 > /dev/null; then + if _command_exists md5; then gradle_files_checksum=$(md5 -q -s "$(cat "$cache_dir/$cache_name" | xargs ls -o 2>/dev/null)") - elif builtin command -v md5sum > /dev/null; then + elif _command_exists md5sum; then gradle_files_checksum=$(cat "$cache_dir/$cache_name" | xargs ls -o 2>/dev/null | md5sum | awk '{print $1}') else echo "Cannot generate completions as neither md5 nor md5sum exist on \$PATH" diff --git a/completion/available/hub.completion.bash b/completion/available/hub.completion.bash index 74c530a8..67a5e29b 100644 --- a/completion/available/hub.completion.bash +++ b/completion/available/hub.completion.bash @@ -23,12 +23,12 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # If there is no git tab completion, but we have the _completion loader try to load it -if ! declare -F _git > /dev/null && declare -F _completion_loader > /dev/null; then +if ! _is_function _git && _is_function _completion_loader; then _completion_loader git fi # Check that git tab completion is available and we haven't already set up completion -if declare -F _git > /dev/null && ! declare -F __git_list_all_commands_without_hub > /dev/null; then +if _is_function _git && ! _is_function __git_list_all_commands_without_hub; 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/')" diff --git a/completion/available/laravel.completion.bash b/completion/available/laravel.completion.bash index 7bd6f223..9298a7bf 100644 --- a/completion/available/laravel.completion.bash +++ b/completion/available/laravel.completion.bash @@ -1,7 +1,9 @@ #!/usr/bin/bash -if command -v laravel > /dev/null; then - __laravel_completion() { +if _command_exists laravel +then + function __laravel_completion() + { local OPTS=("-h --help -q --quiet --ansi --no-ansi -n --no-interaction -v -vv -vvv --verbose help list new") COMPREPLY=() for _opt_ in ${OPTS[@]}; do @@ -9,7 +11,7 @@ if command -v laravel > /dev/null; then COMPREPLY+=("$_opt_") fi done - } + } complete -F __laravel_completion laravel fi diff --git a/completion/available/pew.completion.bash b/completion/available/pew.completion.bash index 73d62e39..04e67ecb 100644 --- a/completion/available/pew.completion.bash +++ b/completion/available/pew.completion.bash @@ -1 +1,6 @@ -[[ -x "$(which pew)" ]] && source "$(pew shell_config)" +# shellcheck shell=bash + +if _command_exists pew +then + source "$(pew shell_config)" +fi diff --git a/completion/available/sqlmap.completion.bash b/completion/available/sqlmap.completion.bash index 16addf85..213dd817 100644 --- a/completion/available/sqlmap.completion.bash +++ b/completion/available/sqlmap.completion.bash @@ -1,21 +1,22 @@ -#!/bin/bash +# shellcheck shell=bash # ---------------------------------------------------------------------------+ # | -# Thanks to Alexander Korznikov | +# Thanks to Alexander Korznikov | # http://www.korznikov.com/2014/12/bash-tab-completion-for-awesome-tool.html | # | # ---------------------------------------------------------------------------+ -if command -v sqlmap > /dev/null; then +if _command_exists sqlmap +then - _sqlmap() + function _sqlmap() { local cur prev COMPREPLY=() - cur=$(_get_cword) - prev=$(_get_pword) + cur="$(_get_cword)" + prev="$(_get_pword)" case $prev in @@ -143,7 +144,7 @@ if command -v sqlmap > /dev/null; then --mobile --page-rank --purge-output --smart \ --sqlmap-shell --wizard ' COMPREPLY=( $( \ - (while read -d ' ' i; do + (while read -d ' ' i; do [[ -z "$i" || "${onlyonce/ ${i%% *} / }" == "$onlyonce" ]] && continue # flatten array with spaces on either side, @@ -152,7 +153,7 @@ if command -v sqlmap > /dev/null; then COMPREPLY=" ${COMPREPLY[@]} " # remove word from list of completions COMPREPLY=( ${COMPREPLY/ ${i%% *} / } ) - done + done printf '%s ' "${COMPREPLY[@]}") <<<"${COMP_WORDS[@]}" ) ) diff --git a/completion/available/travis.completion.bash b/completion/available/travis.completion.bash index 28d599aa..49d8f2cc 100644 --- a/completion/available/travis.completion.bash +++ b/completion/available/travis.completion.bash @@ -1,5 +1,10 @@ -if [[ -x "$(which travis)" ]]; then - __TRAVIS_COMPLETION_SCRIPT="${TRAVIS_CONFIG_PATH:-${HOME}/.travis}/travis.sh" - [[ -f "${__TRAVIS_COMPLETION_SCRIPT}" ]] && source "${__TRAVIS_COMPLETION_SCRIPT}" +# shellcheck shell=bash + +if _command_exists travis +then + if [[ -s "${__TRAVIS_COMPLETION_SCRIPT:=${TRAVIS_CONFIG_PATH:-${HOME}/.travis}/travis.sh}" ]] + then + source "${__TRAVIS_COMPLETION_SCRIPT}" + fi unset __TRAVIS_COMPLETION_SCRIPT fi diff --git a/completion/available/wpscan.completion.bash b/completion/available/wpscan.completion.bash index 5d2e2daa..8891ab7f 100644 --- a/completion/available/wpscan.completion.bash +++ b/completion/available/wpscan.completion.bash @@ -1,7 +1,7 @@ # shellcheck shell=bash -if command -v wpscan > /dev/null; then - __wpscan_completion() { +if _command_exists wpscan; then + function __wpscan_completion() { local OPTS=("--help --hh --version --url --ignore-main-redirect --verbose --output --format --detection-mode --scope --headers --user-agent --vhost --random-user-agent --user-agents-list --http-auth --max-threads --throttle --request-timeout --connect-timeout --disable-tlc-checks --proxy --proxy-auth --cookie-string --cookie-jar --cache-ttl --clear-cache --server --cache-dir --update --no-update --wp-content-dir --wp-plugins-dir --wp-version-detection --main-theme-detection --enumerate --exclude-content-based --plugins-list --plugins-detection --plugins-version-all --plugins-version-detection --themes-list --themes-detection --themes-version-all --themes-version-detection --timthumbs-list --timthumbs-detection --config-backups-list --config-backups-detection --db-exports-list --db-exports-detection --medias-detection --users-list --users-detection --passwords --usernames --multicall-max-passwords --password-attack --stealthy") COMPREPLY=() for _opt_ in "${OPTS[@]}"; do diff --git a/lib/helpers.bash b/lib/helpers.bash old mode 100644 new mode 100755 index 61705a04..fbc6aa88 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -23,7 +23,13 @@ function _command_exists () _example '$ _command_exists ls && echo exists' _group 'lib' local msg="${2:-Command '$1' does not exist!}" - type "$1" &> /dev/null || (_log_warning "$msg" && return 1) ; + if type -t "$1" &> /dev/null + then + return 0 + else + _log_warning "$msg" + return 1 + fi } function _binary_exists () @@ -34,7 +40,13 @@ function _binary_exists () _example '$ _binary_exists ls && echo exists' _group 'lib' local msg="${2:-Binary '$1' does not exist!}" - type -P "$1" &> /dev/null || (_log_warning "$msg" && return 1) ; + if type -P "$1" &> /dev/null + then + return 0 + else + _log_warning "$msg" + return 1 + fi } function _completion_exists () diff --git a/plugins/available/autojump.plugin.bash b/plugins/available/autojump.plugin.bash index 7e6df7fc..dc8fbbb4 100644 --- a/plugins/available/autojump.plugin.bash +++ b/plugins/available/autojump.plugin.bash @@ -1,12 +1,15 @@ +# shellcheck shell=bash cite about-plugin about-plugin 'Autojump configuration, see https://github.com/wting/autojump for more details' # Only supports the Homebrew variant, Debian and Arch at the moment. # Feel free to provide a PR to support other install locations if _bash_it_homebrew_check && [[ -s "${BASH_IT_HOMEBREW_PREFIX}/etc/profile.d/autojump.sh" ]]; then - . "${BASH_IT_HOMEBREW_PREFIX}/etc/profile.d/autojump.sh" -elif command -v dpkg &>/dev/null && dpkg -s autojump &>/dev/null ; then - . "$(dpkg-query -S autojump.sh | cut -d' ' -f2)" -elif command -v pacman &>/dev/null && pacman -Q autojump &>/dev/null ; then - . "$(pacman -Ql autojump | grep autojump.sh | cut -d' ' -f2)" + source "${BASH_IT_HOMEBREW_PREFIX}/etc/profile.d/autojump.sh" +elif _command_exists dpkg && dpkg -s autojump &> /dev/null; then + # shellcheck disable=SC1090 + source "$(dpkg-query -S autojump.sh | cut -d' ' -f2)" +elif _command_exists pacman && pacman -Q autojump &> /dev/null; then + # shellcheck disable=SC1090 + source "$(pacman -Ql autojump | grep autojump.sh | cut -d' ' -f2)" fi diff --git a/plugins/available/base.plugin.bash b/plugins/available/base.plugin.bash index 8499a2df..b0899ce9 100644 --- a/plugins/available/base.plugin.bash +++ b/plugins/available/base.plugin.bash @@ -5,10 +5,10 @@ function ips () { about 'display all ip addresses for this host' group 'base' - if command -v ifconfig &>/dev/null + if _command_exists ifconfig then ifconfig | awk '/inet /{ gsub(/addr:/, ""); print $2 }' - elif command -v ip &>/dev/null + elif _command_exists ip then ip addr | grep -oP 'inet \K[\d.]+' else @@ -70,7 +70,7 @@ function passgen () # Create alias pass to passgen when pass isn't installed or # BASH_IT_LEGACY_PASS is true. -if ! command -v pass &>/dev/null || [[ "${BASH_IT_LEGACY_PASS:-}" = true ]] +if ! _command_exists pass || [[ "${BASH_IT_LEGACY_PASS:-}" = true ]] then alias pass=passgen fi @@ -81,7 +81,7 @@ function pmdown () param '1: markdown file' example '$ pmdown README.md' group 'base' - if command -v markdown &>/dev/null + if _command_exists markdown then markdown $1 | browser else diff --git a/plugins/available/direnv.plugin.bash b/plugins/available/direnv.plugin.bash index 5fd564f5..62788600 100644 --- a/plugins/available/direnv.plugin.bash +++ b/plugins/available/direnv.plugin.bash @@ -1,4 +1,7 @@ +# shellcheck shell=bash cite about-plugin about-plugin 'load direnv, if you are using it: https://direnv.net/' -[ -x "$(which direnv)" ] && eval "$(direnv hook bash)" +if _command_exists direnv; then + eval "$(direnv hook bash)" +fi diff --git a/plugins/available/hub.plugin.bash b/plugins/available/hub.plugin.bash index 0a67a7af..e9a8cbab 100644 --- a/plugins/available/hub.plugin.bash +++ b/plugins/available/hub.plugin.bash @@ -1,4 +1,7 @@ +# shellcheck shell=bash cite about-plugin about-plugin 'load hub, if you are using it' -command -v hub &> /dev/null && eval "$(hub alias -s)" +if _command_exists hub; then + eval "$(hub alias -s)" +fi diff --git a/plugins/available/jump.plugin.bash b/plugins/available/jump.plugin.bash index 26d6467d..1713d1b7 100644 --- a/plugins/available/jump.plugin.bash +++ b/plugins/available/jump.plugin.bash @@ -1,9 +1,12 @@ +# shellcheck shell=bash +# shellcheck disable=SC2016 cite about-plugin about-plugin 'initialize jump (see https://github.com/gsamokovarov/jump). Add `export JUMP_OPTS=("--bind=z")` to change keybinding' -__init_jump() { - command -v jump &> /dev/null || return - eval "$(jump shell bash "${JUMP_OPTS[@]}")" +function __init_jump() { + if _command_exists jump; then + eval "$(jump shell bash "${JUMP_OPTS[@]}")" + fi } __init_jump diff --git a/plugins/available/node.plugin.bash b/plugins/available/node.plugin.bash index 65df3da3..8bf876df 100644 --- a/plugins/available/node.plugin.bash +++ b/plugins/available/node.plugin.bash @@ -1,13 +1,14 @@ +# shellcheck shell=bash cite about-plugin about-plugin 'Node.js helper functions' +# Check that we have npm +_command_exists npm || return + # Ensure local modules are preferred in PATH pathmunge "./node_modules/.bin" "after" -# Check that we have npm -out=$(command -v npm 2>&1) || return - # If not using nodenv, ensure global modules are in PATH -if [[ ! $out == *"nodenv/shims"* ]] ; then - pathmunge "$(npm config get prefix)/bin" "after" +if [[ ! "$(type -p npm)" == *"nodenv/shims"* ]]; then + pathmunge "$(npm config get prefix)/bin" "after" fi diff --git a/plugins/available/nodenv.plugin.bash b/plugins/available/nodenv.plugin.bash index 1bbe7fbd..262a57c3 100644 --- a/plugins/available/nodenv.plugin.bash +++ b/plugins/available/nodenv.plugin.bash @@ -1,7 +1,10 @@ +# shellcheck shell=bash cite about-plugin about-plugin 'load nodenv, if you are using it' export NODENV_ROOT="$HOME/.nodenv" pathmunge "$NODENV_ROOT/bin" -[[ `which nodenv` ]] && eval "$(nodenv init - bash)" +if _command_exists nodenv; then + eval "$(nodenv init - bash)" +fi diff --git a/plugins/available/nvm.plugin.bash b/plugins/available/nvm.plugin.bash index 87dce644..0e6da5d8 100644 --- a/plugins/available/nvm.plugin.bash +++ b/plugins/available/nvm.plugin.bash @@ -1,22 +1,23 @@ -# Bash-it no longer bundles nvm, as this was quickly becoming outdated. +# shellcheck shell=bash # # BASH_IT_LOAD_PRIORITY: 225 # +# Bash-it no longer bundles nvm, as this was quickly becoming outdated. # Please install nvm from https://github.com/creationix/nvm.git if you want to use it. cite about-plugin about-plugin 'node version manager configuration' -export NVM_DIR=${NVM_DIR:-$HOME/.nvm} +export NVM_DIR="${NVM_DIR:-$HOME/.nvm}" # This loads nvm -if _bash_it_homebrew_check && [ -s "${BASH_IT_HOMEBREW_PREFIX}/nvm.sh" ] +if _bash_it_homebrew_check && [[ -s "${BASH_IT_HOMEBREW_PREFIX}/nvm.sh" ]] then - . "${BASH_IT_HOMEBREW_PREFIX}/nvm.sh" + source "${BASH_IT_HOMEBREW_PREFIX}/nvm.sh" else - [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" + [[ -s "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh" fi -if ! command -v nvm &>/dev/null +if ! _command_exists nvm then function nvm() { echo "Bash-it no longer bundles the nvm script. Please install the latest version from" diff --git a/plugins/available/plenv.plugin.bash b/plugins/available/plenv.plugin.bash index 1da2d61b..79a9cf49 100644 --- a/plugins/available/plenv.plugin.bash +++ b/plugins/available/plenv.plugin.bash @@ -1,18 +1,16 @@ +# shellcheck shell=bash +# # 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" - +if [[ -d "${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 - bash)" - +if _command_exists plenv; then + # init plenv + eval "$(plenv init - bash)" fi diff --git a/plugins/available/powerline.plugin.bash b/plugins/available/powerline.plugin.bash index 3d91e658..1927bf3e 100644 --- a/plugins/available/powerline.plugin.bash +++ b/plugins/available/powerline.plugin.bash @@ -1,9 +1,9 @@ -#!/usr/bin/env bash +# shellcheck shell=bash cite about-plugin about-plugin 'enables powerline daemon' -command -v powerline-daemon &>/dev/null || return +_command_exists powerline-daemon || return powerline-daemon -q #the following should not be executed if bashit powerline themes in use @@ -14,13 +14,13 @@ case "$BASH_IT_THEME" in esac POWERLINE_BASH_CONTINUATION=1 POWERLINE_BASH_SELECT=1 -bashPowerlineInit=$(python -c \ +bashPowerlineInit="$(python -c \ "import os; \ import powerline;\ print(os.path.join(os.path.dirname(\ powerline.__file__),\ 'bindings', \ 'bash', \ - 'powerline.sh'))") + 'powerline.sh'))")" [ -e $bashPowerlineInit ] || return -. $bashPowerlineInit +source $bashPowerlineInit diff --git a/plugins/available/pyenv.plugin.bash b/plugins/available/pyenv.plugin.bash index 4d8db4fb..dc8df3ad 100644 --- a/plugins/available/pyenv.plugin.bash +++ b/plugins/available/pyenv.plugin.bash @@ -1,12 +1,15 @@ +# shellcheck shell=bash cite about-plugin about-plugin 'load pyenv, if you are using it' export PYENV_ROOT="$HOME/.pyenv" pathmunge "$PYENV_ROOT/bin" -[[ `which pyenv 2>/dev/null` ]] && eval "$(pyenv init - bash)" +if _command_exists pyenv; then + eval "$(pyenv init - bash)" +fi #Load pyenv virtualenv if the virtualenv plugin is installed. if pyenv virtualenv-init - &> /dev/null; then - eval "$(pyenv virtualenv-init - bash)" + eval "$(pyenv virtualenv-init - bash)" fi diff --git a/plugins/available/rbenv.plugin.bash b/plugins/available/rbenv.plugin.bash index 2b01669d..f3605f58 100644 --- a/plugins/available/rbenv.plugin.bash +++ b/plugins/available/rbenv.plugin.bash @@ -1,7 +1,10 @@ +# shellcheck shell=bash cite about-plugin about-plugin 'load rbenv, if you are using it' export RBENV_ROOT="$HOME/.rbenv" pathmunge "$RBENV_ROOT/bin" -[[ `which rbenv 2>/dev/null` ]] && eval "$(rbenv init - bash)" +if _command_exists rbenv; then + eval "$(rbenv init - bash)" +fi diff --git a/plugins/available/ruby.plugin.bash b/plugins/available/ruby.plugin.bash index 4ab891d9..b1164106 100644 --- a/plugins/available/ruby.plugin.bash +++ b/plugins/available/ruby.plugin.bash @@ -1,9 +1,11 @@ +# shellcheck shell=bash cite about-plugin 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 +if _command_exists ruby && _command_exists gem +then pathmunge "$(ruby -e 'print Gem.user_dir')/bin" after fi diff --git a/plugins/available/textmate.plugin.bash b/plugins/available/textmate.plugin.bash index e3538c1e..5c81f195 100644 --- a/plugins/available/textmate.plugin.bash +++ b/plugins/available/textmate.plugin.bash @@ -1,7 +1,9 @@ +# shellcheck shell=bash cite about-plugin about-plugin 'set textmate as a default editor' -if $(command -v mate &> /dev/null) ; then - export EDITOR="$(which mate) -w" - export GIT_EDITOR=$EDITOR +if _command_exists mate; then + EDITOR="$(type -p mate) -w" + GIT_EDITOR="$EDITOR" + export EDITOR GIT_EDITOR fi diff --git a/plugins/available/virtualenv.plugin.bash b/plugins/available/virtualenv.plugin.bash index f1c85987..41d55ddf 100644 --- a/plugins/available/virtualenv.plugin.bash +++ b/plugins/available/virtualenv.plugin.bash @@ -1,12 +1,14 @@ +# shellcheck shell=bash +# # make sure virtualenvwrapper is enabled if available cite about-plugin about-plugin 'virtualenvwrapper and pyenv-virtualenvwrapper helper functions' if _command_exists pyenv; then - pyenv virtualenvwrapper -else - [[ `which virtualenvwrapper.sh` ]] && . virtualenvwrapper.sh + pyenv virtualenvwrapper +elif _command_exists virtualenvwrapper.sh; then + source virtualenvwrapper.sh fi diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 1e0409d3..f9f5190d 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -396,7 +396,7 @@ function hg_prompt_vars { function nvm_version_prompt { local node - if declare -f -F nvm &> /dev/null; then + if _is_function nvm; then node=$(nvm current 2> /dev/null) [[ "${node}" == "system" ]] && return echo -e "${NVM_THEME_PROMPT_PREFIX}${node}${NVM_THEME_PROMPT_SUFFIX}" @@ -433,8 +433,8 @@ function rbfu_version_prompt { } function chruby_version_prompt { - if declare -f -F chruby &> /dev/null; then - if declare -f -F chruby_auto &> /dev/null; then + if _is_function chruby; then + if _is_function chruby_auto; then chruby_auto fi diff --git a/themes/dulcie/dulcie.theme.bash b/themes/dulcie/dulcie.theme.bash old mode 100644 new mode 100755 index a83b62fb..f70c7864 --- a/themes/dulcie/dulcie.theme.bash +++ b/themes/dulcie/dulcie.theme.bash @@ -77,7 +77,7 @@ dulcie_prompt() { printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}" # Open the new terminal in the same directory - declare -f __vte_osc7 > /dev/null && __vte_osc7 + _is_function __vte_osc7 && __vte_osc7 PS1="${reset_color}[${DULCIE_USER}@${DULCIE_HOST}$(scm_prompt_info)${reset_color} ${DULCIE_WORKINGDIR}]" if [[ "${DULCIE_MULTILINE}" -eq "1" ]]; then