Merge pull request #1938 from gaelicWizard/_command_exists

Use `_command_exists` everywhere
pull/1960/head
Noah Gorny 2021-09-20 14:56:45 +03:00 committed by GitHub
commit 8c697715eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 163 additions and 96 deletions

View File

@ -1,4 +1,4 @@
#!/bin/bash # shellcheck shell=bash
# #
# -binaryanomaly # -binaryanomaly
@ -8,7 +8,8 @@ about-alias 'Apt and dpkg aliases for Ubuntu and Debian distros.'
# set apt aliases # set apt aliases
function _set_pkg_aliases() function _set_pkg_aliases()
{ {
if [ -x $(which apt) ]; then if _command_exists apt
then
alias apts='apt-cache search' alias apts='apt-cache search'
alias aptshow='apt-cache show' alias aptshow='apt-cache show'
alias aptinst='sudo apt-get install -V' alias aptinst='sudo apt-get install -V'

View File

@ -6,7 +6,8 @@ about-alias 'Curl aliases for convenience.'
# set apt aliases # set apt aliases
function _set_pkg_aliases() function _set_pkg_aliases()
{ {
if [ -x $(which curl) ]; then if _command_exists curl
then
# follow redirects # follow redirects
alias cl='curl -L' alias cl='curl -L'
# follow redirects, download as original name # follow redirects, download as original name

View File

@ -30,7 +30,7 @@ then
alias grep='grep --color=auto' alias grep='grep --color=auto'
fi fi
if which gshuf &> /dev/null if _command_exists gshuf
then then
alias shuf=gshuf alias shuf=gshuf
fi fi
@ -65,7 +65,7 @@ alias -- -='cd -' # Go back
alias h='history' alias h='history'
# Tree # Tree
if [ ! -x "$(which tree 2>/dev/null)" ] if ! _command_exists tree
then then
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'" alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
fi fi

View File

@ -2,11 +2,7 @@
cite 'about-alias' cite 'about-alias'
about-alias 'vim abbreviations' about-alias 'vim abbreviations'
VIM=$(command -v vim) if _command_exists vim; then
GVIM=$(command -v gvim)
MVIM=$(command -v mvim)
if [[ -n $VIM ]]; then
alias v='$VIM' alias v='$VIM'
# open the vim help in fullscreen incorporated from # open the vim help in fullscreen incorporated from
# https://stackoverflow.com/a/4687513 # https://stackoverflow.com/a/4687513
@ -17,9 +13,9 @@ fi
# http://stackoverflow.com/questions/936501/let-gvim-always-run-a-single-instancek # http://stackoverflow.com/questions/936501/let-gvim-always-run-a-single-instancek
case $OSTYPE in case $OSTYPE in
darwin*) 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 esac

View File

@ -145,7 +145,7 @@ if [ -e "$HOME/.jekyllconfig" ]; then
fi fi
# BASH_IT_RELOAD_LEGACY is set. # 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 case $OSTYPE in
darwin*) darwin*)
alias reload='source ~/.bash_profile' alias reload='source ~/.bash_profile'

View File

@ -77,8 +77,10 @@ completion/available/wpscan.completion.bash
# plugins # plugins
# #
plugins/available/alias-completion.plugin.bash plugins/available/alias-completion.plugin.bash
plugins/available/autojump.plugin.bash
plugins/available/basher.plugin.bash plugins/available/basher.plugin.bash
plugins/available/cmd-returned-notify.plugin.bash plugins/available/cmd-returned-notify.plugin.bash
plugins/available/direnv.plugin.bash
plugins/available/docker-machine.plugin.bash plugins/available/docker-machine.plugin.bash
plugins/available/git.plugin.bash plugins/available/git.plugin.bash
plugins/available/go.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-search.plugin.bash
plugins/available/history-substring-search.plugin.bash plugins/available/history-substring-search.plugin.bash
plugins/available/history.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 plugins/available/xterm.plugin.bash
# tests # tests

View File

@ -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

View File

@ -3,5 +3,5 @@ cite "about-completion"
about-completion "Hashicorp consul completion" about-completion "Hashicorp consul completion"
if _command_exists consul; then if _command_exists consul; then
complete -C "$(which consul)" consul complete -C "$(command -v consul)" consul
fi fi

View File

@ -676,7 +676,7 @@ _docker_compose() {
done done
local completions_func=_docker_compose_${command//-/_} local completions_func=_docker_compose_${command//-/_}
declare -F $completions_func >/dev/null && $completions_func _is_function $completions_func && $completions_func
eval "$previous_extglob_setting" eval "$previous_extglob_setting"
return 0 return 0

View File

@ -172,6 +172,7 @@ __git_flow_list_hotfixes ()
} }
# temporarily wrap __git_find_on_cmdline() for backwards compatibility # 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 alias __git_find_subcommand=__git_find_on_cmdline
fi fi

View File

@ -505,6 +505,7 @@ __git_flow_list_branches ()
} }
# alias __git_find_on_cmdline for backwards compatibility # 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 alias __git_find_on_cmdline=__git_find_subcommand
fi fi

View File

@ -58,9 +58,9 @@ __gradle-set-cache-name() {
__gradle-set-files-checksum() { __gradle-set-files-checksum() {
# Cache MD5 sum of all Gradle scripts and modified timestamps # 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)") 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}') gradle_files_checksum=$(cat "$cache_dir/$cache_name" | xargs ls -o 2>/dev/null | md5sum | awk '{print $1}')
else else
echo "Cannot generate completions as neither md5 nor md5sum exist on \$PATH" echo "Cannot generate completions as neither md5 nor md5sum exist on \$PATH"

View File

@ -23,12 +23,12 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # 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 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 _completion_loader git
fi fi
# Check that git tab completion is available and we haven't already set up completion # 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 # Duplicate and rename the 'list_all_commands' function
eval "$(declare -f __git_list_all_commands | \ eval "$(declare -f __git_list_all_commands | \
sed 's/__git_list_all_commands/__git_list_all_commands_without_hub/')" sed 's/__git_list_all_commands/__git_list_all_commands_without_hub/')"

View File

@ -1,7 +1,9 @@
#!/usr/bin/bash #!/usr/bin/bash
if command -v laravel > /dev/null; then if _command_exists laravel
__laravel_completion() { then
function __laravel_completion()
{
local OPTS=("-h --help -q --quiet --ansi --no-ansi -n --no-interaction -v -vv -vvv --verbose help list new") local OPTS=("-h --help -q --quiet --ansi --no-ansi -n --no-interaction -v -vv -vvv --verbose help list new")
COMPREPLY=() COMPREPLY=()
for _opt_ in ${OPTS[@]}; do for _opt_ in ${OPTS[@]}; do
@ -9,7 +11,7 @@ if command -v laravel > /dev/null; then
COMPREPLY+=("$_opt_") COMPREPLY+=("$_opt_")
fi fi
done done
} }
complete -F __laravel_completion laravel complete -F __laravel_completion laravel
fi fi

View File

@ -1 +1,6 @@
[[ -x "$(which pew)" ]] && source "$(pew shell_config)" # shellcheck shell=bash
if _command_exists pew
then
source "$(pew shell_config)"
fi

View File

@ -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 | # 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 local cur prev
COMPREPLY=() COMPREPLY=()
cur=$(_get_cword) cur="$(_get_cword)"
prev=$(_get_pword) prev="$(_get_pword)"
case $prev in case $prev in
@ -143,7 +144,7 @@ if command -v sqlmap > /dev/null; then
--mobile --page-rank --purge-output --smart \ --mobile --page-rank --purge-output --smart \
--sqlmap-shell --wizard ' --sqlmap-shell --wizard '
COMPREPLY=( $( \ COMPREPLY=( $( \
(while read -d ' ' i; do (while read -d ' ' i; do
[[ -z "$i" || "${onlyonce/ ${i%% *} / }" == "$onlyonce" ]] && [[ -z "$i" || "${onlyonce/ ${i%% *} / }" == "$onlyonce" ]] &&
continue continue
# flatten array with spaces on either side, # flatten array with spaces on either side,
@ -152,7 +153,7 @@ if command -v sqlmap > /dev/null; then
COMPREPLY=" ${COMPREPLY[@]} " COMPREPLY=" ${COMPREPLY[@]} "
# remove word from list of completions # remove word from list of completions
COMPREPLY=( ${COMPREPLY/ ${i%% *} / } ) COMPREPLY=( ${COMPREPLY/ ${i%% *} / } )
done done
printf '%s ' "${COMPREPLY[@]}") <<<"${COMP_WORDS[@]}" printf '%s ' "${COMPREPLY[@]}") <<<"${COMP_WORDS[@]}"
) ) ) )

View File

@ -1,5 +1,10 @@
if [[ -x "$(which travis)" ]]; then # shellcheck shell=bash
__TRAVIS_COMPLETION_SCRIPT="${TRAVIS_CONFIG_PATH:-${HOME}/.travis}/travis.sh"
[[ -f "${__TRAVIS_COMPLETION_SCRIPT}" ]] && source "${__TRAVIS_COMPLETION_SCRIPT}" 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 unset __TRAVIS_COMPLETION_SCRIPT
fi fi

View File

@ -1,7 +1,7 @@
# shellcheck shell=bash # shellcheck shell=bash
if command -v wpscan > /dev/null; then if _command_exists wpscan; then
__wpscan_completion() { 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") 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=() COMPREPLY=()
for _opt_ in "${OPTS[@]}"; do for _opt_ in "${OPTS[@]}"; do

16
lib/helpers.bash 100644 → 100755
View File

@ -23,7 +23,13 @@ function _command_exists ()
_example '$ _command_exists ls && echo exists' _example '$ _command_exists ls && echo exists'
_group 'lib' _group 'lib'
local msg="${2:-Command '$1' does not exist!}" 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 () function _binary_exists ()
@ -34,7 +40,13 @@ function _binary_exists ()
_example '$ _binary_exists ls && echo exists' _example '$ _binary_exists ls && echo exists'
_group 'lib' _group 'lib'
local msg="${2:-Binary '$1' does not exist!}" 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 () function _completion_exists ()

View File

@ -1,12 +1,15 @@
# shellcheck shell=bash
cite about-plugin cite about-plugin
about-plugin 'Autojump configuration, see https://github.com/wting/autojump for more details' about-plugin 'Autojump configuration, see https://github.com/wting/autojump for more details'
# Only supports the Homebrew variant, Debian and Arch at the moment. # Only supports the Homebrew variant, Debian and Arch at the moment.
# Feel free to provide a PR to support other install locations # 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 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" source "${BASH_IT_HOMEBREW_PREFIX}/etc/profile.d/autojump.sh"
elif command -v dpkg &>/dev/null && dpkg -s autojump &>/dev/null ; then elif _command_exists dpkg && dpkg -s autojump &> /dev/null; then
. "$(dpkg-query -S autojump.sh | cut -d' ' -f2)" # shellcheck disable=SC1090
elif command -v pacman &>/dev/null && pacman -Q autojump &>/dev/null ; then source "$(dpkg-query -S autojump.sh | cut -d' ' -f2)"
. "$(pacman -Ql autojump | grep 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 fi

View File

@ -5,10 +5,10 @@ function ips ()
{ {
about 'display all ip addresses for this host' about 'display all ip addresses for this host'
group 'base' group 'base'
if command -v ifconfig &>/dev/null if _command_exists ifconfig
then then
ifconfig | awk '/inet /{ gsub(/addr:/, ""); print $2 }' ifconfig | awk '/inet /{ gsub(/addr:/, ""); print $2 }'
elif command -v ip &>/dev/null elif _command_exists ip
then then
ip addr | grep -oP 'inet \K[\d.]+' ip addr | grep -oP 'inet \K[\d.]+'
else else
@ -70,7 +70,7 @@ function passgen ()
# Create alias pass to passgen when pass isn't installed or # Create alias pass to passgen when pass isn't installed or
# BASH_IT_LEGACY_PASS is true. # 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 then
alias pass=passgen alias pass=passgen
fi fi
@ -81,7 +81,7 @@ function pmdown ()
param '1: markdown file' param '1: markdown file'
example '$ pmdown README.md' example '$ pmdown README.md'
group 'base' group 'base'
if command -v markdown &>/dev/null if _command_exists markdown
then then
markdown $1 | browser markdown $1 | browser
else else

View File

@ -1,4 +1,7 @@
# shellcheck shell=bash
cite about-plugin cite about-plugin
about-plugin 'load direnv, if you are using it: https://direnv.net/' 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

View File

@ -1,4 +1,7 @@
# shellcheck shell=bash
cite about-plugin cite about-plugin
about-plugin 'load hub, if you are using it' 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

View File

@ -1,9 +1,12 @@
# shellcheck shell=bash
# shellcheck disable=SC2016
cite about-plugin cite about-plugin
about-plugin 'initialize jump (see https://github.com/gsamokovarov/jump). Add `export JUMP_OPTS=("--bind=z")` to change keybinding' about-plugin 'initialize jump (see https://github.com/gsamokovarov/jump). Add `export JUMP_OPTS=("--bind=z")` to change keybinding'
__init_jump() { function __init_jump() {
command -v jump &> /dev/null || return if _command_exists jump; then
eval "$(jump shell bash "${JUMP_OPTS[@]}")" eval "$(jump shell bash "${JUMP_OPTS[@]}")"
fi
} }
__init_jump __init_jump

View File

@ -1,13 +1,14 @@
# shellcheck shell=bash
cite about-plugin cite about-plugin
about-plugin 'Node.js helper functions' about-plugin 'Node.js helper functions'
# Check that we have npm
_command_exists npm || return
# Ensure local modules are preferred in PATH # Ensure local modules are preferred in PATH
pathmunge "./node_modules/.bin" "after" 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 not using nodenv, ensure global modules are in PATH
if [[ ! $out == *"nodenv/shims"* ]] ; then if [[ ! "$(type -p npm)" == *"nodenv/shims"* ]]; then
pathmunge "$(npm config get prefix)/bin" "after" pathmunge "$(npm config get prefix)/bin" "after"
fi fi

View File

@ -1,7 +1,10 @@
# shellcheck shell=bash
cite about-plugin cite about-plugin
about-plugin 'load nodenv, if you are using it' about-plugin 'load nodenv, if you are using it'
export NODENV_ROOT="$HOME/.nodenv" export NODENV_ROOT="$HOME/.nodenv"
pathmunge "$NODENV_ROOT/bin" pathmunge "$NODENV_ROOT/bin"
[[ `which nodenv` ]] && eval "$(nodenv init - bash)" if _command_exists nodenv; then
eval "$(nodenv init - bash)"
fi

View File

@ -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_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. # Please install nvm from https://github.com/creationix/nvm.git if you want to use it.
cite about-plugin cite about-plugin
about-plugin 'node version manager configuration' about-plugin 'node version manager configuration'
export NVM_DIR=${NVM_DIR:-$HOME/.nvm} export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"
# This loads 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 then
. "${BASH_IT_HOMEBREW_PREFIX}/nvm.sh" source "${BASH_IT_HOMEBREW_PREFIX}/nvm.sh"
else else
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" [[ -s "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh"
fi fi
if ! command -v nvm &>/dev/null if ! _command_exists nvm
then then
function nvm() { function nvm() {
echo "Bash-it no longer bundles the nvm script. Please install the latest version from" echo "Bash-it no longer bundles the nvm script. Please install the latest version from"

View File

@ -1,18 +1,16 @@
# shellcheck shell=bash
#
# plugin for plenv # plugin for plenv
cite about-plugin cite about-plugin
about-plugin 'plenv plugin for Perl' about-plugin 'plenv plugin for Perl'
if [[ -e "${HOME}/.plenv/bin" ]] ; then if [[ -d "${HOME}/.plenv/bin" ]]; then
# load plenv bin dir into path if it exists
# load plenv bin dir into path if it exists pathmunge "${HOME}/.plenv/bin"
pathmunge "${HOME}/.plenv/bin"
fi fi
if [[ `which plenv` ]] ; then if _command_exists plenv; then
# init plenv
# init plenv eval "$(plenv init - bash)"
eval "$(plenv init - bash)"
fi fi

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash # shellcheck shell=bash
cite about-plugin cite about-plugin
about-plugin 'enables powerline daemon' about-plugin 'enables powerline daemon'
command -v powerline-daemon &>/dev/null || return _command_exists powerline-daemon || return
powerline-daemon -q powerline-daemon -q
#the following should not be executed if bashit powerline themes in use #the following should not be executed if bashit powerline themes in use
@ -14,13 +14,13 @@ case "$BASH_IT_THEME" in
esac esac
POWERLINE_BASH_CONTINUATION=1 POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1 POWERLINE_BASH_SELECT=1
bashPowerlineInit=$(python -c \ bashPowerlineInit="$(python -c \
"import os; \ "import os; \
import powerline;\ import powerline;\
print(os.path.join(os.path.dirname(\ print(os.path.join(os.path.dirname(\
powerline.__file__),\ powerline.__file__),\
'bindings', \ 'bindings', \
'bash', \ 'bash', \
'powerline.sh'))") 'powerline.sh'))")"
[ -e $bashPowerlineInit ] || return [ -e $bashPowerlineInit ] || return
. $bashPowerlineInit source $bashPowerlineInit

View File

@ -1,12 +1,15 @@
# shellcheck shell=bash
cite about-plugin cite about-plugin
about-plugin 'load pyenv, if you are using it' about-plugin 'load pyenv, if you are using it'
export PYENV_ROOT="$HOME/.pyenv" export PYENV_ROOT="$HOME/.pyenv"
pathmunge "$PYENV_ROOT/bin" 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. #Load pyenv virtualenv if the virtualenv plugin is installed.
if pyenv virtualenv-init - &> /dev/null; then if pyenv virtualenv-init - &> /dev/null; then
eval "$(pyenv virtualenv-init - bash)" eval "$(pyenv virtualenv-init - bash)"
fi fi

View File

@ -1,7 +1,10 @@
# shellcheck shell=bash
cite about-plugin cite about-plugin
about-plugin 'load rbenv, if you are using it' about-plugin 'load rbenv, if you are using it'
export RBENV_ROOT="$HOME/.rbenv" export RBENV_ROOT="$HOME/.rbenv"
pathmunge "$RBENV_ROOT/bin" pathmunge "$RBENV_ROOT/bin"
[[ `which rbenv 2>/dev/null` ]] && eval "$(rbenv init - bash)" if _command_exists rbenv; then
eval "$(rbenv init - bash)"
fi

View File

@ -1,9 +1,11 @@
# shellcheck shell=bash
cite about-plugin cite about-plugin
about-plugin 'ruby and rubygems specific functions and settings' about-plugin 'ruby and rubygems specific functions and settings'
# Make commands installed with 'gem install --user-install' available # Make commands installed with 'gem install --user-install' available
# ~/.gem/ruby/${RUBY_VERSION}/bin/ # ~/.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 pathmunge "$(ruby -e 'print Gem.user_dir')/bin" after
fi fi

View File

@ -1,7 +1,9 @@
# shellcheck shell=bash
cite about-plugin cite about-plugin
about-plugin 'set textmate as a default editor' about-plugin 'set textmate as a default editor'
if $(command -v mate &> /dev/null) ; then if _command_exists mate; then
export EDITOR="$(which mate) -w" EDITOR="$(type -p mate) -w"
export GIT_EDITOR=$EDITOR GIT_EDITOR="$EDITOR"
export EDITOR GIT_EDITOR
fi fi

View File

@ -1,12 +1,14 @@
# shellcheck shell=bash
#
# make sure virtualenvwrapper is enabled if available # make sure virtualenvwrapper is enabled if available
cite about-plugin cite about-plugin
about-plugin 'virtualenvwrapper and pyenv-virtualenvwrapper helper functions' about-plugin 'virtualenvwrapper and pyenv-virtualenvwrapper helper functions'
if _command_exists pyenv; then if _command_exists pyenv; then
pyenv virtualenvwrapper pyenv virtualenvwrapper
else elif _command_exists virtualenvwrapper.sh; then
[[ `which virtualenvwrapper.sh` ]] && . virtualenvwrapper.sh source virtualenvwrapper.sh
fi fi

View File

@ -396,7 +396,7 @@ function hg_prompt_vars {
function nvm_version_prompt { function nvm_version_prompt {
local node local node
if declare -f -F nvm &> /dev/null; then if _is_function nvm; then
node=$(nvm current 2> /dev/null) node=$(nvm current 2> /dev/null)
[[ "${node}" == "system" ]] && return [[ "${node}" == "system" ]] && return
echo -e "${NVM_THEME_PROMPT_PREFIX}${node}${NVM_THEME_PROMPT_SUFFIX}" echo -e "${NVM_THEME_PROMPT_PREFIX}${node}${NVM_THEME_PROMPT_SUFFIX}"
@ -433,8 +433,8 @@ function rbfu_version_prompt {
} }
function chruby_version_prompt { function chruby_version_prompt {
if declare -f -F chruby &> /dev/null; then if _is_function chruby; then
if declare -f -F chruby_auto &> /dev/null; then if _is_function chruby_auto; then
chruby_auto chruby_auto
fi fi

2
themes/dulcie/dulcie.theme.bash 100644 → 100755
View File

@ -77,7 +77,7 @@ dulcie_prompt() {
printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}" printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"
# Open the new terminal in the same directory # 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}]" PS1="${reset_color}[${DULCIE_USER}@${DULCIE_HOST}$(scm_prompt_info)${reset_color} ${DULCIE_WORKINGDIR}]"
if [[ "${DULCIE_MULTILINE}" -eq "1" ]]; then if [[ "${DULCIE_MULTILINE}" -eq "1" ]]; then