upstream merge

pull/1931/head
matchi 2021-09-19 22:21:41 +02:00
parent 8797642112
commit 3286b4bbcd
69 changed files with 279 additions and 213 deletions

View File

@ -13,9 +13,11 @@ insert_final_newline = true
trim_trailing_whitespace = false trim_trailing_whitespace = false
[.git*] [.git*]
indent_size = tab
indent_style = tab indent_style = tab
[{**.*sh,test/run}] [{**.*sh,test/run}]
indent_size = tab
indent_style = tab indent_style = tab
shell_variant = bash shell_variant = bash

View File

@ -11,7 +11,7 @@ jobs:
bats-test: bats-test:
strategy: strategy:
matrix: matrix:
os: [ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, macos-10.15] os: [ubuntu-20.04, ubuntu-18.04, macos-10.15, macos-11.0]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}

View File

@ -1,6 +0,0 @@
# We use colors and not assigned
disable=SC2154
# Hard to fix
disable=SC2155
# shellcheck is wrong on some
disable=SC2034

View File

@ -114,6 +114,7 @@ for _bash_it_config_file in $CUSTOM; do
if [ -e "${_bash_it_config_file}" ]; then if [ -e "${_bash_it_config_file}" ]; then
filename=$(basename "${_bash_it_config_file}") filename=$(basename "${_bash_it_config_file}")
filename=${filename%*.bash} filename=${filename%*.bash}
# shellcheck disable=SC2034
BASH_IT_LOG_PREFIX="custom: $filename: " BASH_IT_LOG_PREFIX="custom: $filename: "
_log_debug "Loading custom file..." _log_debug "Loading custom file..."
# shellcheck disable=SC1090 # shellcheck disable=SC1090
@ -122,7 +123,7 @@ for _bash_it_config_file in $CUSTOM; do
done done
unset _bash_it_config_file unset _bash_it_config_file
if [[ "${PROMPT:-}" ]]; then if [[ -n "${PROMPT:-}" ]]; then
export PS1="\[""$PROMPT""\]" export PS1="\[""$PROMPT""\]"
fi fi

View File

@ -3,14 +3,14 @@ cite "about-completion"
about-completion "composer completion" about-completion "composer completion"
function __composer_completion() { function __composer_completion() {
local cur coms opts com local cur coms opts com words
COMPREPLY=() COMPREPLY=()
_get_comp_words_by_ref -n : cur words _get_comp_words_by_ref -n : cur words
# lookup for command # lookup for command
for word in "${words[@]:1}"; do for word in "${words[@]:1}"; do
if [[ $word != -* ]]; then if [[ "${word}" != -* ]]; then
com=$word com="${word}"
break break
fi fi
done done
@ -19,7 +19,7 @@ function __composer_completion() {
if [[ ${cur} == --* ]]; then if [[ ${cur} == --* ]]; then
opts="--help --quiet --verbose --version --ansi --no-ansi --no-interaction --profile --no-plugins --working-dir" opts="--help --quiet --verbose --version --ansi --no-ansi --no-interaction --profile --no-plugins --working-dir"
case "$com" in case "${com}" in
about) about)
opts="${opts} " opts="${opts} "
;; ;;
@ -109,18 +109,18 @@ function __composer_completion() {
# shellcheck disable=SC2207 # shellcheck disable=SC2207
COMPREPLY=($(compgen -W "${opts}" -- "${cur}")) COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
__ltrim_colon_completions "$cur" __ltrim_colon_completions "${cur}"
return 0 return 0
fi fi
# completing for a command # completing for a command
if [[ "$cur" == "$com" ]]; then if [[ "${cur}" == "${com}" ]]; then
coms="about archive browse clear-cache config create-project depends diagnose dump-autoload exec global help init install licenses list outdated prohibits remove require run-script search self-update show status suggests update validate" coms="about archive browse clear-cache config create-project depends diagnose dump-autoload exec global help init install licenses list outdated prohibits remove require run-script search self-update show status suggests update validate"
# shellcheck disable=SC2207 # shellcheck disable=SC2207
COMPREPLY=($(compgen -W "${coms}" -- "${cur}")) COMPREPLY=($(compgen -W "${coms}" -- "${cur}"))
__ltrim_colon_completions "$cur" __ltrim_colon_completions "${cur}"
return 0 return 0
fi fi

View File

@ -1,7 +1,9 @@
# shellcheck shell=bash # shellcheck shell=bash
__dart_completion() { __dart_completion() {
# shellcheck disable=SC2155
local prev=$(_get_pword) local prev=$(_get_pword)
# shellcheck disable=SC2155
local curr=$(_get_cword) local curr=$(_get_cword)
local HELP="--help -h" local HELP="--help -h"

View File

@ -1,7 +1,9 @@
# shellcheck shell=bash # shellcheck shell=bash
function __dmidecode_completion() { function __dmidecode_completion() {
# shellcheck disable=SC2155
local prev=$(_get_pword) local prev=$(_get_pword)
# shellcheck disable=SC2155
local curr=$(_get_cword) local curr=$(_get_cword)
case $prev in case $prev in

View File

@ -23,8 +23,8 @@
COMP_WORDBREAKS=$(echo "$COMP_WORDBREAKS" | sed -e 's/://g') COMP_WORDBREAKS=$(echo "$COMP_WORDBREAKS" | sed -e 's/://g')
__gradle-set-project-root-dir() { __gradle-set-project-root-dir() {
local dir=`pwd` local dir="${PWD}"
project_root_dir=`pwd` project_root_dir="${PWD}"
while [[ $dir != '/' ]]; do while [[ $dir != '/' ]]; do
if [[ -f "$dir/settings.gradle" || -f "$dir/gradlew" ]]; then if [[ -f "$dir/settings.gradle" || -f "$dir/gradlew" ]]; then
project_root_dir=$dir project_root_dir=$dir

View File

@ -227,7 +227,7 @@ EOF
((c++)) ((c++))
done done
if [ -z "$name" ]; then if [ -z "$name" ]; then
repo=$(basename "$(pwd)") repo="$(basename "${PWD}")"
fi fi
case "$prev" in case "$prev" in
-d|-h) -d|-h)

View File

@ -42,6 +42,7 @@ _KAC_is_file_newer_than() {
_KAC_regen_cache() { _KAC_regen_cache() {
local CACHE_NAME=$1 local CACHE_NAME=$1
local CACHE_PATH="$_KNIFE_AUTOCOMPLETE_CACHE_DIR/$CACHE_NAME" local CACHE_PATH="$_KNIFE_AUTOCOMPLETE_CACHE_DIR/$CACHE_NAME"
# shellcheck disable=SC2155
local TMP_FILE=$(mktemp "$_KAC_CACHE_TMP_DIR/$CACHE_NAME.XXXX") local TMP_FILE=$(mktemp "$_KAC_CACHE_TMP_DIR/$CACHE_NAME.XXXX")
shift 1 shift 1
# discard the temp file if it's empty AND the previous command didn't exit successfully, but still mark the cache as updated # discard the temp file if it's empty AND the previous command didn't exit successfully, but still mark the cache as updated
@ -66,6 +67,7 @@ _KAC_get_command_from_cache_name() {
# otherwise it waits for the cache to be generated # otherwise it waits for the cache to be generated
# in either case, it regenerates the cache, and sets the _KAC_CACHE_PATH env variable # in either case, it regenerates the cache, and sets the _KAC_CACHE_PATH env variable
# for obvious reason, do NOT call that in a sub-shell (in particular, no piping) # for obvious reason, do NOT call that in a sub-shell (in particular, no piping)
# shellcheck disable=SC2155
_KAC_get_and_regen_cache() { _KAC_get_and_regen_cache() {
# the cache name can't have space in it # the cache name can't have space in it
local CACHE_NAME=$(_KAC_get_cache_name_from_command "$@") local CACHE_NAME=$(_KAC_get_cache_name_from_command "$@")
@ -100,7 +102,7 @@ _KAC_clean_cache() {
# perform a cache cleaning when loading this file # perform a cache cleaning when loading this file
# On big systems this could baloon up to a 30 second run or more, so not enabling by default. # On big systems this could baloon up to a 30 second run or more, so not enabling by default.
[[ "${KNIFE_CACHE_CLEAN}" ]] && _KAC_clean_cache [[ -n "${KNIFE_CACHE_CLEAN}" ]] && _KAC_clean_cache
##################################### #####################################
### End of cache helper functions ### ### End of cache helper functions ###
@ -118,7 +120,7 @@ _KAC_get_current_base_command() {
local PREVIOUS="knife" local PREVIOUS="knife"
local I=1 local I=1
local CURRENT local CURRENT
while [ $I -le "$COMP_CWORD" ]; do while [[ "${I}" -le "${COMP_CWORD}" ]]; do
# command words are all lower-case # command words are all lower-case
echo "${COMP_WORDS[$I]}" | grep -E "^[a-z]+$" > /dev/null || break echo "${COMP_WORDS[$I]}" | grep -E "^[a-z]+$" > /dev/null || break
CURRENT="$PREVIOUS ${COMP_WORDS[$I]}" CURRENT="$PREVIOUS ${COMP_WORDS[$I]}"
@ -127,12 +129,13 @@ _KAC_get_current_base_command() {
I=$((I + 1)) I=$((I + 1))
done done
_KAC_CURRENT_COMMAND=$PREVIOUS _KAC_CURRENT_COMMAND=$PREVIOUS
[ $I -le "$COMP_CWORD" ] && _KAC_CURRENT_COMMAND_NB_WORDS=$I [[ "${I}" -le "${COMP_CWORD}" ]] && _KAC_CURRENT_COMMAND_NB_WORDS="${I}"
} }
# searches the position of the currently completed argument in the current base command # searches the position of the currently completed argument in the current base command
# (i.e. handles "plural" arguments such as knife cookbook upload cookbook1 cookbook2 and so on...) # (i.e. handles "plural" arguments such as knife cookbook upload cookbook1 cookbook2 and so on...)
# assumes the current base command is complete # assumes the current base command is complete
# shellcheck disable=SC2155
_KAC_get_current_arg_position() { _KAC_get_current_arg_position() {
local CURRENT_ARG_POS=$((_KAC_CURRENT_COMMAND_NB_WORDS + 1)) local CURRENT_ARG_POS=$((_KAC_CURRENT_COMMAND_NB_WORDS + 1))
local COMPLETE_COMMAND=$(grep -E "^$_KAC_CURRENT_COMMAND" "$_KAC_CACHE_PATH") local COMPLETE_COMMAND=$(grep -E "^$_KAC_CURRENT_COMMAND" "$_KAC_CACHE_PATH")
@ -150,10 +153,11 @@ _KAC_get_current_arg_position() {
_knife() { _knife() {
_KAC_get_and_regen_cache _KAC_knife_commands _KAC_get_and_regen_cache _KAC_knife_commands
local RAW_LIST ITEM REGEN_CMD ARG_POSITION local RAW_LIST ITEM REGEN_CMD ARG_POSITION
# shellcheck disable=SC2034
COMREPLY=() COMREPLY=()
# get correct command & arg pos # get correct command & arg pos
_KAC_get_current_base_command && ARG_POSITION=$(_KAC_get_current_arg_position) || ARG_POSITION=$((COMP_CWORD + 1)) _KAC_get_current_base_command && ARG_POSITION=$(_KAC_get_current_arg_position) || ARG_POSITION=$((COMP_CWORD + 1))
RAW_LIST=$(grep -E "^$_KAC_CURRENT_COMMAND" "$_KAC_CACHE_PATH" | cut -d ' ' -f $ARG_POSITION | uniq) RAW_LIST=$(grep -E "^${_KAC_CURRENT_COMMAND}" "${_KAC_CACHE_PATH}" | cut -d ' ' -f "${ARG_POSITION}" | uniq)
# we need to process that raw list a bit, most notably for placeholders # we need to process that raw list a bit, most notably for placeholders
# NOTE: I chose to explicitely fetch & cache _certain_ informations for the server (cookbooks & node names, etc) # NOTE: I chose to explicitely fetch & cache _certain_ informations for the server (cookbooks & node names, etc)

View File

@ -1,7 +1,9 @@
# shellcheck shell=bash # shellcheck shell=bash
__ngrok_completion() { __ngrok_completion() {
# shellcheck disable=SC2155
local prev=$(_get_pword) local prev=$(_get_pword)
# shellcheck disable=SC2155
local curr=$(_get_cword) local curr=$(_get_cword)
local BASE_NO_CONF="--log --log-format --log-level --help" local BASE_NO_CONF="--log --log-format --log-level --help"

View File

@ -1,7 +1,9 @@
# shellcheck shell=bash # shellcheck shell=bash
function __notify-send_completions() { function __notify-send_completions() {
# shellcheck disable=SC2155
local curr=$(_get_cword) local curr=$(_get_cword)
# shellcheck disable=SC2155
local prev=$(_get_pword) local prev=$(_get_pword)
case $prev in case $prev in

View File

@ -1,7 +1,9 @@
# shellcheck shell=bash # shellcheck shell=bash
_sdkman_complete() {
function _sdkman_complete() {
local CANDIDATES local CANDIDATES
local CANDIDATE_VERSIONS local CANDIDATE_VERSIONS
local SDKMAN_CANDIDATES_CSV="${SDKMAN_CANDIDATES_CSV:-}"
COMPREPLY=() COMPREPLY=()
@ -10,7 +12,7 @@ _sdkman_complete() {
elif [ "$COMP_CWORD" -eq 2 ]; then elif [ "$COMP_CWORD" -eq 2 ]; then
case "${COMP_WORDS[COMP_CWORD - 1]}" in case "${COMP_WORDS[COMP_CWORD - 1]}" in
"install" | "i" | "uninstall" | "rm" | "list" | "ls" | "use" | "u" | "default" | "d" | "home" | "h" | "current" | "c" | "upgrade" | "ug") "install" | "i" | "uninstall" | "rm" | "list" | "ls" | "use" | "u" | "default" | "d" | "home" | "h" | "current" | "c" | "upgrade" | "ug")
CANDIDATES=$(echo "${SDKMAN_CANDIDATES_CSV}" | tr ',' ' ') CANDIDATES="${SDKMAN_CANDIDATES_CSV//,/${IFS:0:1}}"
mapfile -t COMPREPLY < <(compgen -W "$CANDIDATES" -- "${COMP_WORDS[COMP_CWORD]}") mapfile -t COMPREPLY < <(compgen -W "$CANDIDATES" -- "${COMP_WORDS[COMP_CWORD]}")
;; ;;
"env") "env")
@ -46,17 +48,17 @@ _sdkman_complete() {
return 0 return 0
} }
_sdkman_candidate_local_versions() { function _sdkman_candidate_local_versions() {
CANDIDATE_VERSIONS=$(__sdkman_cleanup_local_versions "$1") CANDIDATE_VERSIONS=$(__sdkman_cleanup_local_versions "$1")
} }
_sdkman_candidate_all_versions() { function _sdkman_candidate_all_versions() {
candidate="$1" candidate="$1"
CANDIDATE_LOCAL_VERSIONS=$(__sdkman_cleanup_local_versions "$candidate") CANDIDATE_LOCAL_VERSIONS=$(__sdkman_cleanup_local_versions "$candidate")
if [ "$SDKMAN_OFFLINE_MODE" = "true" ]; then if [[ "${SDKMAN_OFFLINE_MODE:-false}" == "true" ]]; then
CANDIDATE_VERSIONS=$CANDIDATE_LOCAL_VERSIONS CANDIDATE_VERSIONS=$CANDIDATE_LOCAL_VERSIONS
else else
# sdkman has a specific output format for Java candidate since # sdkman has a specific output format for Java candidate since
@ -70,12 +72,12 @@ _sdkman_candidate_all_versions() {
# "+" - local version # "+" - local version
# "*" - installed # "*" - installed
# ">" - currently in use # ">" - currently in use
CANDIDATE_VERSIONS="$(echo "$CANDIDATE_ONLINE_VERSIONS $CANDIDATE_LOCAL_VERSIONS" | tr ' ' '\n' | grep -v -e '^[[:space:]|\*|\>|\+]*$' | sort | uniq -u) " CANDIDATE_VERSIONS="$(echo "$CANDIDATE_ONLINE_VERSIONS $CANDIDATE_LOCAL_VERSIONS" | tr ' ' '\n' | grep -v -e '^[[:space:]|\*|\>|\+]*$' | sort -u) "
fi fi
} }
__sdkman_cleanup_local_versions() { function __sdkman_cleanup_local_versions() {
__sdkman_build_version_csv "$1" | tr ',' ' ' __sdkman_build_version_csv "$1" | tr ',' ' '

View File

@ -1,7 +1,9 @@
# shellcheck shell=bash # shellcheck shell=bash
__vuejs_completion() { __vuejs_completion() {
# shellcheck disable=SC2155
local prev=$(_get_pword) local prev=$(_get_pword)
# shellcheck disable=SC2155
local curr=$(_get_cword) local curr=$(_get_cword)
case $prev in case $prev in

View File

@ -18,4 +18,4 @@ for file in "$@"; do
fi fi
done done
exit $exit_code exit "${exit_code:-0}"

View File

@ -18,4 +18,4 @@ for file in "$@"; do
fi fi
done done
exit $exit_code exit "${exit_code:-0}"

View File

@ -83,8 +83,8 @@ function _bash-it_check_for_backup() {
fi fi
echo -e "\033[0;33mBackup file already exists. Make sure to backup your .bashrc before running this installation.\033[0m" >&2 echo -e "\033[0;33mBackup file already exists. Make sure to backup your .bashrc before running this installation.\033[0m" >&2
if ! [[ $overwrite_backup ]]; then if [[ -z "${overwrite_backup}" ]]; then
while ! [[ $silent ]]; do while [[ -z "${silent}" ]]; do
read -e -n 1 -r -p "Would you like to overwrite the existing backup? This will delete your existing backup file ($HOME/$BACKUP_FILE) [y/N] " RESP read -e -n 1 -r -p "Would you like to overwrite the existing backup? This will delete your existing backup file ($HOME/$BACKUP_FILE) [y/N] " RESP
case $RESP in case $RESP in
[yY]) [yY])
@ -100,9 +100,9 @@ function _bash-it_check_for_backup() {
esac esac
done done
fi fi
if ! [[ $overwrite_backup ]]; then if [[ -z "${overwrite_backup}" ]]; then
echo -e "\033[91mInstallation aborted. Please come back soon!\033[m" echo -e "\033[91mInstallation aborted. Please come back soon!\033[m"
if [[ $silent ]]; then if [[ -n "${silent}" ]]; then
echo -e "\033[91mUse \"-f\" flag to force overwrite of backup.\033[m" echo -e "\033[91mUse \"-f\" flag to force overwrite of backup.\033[m"
fi fi
exit 1 exit 1
@ -114,8 +114,8 @@ function _bash-it_check_for_backup() {
function _bash-it_modify_config_files() { function _bash-it_modify_config_files() {
_bash-it_check_for_backup _bash-it_check_for_backup
if ! [[ $silent ]]; then if [[ -z "${silent}" ]]; then
while ! [[ $append_to_config ]]; do while [[ -z "${append_to_config}" ]]; do
read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash-it templates at the end? [y/N] " choice read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash-it templates at the end? [y/N] " choice
case $choice in case $choice in
[yY]) [yY])
@ -131,7 +131,7 @@ function _bash-it_modify_config_files() {
esac esac
done done
fi fi
if [[ $append_to_config ]]; then if [[ -n "${append_to_config}" ]]; then
# backup/append # backup/append
_bash-it_backup_append _bash-it_backup_append
else else
@ -174,17 +174,17 @@ done
shift $((OPTIND - 1)) shift $((OPTIND - 1))
if [[ $silent ]] && [[ $interactive ]]; then if [[ -n "${silent}" && -n "${interactive}" ]]; then
echo -e "\033[91mOptions --silent and --interactive are mutually exclusive. Please choose one or the other.\033[m" echo -e "\033[91mOptions --silent and --interactive are mutually exclusive. Please choose one or the other.\033[m"
exit 1 exit 1
fi fi
if [[ $no_modify_config ]] && [[ $append_to_config ]]; then if [[ -n "${no_modify_config}" && -n "${append_to_config}" ]]; then
echo -e "\033[91mOptions --no-modify-config and --append-to-config are mutually exclusive. Please choose one or the other.\033[m" echo -e "\033[91mOptions --no-modify-config and --append-to-config are mutually exclusive. Please choose one or the other.\033[m"
exit 1 exit 1
fi fi
BASH_IT="$(cd "$(dirname "$0")" && pwd)" BASH_IT="$(cd "${BASH_SOURCE%/*}" && pwd)"
case $OSTYPE in case $OSTYPE in
darwin*) darwin*)
@ -197,7 +197,7 @@ esac
BACKUP_FILE=$CONFIG_FILE.bak BACKUP_FILE=$CONFIG_FILE.bak
echo "Installing bash-it" echo "Installing bash-it"
if ! [[ $no_modify_config ]]; then if [[ -z "${no_modify_config}" ]]; then
_bash-it_modify_config_files _bash-it_modify_config_files
fi fi
@ -212,10 +212,10 @@ cite _about _param _example _group _author _version
# shellcheck source=./lib/helpers.bash # shellcheck source=./lib/helpers.bash
source "$BASH_IT/lib/helpers.bash" source "$BASH_IT/lib/helpers.bash"
if [[ $interactive ]] && ! [[ $silent ]]; then if [[ -n $interactive && -z "${silent}" ]]; then
for type in "aliases" "plugins" "completion"; do for type in "aliases" "plugins" "completion"; do
echo -e "\033[0;32mEnabling $type\033[0m" echo -e "\033[0;32mEnabling ${type}\033[0m"
_bash-it_load_some $type _bash-it_load_some "$type"
done done
else else
echo "" echo ""
@ -230,7 +230,7 @@ fi
echo "" echo ""
echo -e "\033[0;32mInstallation finished successfully! Enjoy bash-it!\033[0m" echo -e "\033[0;32mInstallation finished successfully! Enjoy bash-it!\033[0m"
# shellcheck disable=SC2086 # shellcheck disable=SC2086
echo -e "\033[0;32mTo start using it, open a new tab or 'source "$HOME/$CONFIG_FILE"'.\033[0m" echo -e "\033[0;32mTo start using it, open a new tab or 'source "~/$CONFIG_FILE"'.\033[0m"
echo "" echo ""
echo "To show the available aliases/completions/plugins, type one of the following:" echo "To show the available aliases/completions/plugins, type one of the following:"
echo " bash-it show aliases" echo " bash-it show aliases"

12
lib/helpers.bash 100755 → 100644
View File

@ -340,7 +340,7 @@ _bash-it-migrate() {
do do
for f in `sort <(compgen -G "${BASH_IT}/$file_type/enabled/*.bash")` for f in `sort <(compgen -G "${BASH_IT}/$file_type/enabled/*.bash")`
do do
typeset ff=$(basename $f) typeset ff="${f##*/}"
# Get the type of component from the extension # Get the type of component from the extension
typeset single_type=$(echo $ff | sed -e 's/.*\.\(.*\)\.bash/\1/g' | sed 's/aliases/alias/g') typeset single_type=$(echo $ff | sed -e 's/.*\.\(.*\)\.bash/\1/g' | sed 's/aliases/alias/g')
@ -449,7 +449,7 @@ _bash-it-restart() {
_about 'restarts the shell in order to fully reload it' _about 'restarts the shell in order to fully reload it'
_group 'lib' _group 'lib'
saved_pwd=$(pwd) saved_pwd="${PWD}"
case $OSTYPE in case $OSTYPE in
darwin*) darwin*)
@ -501,7 +501,7 @@ _bash-it-describe ()
do do
# Check for both the old format without the load priority, and the extended format with the priority # Check for both the old format without the load priority, and the extended format with the priority
declare enabled_files enabled_file declare enabled_files enabled_file
enabled_file=$(basename $f) enabled_file="${f##*/}"
enabled_files=$(sort <(compgen -G "${BASH_IT}/enabled/*$BASH_IT_LOAD_PRIORITY_SEPARATOR${enabled_file}") <(compgen -G "${BASH_IT}/$subdirectory/enabled/${enabled_file}") <(compgen -G "${BASH_IT}/$subdirectory/enabled/*$BASH_IT_LOAD_PRIORITY_SEPARATOR${enabled_file}") | wc -l) enabled_files=$(sort <(compgen -G "${BASH_IT}/enabled/*$BASH_IT_LOAD_PRIORITY_SEPARATOR${enabled_file}") <(compgen -G "${BASH_IT}/$subdirectory/enabled/${enabled_file}") <(compgen -G "${BASH_IT}/$subdirectory/enabled/*$BASH_IT_LOAD_PRIORITY_SEPARATOR${enabled_file}") | wc -l)
if [ $enabled_files -gt 0 ]; then if [ $enabled_files -gt 0 ]; then
@ -603,9 +603,9 @@ _disable-thing ()
printf '%s\n' "sorry, $file_entity does not appear to be an enabled $file_type." printf '%s\n' "sorry, $file_entity does not appear to be an enabled $file_type."
return return
fi fi
rm "${BASH_IT}/$subdirectory/enabled/$(basename $plugin)" rm "${BASH_IT}/$subdirectory/enabled/${plugin##*/}"
else else
rm "${BASH_IT}/enabled/$(basename $plugin_global)" rm "${BASH_IT}/enabled/${plugin_global##*/}"
fi fi
fi fi
@ -681,7 +681,7 @@ _enable-thing ()
return return
fi fi
to_enable=$(basename $to_enable) to_enable="${to_enable##*/}"
# Check for existence of the file using a wildcard, since we don't know which priority might have been used when enabling it. # Check for existence of the file using a wildcard, since we don't know which priority might have been used when enabling it.
typeset enabled_plugin=$(command ls "${BASH_IT}/$subdirectory/enabled/"{[0-9][0-9][0-9]$BASH_IT_LOAD_PRIORITY_SEPARATOR$to_enable,$to_enable} 2>/dev/null | head -1) typeset enabled_plugin=$(command ls "${BASH_IT}/$subdirectory/enabled/"{[0-9][0-9][0-9]$BASH_IT_LOAD_PRIORITY_SEPARATOR$to_enable,$to_enable} 2>/dev/null | head -1)
if [ ! -z "$enabled_plugin" ] ; then if [ ! -z "$enabled_plugin" ] ; then

0
lib/log.bash 100755 → 100644
View File

0
lib/search.bash 100755 → 100644
View File

8
lib/utilities.bash 100755 → 100644
View File

@ -71,12 +71,12 @@ _bash-it-grep() {
########################################################################### ###########################################################################
_bash-it-component-help() { _bash-it-component-help() {
local component=$(_bash-it-pluralize-component "${1}") local component="$(_bash-it-pluralize-component "${1}")"
local file=$(_bash-it-component-cache-file ${component}) local file="$(_bash-it-component-cache-file "${component}")"
if [[ ! -s "${file}" || -z $(find "${file}" -mmin -300) ]] ; then if [[ ! -s "${file}" || -z $(find "${file}" -mmin -300) ]] ; then
rm -f "${file}" 2>/dev/null rm -f "${file}" 2>/dev/null
local func="_bash-it-${component}" local func="_bash-it-${component}"
${func} | $(_bash-it-grep) -E ' \[' | cat > ${file} "${func}" | $(_bash-it-grep) -E ' \[' | cat > "${file}"
fi fi
cat "${file}" cat "${file}"
} }
@ -84,7 +84,7 @@ _bash-it-component-help() {
_bash-it-component-cache-file() { _bash-it-component-cache-file() {
local component=$(_bash-it-pluralize-component "${1}") local component=$(_bash-it-pluralize-component "${1}")
local file="${BASH_IT}/tmp/cache/${component}" local file="${BASH_IT}/tmp/cache/${component}"
[[ -f ${file} ]] || mkdir -p $(dirname ${file}) [[ -f "${file}" ]] || mkdir -p "${file%/*}"
printf "${file}" printf "${file}"
} }

View File

@ -19,6 +19,8 @@ about-plugin 'Automatic completion of aliases'
# Automatically add completion for all aliases to commands having completion functions # Automatically add completion for all aliases to commands having completion functions
function alias_completion { function alias_completion {
local namespace="alias_completion" local namespace="alias_completion"
local tmp_file completion_loader alias_name alias_tokens line completions
local alias_arg_words new_completion compl_func compl_wrapper
# parse function based completion definitions, where capture group 2 => function and 3 => trigger # parse function based completion definitions, where capture group 2 => function and 3 => trigger
local compl_regex='complete( +[^ ]+)* -F ([^ ]+) ("[^"]+"|[^ ]+)' local compl_regex='complete( +[^ ]+)* -F ([^ ]+) ("[^"]+"|[^ ]+)'
@ -26,28 +28,25 @@ function alias_completion {
local alias_regex="alias( -- | )([^=]+)='(\"[^\"]+\"|[^ ]+)(( +[^ ]+)*)'" local alias_regex="alias( -- | )([^=]+)='(\"[^\"]+\"|[^ ]+)(( +[^ ]+)*)'"
# create array of function completion triggers, keeping multi-word triggers together # create array of function completion triggers, keeping multi-word triggers together
eval "local completions=($(complete -p | sed -Ene "/$compl_regex/s//'\3'/p"))" eval "completions=($(complete -p | sed -Ene "/$compl_regex/s//'\3'/p"))"
((${#completions[@]} == 0)) && return 0 ((${#completions[@]} == 0)) && return 0
# create temporary file for wrapper functions and completions # create temporary file for wrapper functions and completions
local tmp_file
tmp_file="$(mktemp -t "${namespace}-${RANDOM}XXXXXX")" || return 1 tmp_file="$(mktemp -t "${namespace}-${RANDOM}XXXXXX")" || return 1
local completion_loader
completion_loader="$(complete -p -D 2> /dev/null | sed -Ene 's/.* -F ([^ ]*).*/\1/p')" completion_loader="$(complete -p -D 2> /dev/null | sed -Ene 's/.* -F ([^ ]*).*/\1/p')"
# read in "<alias> '<aliased command>' '<command args>'" lines from defined aliases # read in "<alias> '<aliased command>' '<command args>'" lines from defined aliases
local line
# shellcheck disable=SC2162
# some aliases do have backslashes that needs to be interpreted # some aliases do have backslashes that needs to be interpreted
# shellcheck disable=SC2162
while read line; do while read line; do
eval "local alias_tokens; alias_tokens=($line)" 2> /dev/null || continue # some alias arg patterns cause an eval parse error eval "alias_tokens=($line)" 2> /dev/null || continue # some alias arg patterns cause an eval parse error
local alias_name="${alias_tokens[0]}" alias_cmd="${alias_tokens[1]}" alias_args="${alias_tokens[2]# }" # shellcheck disable=SC2154 # see `eval` above
alias_name="${alias_tokens[0]}" alias_cmd="${alias_tokens[1]}" alias_args="${alias_tokens[2]# }"
# skip aliases to pipes, boolean control structures and other command lists # skip aliases to pipes, boolean control structures and other command lists
# (leveraging that eval errs out if $alias_args contains unquoted shell metacharacters) # (leveraging that eval errs out if $alias_args contains unquoted shell metacharacters)
eval "local alias_arg_words; alias_arg_words=($alias_args)" 2> /dev/null || continue eval "alias_arg_words=($alias_args)" 2> /dev/null || continue
# avoid expanding wildcards # avoid expanding wildcards
read -a alias_arg_words <<< "$alias_args" read -a alias_arg_words <<< "$alias_args"
@ -63,15 +62,15 @@ function alias_completion {
continue continue
fi fi
fi fi
local new_completion="$(complete -p "$alias_cmd" 2> /dev/null)" new_completion="$(complete -p "$alias_cmd" 2> /dev/null)"
# create a wrapper inserting the alias arguments if any # create a wrapper inserting the alias arguments if any
if [[ -n $alias_args ]]; then if [[ -n $alias_args ]]; then
local compl_func="${new_completion/#* -F /}" compl_func="${new_completion/#* -F /}"
compl_func="${compl_func%% *}" compl_func="${compl_func%% *}"
# avoid recursive call loops by ignoring our own functions # avoid recursive call loops by ignoring our own functions
if [[ "${compl_func#_$namespace::}" == "$compl_func" ]]; then if [[ "${compl_func#_"$namespace"::}" == "$compl_func" ]]; then
local compl_wrapper="_${namespace}::${alias_name}" compl_wrapper="_${namespace}::${alias_name}"
echo "function $compl_wrapper { echo "function $compl_wrapper {
local compl_word=\$2 local compl_word=\$2
local prec_word=\$3 local prec_word=\$3

View File

@ -9,7 +9,7 @@ precmd_return_notification() {
} }
preexec_return_notification() { preexec_return_notification() {
[ -z "${LAST_COMMAND_TIME}" ] && export LAST_COMMAND_TIME=$(date +%s) [[ -z "${LAST_COMMAND_TIME}" ]] && LAST_COMMAND_TIME=$(date +%s)
} }
precmd_functions+=(precmd_return_notification) precmd_functions+=(precmd_return_notification)

View File

@ -23,7 +23,7 @@ alias 8="pushd +8"
alias 9="pushd +9" alias 9="pushd +9"
# Clone this location # Clone this location
alias pc="pushd \$(pwd)" alias pc='pushd "${PWD}"'
# Push new location # Push new location
alias pu="pushd" alias pu="pushd"
@ -73,7 +73,7 @@ G () {
example '$ G ..' example '$ G ..'
group 'dirs' group 'dirs'
cd "${1:-$(pwd)}" ; cd "${1:-${PWD}}" ;
} }
S () { S () {
@ -86,7 +86,7 @@ S () {
sed "/$@/d" ~/.dirs > ~/.dirs1; sed "/$@/d" ~/.dirs > ~/.dirs1;
\mv ~/.dirs1 ~/.dirs; \mv ~/.dirs1 ~/.dirs;
echo "$@"=\"`pwd`\" >> ~/.dirs; echo "$@"=\""${PWD}"\" >> ~/.dirs;
source ~/.dirs ; source ~/.dirs ;
} }

View File

@ -2,12 +2,13 @@
cite about-plugin cite about-plugin
about-plugin 'git helper functions' about-plugin 'git helper functions'
# shellcheck disable=SC2016
function git_remote { function git_remote {
about "adds remote $GIT_HOSTING:$1 to current repo" about 'adds remote $GIT_HOSTING:$1 to current repo'
group "git" group "git"
echo "Running: git remote add origin ${GIT_HOSTING}:$1.git" echo "Running: git remote add origin ${GIT_HOSTING:?}:$1.git"
git remote add origin "$GIT_HOSTING:$1".git git remote add origin "${GIT_HOSTING}:${1}".git
} }
function git_first_push { function git_first_push {
@ -24,14 +25,14 @@ function git_pub() {
BRANCH=$(git rev-parse --abbrev-ref HEAD) BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo "Publishing ${BRANCH} to remote origin" echo "Publishing ${BRANCH} to remote origin"
git push -u origin "$BRANCH" git push -u origin "${BRANCH}"
} }
function git_revert() { function git_revert() {
about 'applies changes to HEAD that revert all changes after this commit' about 'applies changes to HEAD that revert all changes after this commit'
group 'git' group 'git'
git reset "$1" git reset "${1:?}"
git reset --soft "HEAD@{1}" git reset --soft "HEAD@{1}"
git commit -m "Revert to ${1}" git commit -m "Revert to ${1}"
git reset --hard git reset --hard
@ -49,9 +50,7 @@ function git_rollback() {
} }
function commit_exists() { function commit_exists() {
git rev-list --quiet "$1" if git rev-list --quiet "${1:?}"; then
status=$?
if [ $status -ne 0 ]; then
echo "Commit ${1} does not exist" echo "Commit ${1} does not exist"
kill -INT $$ kill -INT $$
fi fi
@ -61,7 +60,7 @@ function git_rollback() {
while true; do while true; do
# shellcheck disable=SC2162 # shellcheck disable=SC2162
read -p "Do you want to keep all changes from rolled back revisions in your working tree? [Y/N]" RESP read -p "Do you want to keep all changes from rolled back revisions in your working tree? [Y/N]" RESP
case $RESP in case "${RESP}" in
[yY]) [yY])
echo "Rolling back to commit ${1} with unstaged changes" echo "Rolling back to commit ${1} with unstaged changes"
@ -87,7 +86,7 @@ function git_rollback() {
while true; do while true; do
# shellcheck disable=SC2162 # shellcheck disable=SC2162
read -p "WARNING: This will change your history and move the current HEAD back to commit ${1}, continue? [Y/N]" RESP read -p "WARNING: This will change your history and move the current HEAD back to commit ${1}, continue? [Y/N]" RESP
case $RESP in case "${RESP}" in
[yY]) [yY])
keep_changes "$1" keep_changes "$1"
@ -134,8 +133,8 @@ function git_info() {
# print all remotes and thier details # print all remotes and thier details
for remote in $(git remote show); do for remote in $(git remote show); do
echo "$remote": echo "${remote}":
git remote show "$remote" git remote show "${remote}"
echo echo
done done
@ -172,32 +171,32 @@ function git_stats {
AUTHORS=$(git shortlog -sn --all | cut -f2 | cut -f1 -d' ') AUTHORS=$(git shortlog -sn --all | cut -f2 | cut -f1 -d' ')
LOGOPTS="" LOGOPTS=""
if [ "$1" == '-w' ]; then if [ "$1" == '-w' ]; then
LOGOPTS="$LOGOPTS -w" LOGOPTS="${LOGOPTS} -w"
shift shift
fi fi
if [ "$1" == '-M' ]; then if [ "$1" == '-M' ]; then
LOGOPTS="$LOGOPTS -M" LOGOPTS="${LOGOPTS} -M"
shift shift
fi fi
if [ "$1" == '-C' ]; then if [ "$1" == '-C' ]; then
LOGOPTS="$LOGOPTS -C --find-copies-harder" LOGOPTS="${LOGOPTS} -C --find-copies-harder"
shift shift
fi fi
for a in $AUTHORS; do for a in ${AUTHORS}; do
echo '-------------------' echo '-------------------'
echo "Statistics for: $a" echo "Statistics for: ${a}"
echo -n "Number of files changed: " echo -n "Number of files changed: "
# shellcheck disable=SC2086 # shellcheck disable=SC2086
git log $LOGOPTS --all --numstat --format="%n" --author="$a" | cut -f3 | sort -iu | wc -l git log ${LOGOPTS} --all --numstat --format="%n" --author="${a}" | cut -f3 | sort -iu | wc -l
echo -n "Number of lines added: " echo -n "Number of lines added: "
# shellcheck disable=SC2086 # shellcheck disable=SC2086
git log $LOGOPTS --all --numstat --format="%n" --author="$a" | cut -f1 | awk '{s+=$1} END {print s}' git log ${LOGOPTS} --all --numstat --format="%n" --author="${a}" | cut -f1 | awk '{s+=$1} END {print s}'
echo -n "Number of lines deleted: " echo -n "Number of lines deleted: "
# shellcheck disable=SC2086 # shellcheck disable=SC2086
git log $LOGOPTS --all --numstat --format="%n" --author="$a" | cut -f2 | awk '{s+=$1} END {print s}' git log ${LOGOPTS} --all --numstat --format="%n" --author="${a}" | cut -f2 | awk '{s+=$1} END {print s}'
echo -n "Number of merges: " echo -n "Number of merges: "
# shellcheck disable=SC2086 # shellcheck disable=SC2086
git log $LOGOPTS --all --merges --author="$a" | grep -c '^commit' git log ${LOGOPTS} --all --merges --author="${a}" | grep -c '^commit'
done done
else else
echo "you're currently not in a git repository" echo "you're currently not in a git repository"
@ -212,18 +211,16 @@ function gittowork() {
result=$(curl -L "https://www.gitignore.io/api/$1" 2> /dev/null) result=$(curl -L "https://www.gitignore.io/api/$1" 2> /dev/null)
if [[ $result =~ ERROR ]]; then if [[ "${result}" =~ ERROR ]]; then
echo "Query '$1' has no match. See a list of possible queries with 'gittowork list'" echo "Query '$1' has no match. See a list of possible queries with 'gittowork list'"
elif [[ $1 = list ]]; then elif [[ $1 == list ]]; then
echo "$result" echo "${result}"
else else
if [[ -f .gitignore ]]; then if [[ -f .gitignore ]]; then
result=$(echo "$result" | grep -v "# Created by http://www.gitignore.io") result=$(grep -v "# Created by http://www.gitignore.io" <<< "${result}")
echo ".gitignore already exists, appending..." echo ".gitignore already exists, appending..."
echo "$result" >> .gitignore
else
echo "$result" > .gitignore
fi fi
echo "${result}" >> .gitignore
fi fi
} }
@ -257,7 +254,7 @@ function gitignore-reload() {
fi fi
# Prompt user to commit or stash changes and exit # Prompt user to commit or stash changes and exit
if [ $err = 1 ]; then if [[ "${err}" == 1 ]]; then
echo >&2 "Please commit or stash them." echo >&2 "Please commit or stash them."
fi fi
@ -265,7 +262,7 @@ function gitignore-reload() {
# If we're here, then there are no uncommited or unstaged changes dangling around. # If we're here, then there are no uncommited or unstaged changes dangling around.
# Proceed to reload .gitignore # Proceed to reload .gitignore
if [ $err = 0 ]; then if [[ "${err}" == 0 ]]; then
# Remove all cached files # Remove all cached files
git rm -r --cached . git rm -r --cached .
@ -290,6 +287,7 @@ function git-changelog() {
return 1 return 1
fi fi
# shellcheck disable=SC2155
local NEXT=$(date +%F) local NEXT=$(date +%F)
if [[ "$2" == "md" ]]; then if [[ "$2" == "md" ]]; then
@ -298,9 +296,9 @@ function git-changelog() {
# shellcheck disable=SC2162 # shellcheck disable=SC2162
git log "$1" --no-merges --format="%cd" --date=short | sort -u -r | while read DATE; do git log "$1" --no-merges --format="%cd" --date=short | sort -u -r | while read DATE; do
echo echo
echo "### $DATE" echo "### ${DATE}"
git log --no-merges --format=" * (%h) %s by [%an](mailto:%ae)" --since="$DATE 00:00:00" --until="$DATE 24:00:00" git log --no-merges --format=" * (%h) %s by [%an](mailto:%ae)" --since="${DATE} 00:00:00" --until="${DATE} 24:00:00"
NEXT=$DATE NEXT=${DATE}
done done
else else
echo "CHANGELOG $1" echo "CHANGELOG $1"
@ -309,9 +307,10 @@ function git-changelog() {
# shellcheck disable=SC2162 # shellcheck disable=SC2162
git log "$1" --no-merges --format="%cd" --date=short | sort -u -r | while read DATE; do git log "$1" --no-merges --format="%cd" --date=short | sort -u -r | while read DATE; do
echo echo
echo [$DATE] echo "[${DATE}]"
git log --no-merges --format=" * (%h) %s by %an <%ae>" --since="$DATE 00:00:00" --until="$DATE 24:00:00" git log --no-merges --format=" * (%h) %s by %an <%ae>" --since="${DATE} 00:00:00" --until="${DATE} 24:00:00"
NEXT=$DATE # shellcheck disable=SC2034
NEXT=${DATE}
done done
fi fi
} }

View File

@ -30,7 +30,7 @@ eval "$(goenv init - bash)"
# If moving to a directory with a goenv version set, reload the shell # If moving to a directory with a goenv version set, reload the shell
# to ensure the shell environment matches expectations. # to ensure the shell environment matches expectations.
_bash-it-goenv-preexec() { _bash-it-goenv-preexec() {
export GOENV_OLD_VERSION="$(goenv version-name)" GOENV_OLD_VERSION="$(goenv version-name)"
} }
_bash-it-goenv-precmd() { _bash-it-goenv-precmd() {
if [[ -n $GOENV_OLD_VERSION ]] && [[ "$GOENV_OLD_VERSION" != "$(goenv version-name)" ]]; then if [[ -n $GOENV_OLD_VERSION ]] && [[ "$GOENV_OLD_VERSION" != "$(goenv version-name)" ]]; then

View File

@ -16,7 +16,7 @@ editpost() {
for site in ${SITES[@]} for site in ${SITES[@]}
do do
if [ "$(basename $site)" = "$1" ] if [ "${site##*/}" = "$1" ]
then then
SITE=$site SITE=$site
break break
@ -77,7 +77,7 @@ newpost() {
for site in ${SITES[@]} for site in ${SITES[@]}
do do
if [ "$(basename $site)" = "$1" ] if [ "${site##*/}" = "$1" ]
then then
SITE=$site SITE=$site
JEKYLL_FORMATTING=${MARKUPS[$loc]} JEKYLL_FORMATTING=${MARKUPS[$loc]}
@ -280,7 +280,7 @@ function testsite() {
for site in ${SITES[@]} for site in ${SITES[@]}
do do
if [ "$(basename $site)" = "$1" ] if [ "${site##*/}" = "$1" ]
then then
SITE=$site SITE=$site
break break
@ -312,7 +312,7 @@ function buildsite() {
for site in ${SITES[@]} for site in ${SITES[@]}
do do
if [ "$(basename $site)" = "$1" ] if [ "${site##*/}" = "$1" ]
then then
SITE=$site SITE=$site
break break
@ -347,7 +347,7 @@ function deploysite() {
for site in ${SITES[@]} for site in ${SITES[@]}
do do
if [ "$(basename $site)" = "$1" ] if [ "${site##*/}" = "$1" ]
then then
SITE=$site SITE=$site
REMOTE=${REMOTES[$loc]} REMOTE=${REMOTES[$loc]}

View File

@ -15,7 +15,7 @@ function time-machine-list-machines() {
local tmdest="$(time-machine-destination)/Backups.backupdb" local tmdest="$(time-machine-destination)/Backups.backupdb"
find "$tmdest" -maxdepth 1 -mindepth 1 -type d | grep -v "/\." | while read line ; do find "$tmdest" -maxdepth 1 -mindepth 1 -type d | grep -v "/\." | while read line ; do
echo "$(basename "$line")" echo "${line##*/}"
done done
} }

View File

@ -14,8 +14,8 @@ function mkvenv {
about 'create a new virtualenv for this directory' about 'create a new virtualenv for this directory'
group 'virtualenv' group 'virtualenv'
cwd=`basename \`pwd\`` local cwd="${PWD##*/}"
mkvirtualenv --distribute $cwd mkvirtualenv --distribute "$cwd"
} }
@ -23,19 +23,21 @@ function mkvbranch {
about 'create a new virtualenv for the current branch' about 'create a new virtualenv for the current branch'
group 'virtualenv' group 'virtualenv'
mkvirtualenv --distribute "$(basename `pwd`)@$SCM_BRANCH" local cwd="${PWD##*/}"
mkvirtualenv --distribute "${cwd}@${SCM_BRANCH}"
} }
function wovbranch { function wovbranch {
about 'sets workon branch' about 'sets workon branch'
group 'virtualenv' group 'virtualenv'
workon "$(basename `pwd`)@$SCM_BRANCH" local cwd="${PWD##*/}"
workon "${cwd}@${SCM_BRANCH}"
} }
function wovenv { function wovenv {
about 'works on the virtualenv for this directory' about 'works on the virtualenv for this directory'
group 'virtualenv' group 'virtualenv'
workon "$(basename `pwd`)" workon "${PWD##*/}"
} }

View File

@ -3,29 +3,37 @@ cite about-plugin
about-plugin 'automatically set your xterm title with host and location info' about-plugin 'automatically set your xterm title with host and location info'
_short-dirname() { _short-dirname() {
local dir_name=$(dirs +0) local dir_name="${PWD/~/\~}"
[ "$SHORT_TERM_LINE" = true ] && [ "${#dir_name}" -gt 8 ] && echo "${dir_name##*/}" || echo "${dir_name}" if [[ "${SHORT_TERM_LINE:-}" == true && "${#dir_name}" -gt 8 ]]; then
echo "${dir_name##*/}"
else
echo "${dir_name}"
fi
} }
_short-command() { _short-command() {
local input_command="$*" local input_command="$*"
[ "$SHORT_TERM_LINE" = true ] && [ "${#input_command}" -gt 8 ] && echo "${input_command%% *}" || echo "${input_command}" if [[ "${SHORT_TERM_LINE:-}" == true && "${#input_command}" -gt 8 ]]; then
echo "${input_command%% *}"
else
echo "${input_command}"
fi
} }
set_xterm_title() { set_xterm_title() {
local title="$1" local title="${1:-}"
echo -ne "\033]0;$title\007" echo -ne "\033]0;${title}\007"
} }
precmd_xterm_title() { precmd_xterm_title() {
set_xterm_title "${SHORT_USER:-${USER}}@${SHORT_HOSTNAME:-${HOSTNAME}} $(_short-dirname) $PROMPT_CHAR" set_xterm_title "${SHORT_USER:-${USER}}@${SHORT_HOSTNAME:-${HOSTNAME}} $(_short-dirname) ${PROMPT_CHAR:-\$}"
} }
preexec_xterm_title() { preexec_xterm_title() {
set_xterm_title "$(_short-command "${1}") {$(_short-dirname)} (${SHORT_USER:-${USER}}@${SHORT_HOSTNAME:-${HOSTNAME}})" set_xterm_title "$(_short-command "${1:-}") {$(_short-dirname)} (${SHORT_USER:-${USER}}@${SHORT_HOSTNAME:-${HOSTNAME}})"
} }
case "$TERM" in case "${TERM:-dumb}" in
xterm* | rxvt*) xterm* | rxvt*)
precmd_functions+=(precmd_xterm_title) precmd_functions+=(precmd_xterm_title)
preexec_functions+=(preexec_xterm_title) preexec_functions+=(preexec_xterm_title)

View File

@ -11,7 +11,7 @@ autoenv_init()
typeset target home _file typeset target home _file
typeset -a _files typeset -a _files
target=$1 target=$1
home="$(dirname "$HOME")" home="${HOME%/*}"
_files=( $( _files=( $(
while [[ "$PWD" != "/" && "$PWD" != "$home" ]] while [[ "$PWD" != "/" && "$PWD" != "$home" ]]

3
scripts/reloader.bash 100644 → 100755
View File

@ -5,6 +5,7 @@ function _set-prefix-based-on-path()
{ {
filename=$(_bash-it-get-component-name-from-path "$1") filename=$(_bash-it-get-component-name-from-path "$1")
extension=$(_bash-it-get-component-type-from-path "$1") extension=$(_bash-it-get-component-type-from-path "$1")
# shellcheck disable=SC2034
BASH_IT_LOG_PREFIX="$extension: $filename: " BASH_IT_LOG_PREFIX="$extension: $filename: "
} }
@ -15,7 +16,7 @@ if [[ "$1" != "skip" ]] && [[ -d "$BASH_IT/enabled" ]]; then
alias|completion|plugin) alias|completion|plugin)
_bash_it_config_type=$1 _bash_it_config_type=$1
_log_debug "Loading enabled $1 components..." ;; _log_debug "Loading enabled $1 components..." ;;
*|'') ''|*)
_log_debug "Loading all enabled components..." ;; _log_debug "Loading all enabled components..." ;;
esac esac

0
test/fixtures/svn/broken/xcrun vendored 100755
View File

View File

View File

@ -40,7 +40,7 @@ load ../../plugins/available/base.plugin
mkcd "${dir_name}" mkcd "${dir_name}"
assert_success assert_success
assert_dir_exist "${BASH_IT_ROOT}/${dir_name}" assert_dir_exist "${BASH_IT_ROOT}/${dir_name}"
assert_equal $(pwd) "${BASH_IT_ROOT}/${dir_name}" assert_equal "${PWD}" "${BASH_IT_ROOT}/${dir_name}"
} }
@test 'plugins base: lsgrep()' { @test 'plugins base: lsgrep()' {

View File

@ -6,7 +6,7 @@ git submodule init && git submodule update
if [ -z "${BASH_IT}" ]; then if [ -z "${BASH_IT}" ]; then
declare BASH_IT declare BASH_IT
BASH_IT=$(cd ${test_directory} && dirname "$(pwd)") BASH_IT="$(cd "${test_directory}" && dirname "${PWD}")"
export BASH_IT export BASH_IT
fi fi

View File

@ -7,7 +7,6 @@ load ../../lib/log
cite _about _param _example _group _author _version cite _about _param _example _group _author _version
load ../../lib/helpers load ../../lib/helpers
load ../../themes/base.theme
function local_setup { function local_setup {
setup_test_fixture setup_test_fixture
@ -23,6 +22,8 @@ function local_setup {
fi fi
export OLD_PATH="$PATH" export OLD_PATH="$PATH"
load ../../themes/base.theme
} }
function local_teardown { function local_teardown {
@ -56,8 +57,8 @@ function setup_svn_path {
setup_svn_path "$BASH_IT/test/fixtures/svn/working" setup_svn_path "$BASH_IT/test/fixtures/svn/working"
# Load the base theme again so that the working SVN script is detected # Init the base theme again so that the working SVN script is detected
load ../../themes/base.theme _bash_it_appearance_scm_init
scm scm
# Make sure that the SVN command is used # Make sure that the SVN command is used
@ -73,8 +74,8 @@ function setup_svn_path {
setup_svn_path "$BASH_IT/test/fixtures/svn/working" setup_svn_path "$BASH_IT/test/fixtures/svn/working"
# Load the base theme again so that the working SVN script is detected # init the base theme again so that the working SVN script is detected
load ../../themes/base.theme _bash_it_appearance_scm_init
scm scm
# Make sure that the SVN command is used # Make sure that the SVN command is used
@ -89,8 +90,8 @@ function setup_svn_path {
setup_svn_path "$BASH_IT/test/fixtures/svn/working" setup_svn_path "$BASH_IT/test/fixtures/svn/working"
# Load the base theme again so that the working SVN script is detected # Init the base theme again so that the working SVN script is detected
load ../../themes/base.theme _bash_it_appearance_scm_init
scm scm
# Make sure that no SVN command is used # Make sure that no SVN command is used
@ -103,8 +104,8 @@ function setup_svn_path {
setup_svn_path "$BASH_IT/test/fixtures/svn/broken" setup_svn_path "$BASH_IT/test/fixtures/svn/broken"
# Load the base theme again so that the broken SVN script is detected # Init the base theme again so that the broken SVN script is detected
load ../../themes/base.theme _bash_it_appearance_scm_init
scm scm
# Make sure that no SVN command is not used # Make sure that no SVN command is not used
@ -120,8 +121,8 @@ function setup_svn_path {
setup_svn_path "$BASH_IT/test/fixtures/svn/broken" setup_svn_path "$BASH_IT/test/fixtures/svn/broken"
# Load the base theme again so that the broken SVN script is detected # Init the base theme again so that the broken SVN script is detected
load ../../themes/base.theme _bash_it_appearance_scm_init
scm scm
# Make sure that no SVN command is used # Make sure that no SVN command is used

View File

@ -1,4 +1,7 @@
# shellcheck shell=bash # shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# shellcheck disable=SC2154 #TODO: fix these all.
SCM_THEME_PROMPT_DIRTY=" ${red}" SCM_THEME_PROMPT_DIRTY=" ${red}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}" SCM_THEME_PROMPT_CLEAN=" ${bold_green}"
SCM_THEME_PROMPT_PREFIX=" |" SCM_THEME_PROMPT_PREFIX=" |"
@ -11,7 +14,7 @@ GIT_THEME_PROMPT_SUFFIX="${green}|"
# Nicely formatted terminal prompt # Nicely formatted terminal prompt
function prompt_command() { function prompt_command() {
export PS1="\n${bold_black}[${blue}\@${bold_black}]-${bold_black}[${green}\u${yellow}@${green}\h${bold_black}]-${bold_black}[${purple}\w${bold_black}]-$(scm_prompt_info)\n${reset_color}\$ " PS1="\n${bold_black}[${blue}\@${bold_black}]-${bold_black}[${green}\u${yellow}@${green}\h${bold_black}]-${bold_black}[${purple}\w${bold_black}]-$(scm_prompt_info)\n${reset_color}\$ "
} }
safe_append_prompt_command prompt_command safe_append_prompt_command prompt_command

View File

@ -1,4 +1,5 @@
# shellcheck shell=bash # shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# vim: ft=bash ts=2 sw=2 sts=2 # vim: ft=bash ts=2 sw=2 sts=2
# #
# agnoster's Theme - https://gist.github.com/3712874 # agnoster's Theme - https://gist.github.com/3712874
@ -220,7 +221,7 @@ prompt_virtualenv() {
# Context: user@hostname (who am I and where am I) # Context: user@hostname (who am I and where am I)
prompt_context() { prompt_context() {
local user=$(whoami) local user="${USER:-${LOGNAME:?}}"
if [[ $user != "$DEFAULT_USER" || -n $SSH_CLIENT ]]; then if [[ $user != "$DEFAULT_USER" || -n $SSH_CLIENT ]]; then
prompt_segment black default "$user@\h" prompt_segment black default "$user@\h"

View File

@ -1,4 +1,6 @@
# shellcheck shell=bash # shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# shellcheck disable=SC2154 #TODO: fix these all.
# Atomic Bash Prompt for Bash-it # Atomic Bash Prompt for Bash-it
# By lfelipe base on the theme brainy of MunifTanjim # By lfelipe base on the theme brainy of MunifTanjim

View File

@ -1,4 +1,6 @@
# shellcheck shell=bash # shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# shellcheck disable=SC2154 #TODO: fix these all.
SCM_THEME_PROMPT_DIRTY=" ${red}" SCM_THEME_PROMPT_DIRTY=" ${red}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}" SCM_THEME_PROMPT_CLEAN=" ${bold_green}"

View File

@ -1,4 +1,6 @@
# shellcheck shell=bash # shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# shellcheck disable=SC2154 #TODO: fix these all.
# Theme custom glyphs # Theme custom glyphs
SCM_GIT_CHAR_GITLAB=${BARBUK_GITLAB_CHAR:=' '} SCM_GIT_CHAR_GITLAB=${BARBUK_GITLAB_CHAR:=' '}

View File

@ -1,4 +1,5 @@
# shellcheck shell=bash # shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
CLOCK_CHAR_THEME_PROMPT_PREFIX='' CLOCK_CHAR_THEME_PROMPT_PREFIX=''
CLOCK_CHAR_THEME_PROMPT_SUFFIX='' CLOCK_CHAR_THEME_PROMPT_SUFFIX=''
@ -85,6 +86,7 @@ RBENV_THEME_PROMPT_SUFFIX='|'
RBFU_THEME_PROMPT_PREFIX=' |' RBFU_THEME_PROMPT_PREFIX=' |'
RBFU_THEME_PROMPT_SUFFIX='|' RBFU_THEME_PROMPT_SUFFIX='|'
<<<<<<< HEAD
GIT_EXE=$(command -v git 2> /dev/null || true) GIT_EXE=$(command -v git 2> /dev/null || true)
P4_EXE=$(command -v p4 2> /dev/null || true) P4_EXE=$(command -v p4 2> /dev/null || true)
HG_EXE=$(command -v hg 2> /dev/null || true) HG_EXE=$(command -v hg 2> /dev/null || true)
@ -96,38 +98,58 @@ if [[ -x "$SVN_EXE" ]]; then
if ! "$SVN_EXE" --version > /dev/null 2>&1; then if ! "$SVN_EXE" --version > /dev/null 2>&1; then
# Unset the SVN exe variable so that SVN commands are avoided. # Unset the SVN exe variable so that SVN commands are avoided.
SVN_EXE="" SVN_EXE=""
=======
: "${GIT_EXE:=$SCM_GIT}"
: "${P4_EXE:=$SCM_P4}"
: "${HG_EXE:=$SCM_HG}"
: "${SVN_EXE:=$SCM_SVN}"
function _bash_it_appearance_scm_init() {
GIT_EXE="$(type -P $SCM_GIT || true)"
P4_EXE="$(type -P $SCM_P4 || true)"
HG_EXE="$(type -P $SCM_HG || true)"
SVN_EXE="$(type -P $SCM_SVN || true)"
# Check for broken SVN exe that is caused by some versions of Xcode.
# See https://github.com/Bash-it/bash-it/issues/1612 for more details.
if [[ -x "$SVN_EXE" && -x "${SVN_EXE%/*}/xcrun" ]]; then
if ! "$SVN_EXE" --version > /dev/null 2>&1; then
# Unset the SVN exe variable so that SVN commands are avoided.
SVN_EXE=""
fi fi
>>>>>>> 77e9404c7dafb5c29e887e5c71332cb161014e82
fi fi
}
_bash_it_appearance_scm_init
function scm { function scm {
if [[ "$SCM_CHECK" = false ]]; then if [[ "$SCM_CHECK" = false ]]; then
SCM=$SCM_NONE SCM=$SCM_NONE
elif [[ -f .git/HEAD ]] && [[ -x "$GIT_EXE" ]]; then elif [[ -f .git/HEAD ]] && [[ -x "$GIT_EXE" ]]; then
SCM=$SCM_GIT SCM=$SCM_GIT
elif [[ -x "$GIT_EXE" ]] && [[ -n "$(git rev-parse --is-inside-work-tree 2> /dev/null)" ]]; then
SCM=$SCM_GIT
elif [[ -x "$P4_EXE" ]] && [[ -n "$(p4 set P4CLIENT 2> /dev/null)" ]]; then
SCM=$SCM_P4
elif [[ -d .hg ]] && [[ -x "$HG_EXE" ]]; then elif [[ -d .hg ]] && [[ -x "$HG_EXE" ]]; then
SCM=$SCM_HG SCM=$SCM_HG
elif [[ -x "$HG_EXE" ]] && [[ -n "$(hg root 2> /dev/null)" ]]; then
SCM=$SCM_HG
elif [[ -d .svn ]] && [[ -x "$SVN_EXE" ]]; then elif [[ -d .svn ]] && [[ -x "$SVN_EXE" ]]; then
SCM=$SCM_SVN SCM=$SCM_SVN
elif [[ -x "$GIT_EXE" ]] && [[ -n "$(git rev-parse --is-inside-work-tree 2> /dev/null)" ]]; then
SCM=$SCM_GIT
elif [[ -x "$HG_EXE" ]] && [[ -n "$(hg root 2> /dev/null)" ]]; then
SCM=$SCM_HG
elif [[ -x "$SVN_EXE" ]] && [[ -n "$(svn info --show-item wc-root 2> /dev/null)" ]]; then elif [[ -x "$SVN_EXE" ]] && [[ -n "$(svn info --show-item wc-root 2> /dev/null)" ]]; then
SCM=$SCM_SVN SCM=$SCM_SVN
elif [[ -x "$P4_EXE" ]] && [[ -n "$(p4 set P4CLIENT 2> /dev/null)" ]]; then
SCM=$SCM_P4
else else
SCM=$SCM_NONE SCM=$SCM_NONE
fi fi
} }
scm_prompt() { scm_prompt() {
local CHAR=$(scm_char) local CHAR
CHAR="$(scm_char)"
local format=${SCM_PROMPT_FORMAT:-'[%s%s]'} local format=${SCM_PROMPT_FORMAT:-'[%s%s]'}
if [[ $CHAR = "$SCM_NONE_CHAR" ]]; then if [[ "${CHAR}" != "$SCM_NONE_CHAR" ]]; then
return
else
# shellcheck disable=2059 # shellcheck disable=2059
printf "$format\n" "$CHAR" "$(scm_prompt_info)" printf "$format\n" "$CHAR" "$(scm_prompt_info)"
fi fi
@ -344,15 +366,15 @@ function svn_prompt_vars {
# - .hg is located in ~/Projects/Foo/.hg # - .hg is located in ~/Projects/Foo/.hg
# - get_hg_root starts at ~/Projects/Foo/Bar and sees that there is no .hg directory, so then it goes into ~/Projects/Foo # - get_hg_root starts at ~/Projects/Foo/Bar and sees that there is no .hg directory, so then it goes into ~/Projects/Foo
function get_hg_root { function get_hg_root {
local CURRENT_DIR=$(pwd) local CURRENT_DIR="${PWD}"
while [ "$CURRENT_DIR" != "/" ]; do while [[ "${CURRENT_DIR:-/}" != "/" ]]; do
if [ -d "$CURRENT_DIR/.hg" ]; then if [[ -d "$CURRENT_DIR/.hg" ]]; then
echo "$CURRENT_DIR/.hg" echo "$CURRENT_DIR/.hg"
return return
fi fi
CURRENT_DIR=$(dirname "$CURRENT_DIR") CURRENT_DIR="${CURRENT_DIR%/*}"
done done
} }
@ -544,7 +566,7 @@ function prompt_char {
function battery_char { function battery_char {
if [[ "${THEME_BATTERY_PERCENTAGE_CHECK}" = true ]]; then if [[ "${THEME_BATTERY_PERCENTAGE_CHECK}" = true ]]; then
echo -e "${bold_red}$(battery_percentage)%" echo -e "${bold_red:-}$(battery_percentage)%"
fi fi
} }
@ -586,7 +608,7 @@ function __check_precmd_conflict() {
function safe_append_prompt_command { function safe_append_prompt_command {
local prompt_re local prompt_re
if [ "${__bp_imported}" == "defined" ]; then if [ "${__bp_imported:-missing}" == "defined" ]; then
# We are using bash-preexec # We are using bash-preexec
if ! __check_precmd_conflict "${1}"; then if ! __check_precmd_conflict "${1}"; then
precmd_functions+=("${1}") precmd_functions+=("${1}")
@ -601,7 +623,7 @@ function safe_append_prompt_command {
prompt_re="\<${1}\>" prompt_re="\<${1}\>"
fi fi
if [[ ${PROMPT_COMMAND} =~ ${prompt_re} ]]; then if [[ ${PROMPT_COMMAND[*]:-} =~ ${prompt_re} ]]; then
return return
elif [[ -z ${PROMPT_COMMAND} ]]; then elif [[ -z ${PROMPT_COMMAND} ]]; then
PROMPT_COMMAND="${1}" PROMPT_COMMAND="${1}"

View File

@ -1,4 +1,6 @@
# shellcheck shell=bash # shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# shellcheck disable=SC2154 #TODO: fix these all.
# Detect whether a reboot is required # Detect whether a reboot is required
function show_reboot_required() { function show_reboot_required() {

View File

@ -1,4 +1,6 @@
# shellcheck shell=bash # shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# shellcheck disable=SC2154 #TODO: fix these all.
SCM_THEME_PROMPT_PREFIX=" ${yellow}" SCM_THEME_PROMPT_PREFIX=" ${yellow}"
SCM_THEME_PROMPT_SUFFIX="${reset_color}" SCM_THEME_PROMPT_SUFFIX="${reset_color}"

View File

@ -1,4 +1,6 @@
# shellcheck shell=bash # shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# shellcheck disable=SC2154 #TODO: fix these all.
SCM_THEME_PROMPT_DIRTY=" ${red}" SCM_THEME_PROMPT_DIRTY=" ${red}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}" SCM_THEME_PROMPT_CLEAN=" ${bold_green}"

View File

@ -1,4 +1,6 @@
# shellcheck shell=bash # shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# shellcheck disable=SC2154 #TODO: fix these all.
SCM_THEME_PROMPT_DIRTY=" ${red}" SCM_THEME_PROMPT_DIRTY=" ${red}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}" SCM_THEME_PROMPT_CLEAN=" ${bold_green}"

View File

@ -1,4 +1,6 @@
# shellcheck shell=bash # shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# shellcheck disable=SC2154 #TODO: fix these all.
# Brainy Bash Prompt for Bash-it # Brainy Bash Prompt for Bash-it
# by MunifTanjim # by MunifTanjim

View File

@ -1,4 +1,6 @@
# shellcheck shell=bash # shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# shellcheck disable=SC2154 #TODO: fix these all.
SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_PREFIX=""
SCM_THEME_PROMPT_SUFFIX="" SCM_THEME_PROMPT_SUFFIX=""

View File

@ -1,4 +1,6 @@
# shellcheck shell=bash # shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# shellcheck disable=SC2154 #TODO: fix these all.
function prompt_command() { function prompt_command() {
PS1="${green}\u@\h $(clock_prompt) ${reset_color}${white}\w${reset_color}$(scm_prompt_info)${blue}${bold_blue} ${reset_color} ${normal}" PS1="${green}\u@\h $(clock_prompt) ${reset_color}${white}\w${reset_color}$(scm_prompt_info)${blue}${bold_blue} ${reset_color} ${normal}"

View File

@ -1,3 +1,5 @@
# shellcheck shell=bash
SCM_THEME_PROMPT_PREFIX=${SCM_THEME_PROMPT_SUFFIX} SCM_THEME_PROMPT_PREFIX=${SCM_THEME_PROMPT_SUFFIX}
SCM_THEME_PROMPT_DIRTY="${bold_red}${normal}" SCM_THEME_PROMPT_DIRTY="${bold_red}${normal}"
SCM_THEME_PROMPT_CLEAN="${bold_green}${normal}" SCM_THEME_PROMPT_CLEAN="${bold_green}${normal}"
@ -19,11 +21,5 @@ prompt() {
PS1="$(user_host_path_prompt)$(virtualenv_prompt)$(scm_prompt) $(mark_prompt) " PS1="$(user_host_path_prompt)$(virtualenv_prompt)$(scm_prompt) $(mark_prompt) "
} }
share_history() { safe_append_prompt_command '_save-and-reload-history 1'
history -a
history -c
history -r
}
safe_append_prompt_command share_history
safe_append_prompt_command prompt safe_append_prompt_command prompt

View File

@ -1,4 +1,6 @@
#!/usr/bin/env bash # shellcheck shell=bash
# shellcheck disable=SC2005
# shellcheck disable=SC2034
function __ { function __ {
echo "$@" echo "$@"

0
themes/demula/demula.theme.bash 100755 → 100644
View File

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash # shellcheck shell=bash
SCM_THEME_PROMPT_DIRTY='' SCM_THEME_PROMPT_DIRTY=''
SCM_THEME_PROMPT_CLEAN='' SCM_THEME_PROMPT_CLEAN=''
@ -30,9 +30,7 @@ fi
function prompt_setter() { function prompt_setter() {
# Save history # Save history
history -a _save-and-reload-history 1
history -c
history -r
PS1=" PS1="
$(clock_prompt) $(scm_char) [${THEME_PROMPT_HOST_COLOR}\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)$(ruby_version_prompt)\w $(clock_prompt) $(scm_char) [${THEME_PROMPT_HOST_COLOR}\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)$(ruby_version_prompt)\w
$(scm_prompt)$reset_color $ " $(scm_prompt)$reset_color $ "

View File

@ -1,12 +1,10 @@
#!/usr/bin/env bash # shellcheck shell=bash
source "$BASH_IT/themes/doubletime/doubletime.theme.bash" source "$BASH_IT/themes/doubletime/doubletime.theme.bash"
function prompt_setter() { function prompt_setter() {
# Save history # Save history
history -a _save-and-reload-history 1
history -c
history -r
PS1=" PS1="
$(clock_prompt) $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)$(ruby_version_prompt) $(clock_prompt) $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)$(ruby_version_prompt)
\w \w

View File

@ -1,12 +1,10 @@
#!/usr/bin/env bash # shellcheck shell=bash
source "$BASH_IT/themes/doubletime/doubletime.theme.bash" source "$BASH_IT/themes/doubletime/doubletime.theme.bash"
function prompt_setter() { function prompt_setter() {
# Save history # Save history
history -a _save-and-reload-history 1
history -c
history -r
PS1=" PS1="
$(clock_prompt) $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt) $(clock_prompt) $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)
\w \w

View File

@ -1,4 +1,6 @@
# shellcheck shell=bash # shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# shellcheck disable=SC2154 #TODO: fix these all.
SCM_THEME_PROMPT_PREFIX="${bold_green}[ ${normal}" SCM_THEME_PROMPT_PREFIX="${bold_green}[ ${normal}"
SCM_THEME_PROMPT_SUFFIX="${bold_green} ] " SCM_THEME_PROMPT_SUFFIX="${bold_green} ] "

View File

View File

@ -1,4 +1,6 @@
# shellcheck shell=bash # shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# shellcheck disable=SC2154 #TODO: fix these all.
SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_PREFIX=""
SCM_THEME_PROMPT_SUFFIX="" SCM_THEME_PROMPT_SUFFIX=""

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash # shellcheck shell=bash
# Two line prompt showing the following information: # Two line prompt showing the following information:
# (time) SCM [username@hostname] pwd (SCM branch SCM status) # (time) SCM [username@hostname] pwd (SCM branch SCM status)
@ -29,9 +29,7 @@ prompt_setter() {
else PROMPT_END=$PROMPT_END_DIRTY else PROMPT_END=$PROMPT_END_DIRTY
fi fi
# Save history # Save history
history -a _save-and-reload-history 1
history -c
history -r
PS1="($(clock_prompt)) $(scm_char) [${blue}\u${reset_color}@${green}\H${reset_color}] ${yellow}\w${reset_color}$(scm_prompt_info) ${reset_color}\n$(prompt_end) " PS1="($(clock_prompt)) $(scm_char) [${blue}\u${reset_color}@${green}\H${reset_color}] ${yellow}\w${reset_color}$(scm_prompt_info) ${reset_color}\n$(prompt_end) "
PS2='> ' PS2='> '
PS4='+ ' PS4='+ '

View File

@ -1,4 +1,4 @@
#!/bin/bash # shellcheck shell=bash
# Two line prompt showing the following information: # Two line prompt showing the following information:
# (time) SCM [username@hostname] pwd (SCM branch SCM status) # (time) SCM [username@hostname] pwd (SCM branch SCM status)
@ -96,9 +96,7 @@ prompt_setter() {
else PROMPT_END=$PROMPT_END_DIRTY else PROMPT_END=$PROMPT_END_DIRTY
fi fi
# Save history # Save history
history -a _save-and-reload-history 1
history -c
history -r
PS1="($(clock_prompt)${reset_color}) $(scm_char) [${USERNAME_COLOR}\u${reset_color}@${HOSTNAME_COLOR}\H${reset_color}] ${PATH_COLOR}\w${reset_color}$(scm_prompt_info) ${reset_color}\n$(prompt_end) " PS1="($(clock_prompt)${reset_color}) $(scm_char) [${USERNAME_COLOR}\u${reset_color}@${HOSTNAME_COLOR}\H${reset_color}] ${PATH_COLOR}\w${reset_color}$(scm_prompt_info) ${reset_color}\n$(prompt_end) "
PS2='> ' PS2='> '
PS4='+ ' PS4='+ '

View File

@ -1,10 +1,8 @@
#!/usr/bin/env bash # shellcheck shell=bash
prompt_setter() { prompt_setter() {
# Save history # Save history
history -a _save-and-reload-history 1
history -c
history -r
PS1="($(clock_prompt)) $(scm_char) [$blue\u$reset_color@$green\H$reset_color] $yellow\w${reset_color}$(scm_prompt_info)$(ruby_version_prompt) $reset_color " PS1="($(clock_prompt)) $(scm_char) [$blue\u$reset_color@$green\H$reset_color] $yellow\w${reset_color}$(scm_prompt_info)$(ruby_version_prompt) $reset_color "
PS2='> ' PS2='> '
PS4='+ ' PS4='+ '

View File

@ -1,4 +1,7 @@
# shellcheck shell=bash # shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# shellcheck disable=SC2154 #TODO: fix these all.
# Define this here so it can be used by all of the Powerline themes # Define this here so it can be used by all of the Powerline themes
THEME_CHECK_SUDO=${THEME_CHECK_SUDO:=true} THEME_CHECK_SUDO=${THEME_CHECK_SUDO:=true}
@ -139,7 +142,7 @@ function __powerline_scm_prompt() {
} }
function __powerline_cwd_prompt() { function __powerline_cwd_prompt() {
local cwd=$(pwd | sed "s|^${HOME}|~|") local cwd="${PWD/$HOME/\~}"
echo "${cwd}|${CWD_THEME_PROMPT_COLOR}" echo "${cwd}|${CWD_THEME_PROMPT_COLOR}"
} }
@ -157,10 +160,10 @@ function __powerline_clock_prompt() {
} }
function __powerline_battery_prompt() { function __powerline_battery_prompt() {
local color="" local color="" battery_status
local battery_status="$(battery_percentage 2> /dev/null)" battery_status="$(battery_percentage 2> /dev/null)"
if [[ -z "${battery_status}" ]] || [[ "${battery_status}" = "-1" ]] || [[ "${battery_status}" = "no" ]]; then if [[ -z "${battery_status}" || "${battery_status}" == "-1" || "${battery_status}" == "no" ]]; then
true true
else else
if [[ "$((10#${battery_status}))" -le 5 ]]; then if [[ "$((10#${battery_status}))" -le 5 ]]; then
@ -176,7 +179,7 @@ function __powerline_battery_prompt() {
} }
function __powerline_in_vim_prompt() { function __powerline_in_vim_prompt() {
if [ -n "$VIMRUNTIME" ]; then if [[ -n "$VIMRUNTIME" ]]; then
echo "${IN_VIM_THEME_PROMPT_TEXT}|${IN_VIM_THEME_PROMPT_COLOR}" echo "${IN_VIM_THEME_PROMPT_TEXT}|${IN_VIM_THEME_PROMPT_COLOR}"
fi fi
} }
@ -221,7 +224,8 @@ function __powerline_command_number_prompt() {
} }
function __powerline_duration_prompt() { function __powerline_duration_prompt() {
local duration=$(_command_duration) local duration
duration=$(_command_duration)
[[ -n "$duration" ]] && echo "${duration}|${COMMAND_DURATION_PROMPT_COLOR}" [[ -n "$duration" ]] && echo "${duration}|${COMMAND_DURATION_PROMPT_COLOR}"
} }
@ -265,7 +269,7 @@ function __powerline_last_status_prompt() {
function __powerline_prompt_command() { function __powerline_prompt_command() {
local last_status="$?" ## always the first local last_status="$?" ## always the first
local separator_char="${POWERLINE_PROMPT_CHAR}" local separator_char="${POWERLINE_PROMPT_CHAR}" info prompt_color
LEFT_PROMPT="" LEFT_PROMPT=""
SEGMENTS_AT_LEFT=0 SEGMENTS_AT_LEFT=0
@ -277,7 +281,7 @@ function __powerline_prompt_command() {
## left prompt ## ## left prompt ##
for segment in $POWERLINE_PROMPT; do for segment in $POWERLINE_PROMPT; do
local info="$(__powerline_"${segment}"_prompt)" info="$(__powerline_"${segment}"_prompt)"
[[ -n "${info}" ]] && __powerline_left_segment "${info}" [[ -n "${info}" ]] && __powerline_left_segment "${info}"
done done
@ -289,7 +293,7 @@ function __powerline_prompt_command() {
# By default we try to match the prompt to the adjacent segment's background color, # By default we try to match the prompt to the adjacent segment's background color,
# but when part of the prompt exists within that segment, we instead match the foreground color. # but when part of the prompt exists within that segment, we instead match the foreground color.
local prompt_color="$(set_color "${LAST_SEGMENT_COLOR}" -)" prompt_color="$(set_color "${LAST_SEGMENT_COLOR}" -)"
if [[ -n "${LEFT_PROMPT}" ]] && [[ -n "${POWERLINE_LEFT_LAST_SEGMENT_PROMPT_CHAR}" ]]; then if [[ -n "${LEFT_PROMPT}" ]] && [[ -n "${POWERLINE_LEFT_LAST_SEGMENT_PROMPT_CHAR}" ]]; then
LEFT_PROMPT+="$(set_color - "${LAST_SEGMENT_COLOR}")${POWERLINE_LEFT_LAST_SEGMENT_PROMPT_CHAR}" LEFT_PROMPT+="$(set_color - "${LAST_SEGMENT_COLOR}")${POWERLINE_LEFT_LAST_SEGMENT_PROMPT_CHAR}"
prompt_color="${normal}" prompt_color="${normal}"

View File

@ -1,4 +1,5 @@
# shellcheck shell=bash # shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# shellcheck source=../../themes/powerline/powerline.base.bash # shellcheck source=../../themes/powerline/powerline.base.bash
. "$BASH_IT/themes/powerline/powerline.base.bash" . "$BASH_IT/themes/powerline/powerline.base.bash"

View File

@ -43,7 +43,7 @@ _swd(){
begin="" # The unshortened beginning of the path. begin="" # The unshortened beginning of the path.
shortbegin="" # The shortened beginning of the path. shortbegin="" # The shortened beginning of the path.
current="" # The section of the path we're currently working on. current="" # The section of the path we're currently working on.
end="${2:-$(pwd)}/" # The unmodified rest of the path. end="${2:-${PWD}}/" # The unmodified rest of the path.
if [[ "$end" =~ "$HOME" ]]; then if [[ "$end" =~ "$HOME" ]]; then
INHOME=1 INHOME=1

View File

@ -1,4 +1,6 @@
# shellcheck shell=bash # shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# shellcheck disable=SC2154 #TODO: fix these all.
# scm theming # scm theming
SCM_THEME_PROMPT_PREFIX="|" SCM_THEME_PROMPT_PREFIX="|"

View File

@ -1,4 +1,6 @@
# shellcheck shell=bash # shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# shellcheck disable=SC2154 #TODO: fix these all.
SCM_THEME_PROMPT_DIRTY=" ${bold_red}${normal}" SCM_THEME_PROMPT_DIRTY=" ${bold_red}${normal}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}${normal}" SCM_THEME_PROMPT_CLEAN=" ${bold_green}${normal}"
@ -26,8 +28,8 @@ venv_prompt() {
} }
function prompt_command() { function prompt_command() {
retval=$? local retval=$? ret_status
local ret_status="$([ $retval -eq 0 ] && echo -e "$STATUS_THEME_PROMPT_OK" || echo -e "$STATUS_THEME_PROMPT_BAD")" ret_status="$([ $retval -eq 0 ] && echo -e "$STATUS_THEME_PROMPT_OK" || echo -e "$STATUS_THEME_PROMPT_BAD")"
PS1="\n${PURITY_THEME_PROMPT_COLOR}\w $(scm_prompt_info)\n${ret_status}$(venv_prompt)" PS1="\n${PURITY_THEME_PROMPT_COLOR}\w $(scm_prompt_info)\n${ret_status}$(venv_prompt)"
} }

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash # shellcheck shell=bash
# based off of n0qorg # based off of n0qorg
# looks like, if you're in a git repo: # looks like, if you're in a git repo:
@ -7,9 +7,7 @@
prompt_setter() { prompt_setter() {
# Save history # Save history
history -a _save-and-reload-history 1
history -c
history -r
# displays user@server in purple # displays user@server in purple
# PS1="$red$(scm_char) $purple\u@\h$reset_color:$blue\w$yellow$(scm_prompt_info)$(ruby_version_prompt) $black\$$reset_color " # PS1="$red$(scm_char) $purple\u@\h$reset_color:$blue\w$yellow$(scm_prompt_info)$(ruby_version_prompt) $black\$$reset_color "
# no user@server # no user@server

0
themes/rana/rana.theme.bash 100755 → 100644
View File