Merge branch 'master' into vendor

pull/1776/head
Noah Gorny 2021-01-27 16:43:34 +02:00 committed by GitHub
commit 9b04e11bfc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 202 additions and 186 deletions

View File

@ -39,6 +39,13 @@ themes/barbuk
themes/atomic themes/atomic
themes/axin themes/axin
themes/base.theme.bash themes/base.theme.bash
themes/bakke
themes/binaryanomaly
themes/bira
themes/bobby
themes/bobby-python
themes/brainy
themes/brunton
themes/command_duration.theme.bash themes/command_duration.theme.bash
# plugins # plugins
@ -56,6 +63,7 @@ completion/available/pipx.completion.bash
completion/available/rustup.completion.bash completion/available/rustup.completion.bash
completion/available/vault.completion.bash completion/available/vault.completion.bash
completion/available/sdkman.completion.bash completion/available/sdkman.completion.bash
completion/available/vuejs.completion.bash
# aliases # aliases
# #

View File

@ -1,49 +1,59 @@
#!/usr/bin/bash # shellcheck shell=bash
if _command_exists vue; then
__vuejs_completion() { __vuejs_completion() {
local prev=$(_get_pword) local prev=$(_get_pword)
local curr=$(_get_cword) local curr=$(_get_cword)
case $prev in case $prev in
create) create)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-p -d -i -m -r -g -n -f -c -x -b -h --help --preset --default --inilinePreset --packageManager --registry --git --no-git --force --merge --clone --proxy --bare --skipGetStarted" -- "$curr")) COMPREPLY=($(compgen -W "-p -d -i -m -r -g -n -f -c -x -b -h --help --preset --default --inilinePreset --packageManager --registry --git --no-git --force --merge --clone --proxy --bare --skipGetStarted" -- "$curr"))
;; ;;
add | invoke) add | invoke)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "--registry -h --help" -- "$curr")) COMPREPLY=($(compgen -W "--registry -h --help" -- "$curr"))
;; ;;
inspect) inspect)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-v --help --verbose --mode --rule --plugin --plugins --rules" -- "$curr")) COMPREPLY=($(compgen -W "-v --help --verbose --mode --rule --plugin --plugins --rules" -- "$curr"))
;; ;;
serve) serve)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-o -h --help --open -c --copy -p --port" -- "$curr")) COMPREPLY=($(compgen -W "-o -h --help --open -c --copy -p --port" -- "$curr"))
;; ;;
build) build)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-t --target -n --name -d --dest -h --help" -- "$curr")) COMPREPLY=($(compgen -W "-t --target -n --name -d --dest -h --help" -- "$curr"))
;; ;;
ui) ui)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-H --host -p --port -D --dev --quiet --headless -h --help" -- "$curr")) COMPREPLY=($(compgen -W "-H --host -p --port -D --dev --quiet --headless -h --help" -- "$curr"))
;; ;;
init) init)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-c --clone --offline -h --help" -- "$curr")) COMPREPLY=($(compgen -W "-c --clone --offline -h --help" -- "$curr"))
;; ;;
config) config)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-g --get -s --set -d --delete -e --edit --json -h --help" -- "$curr")) COMPREPLY=($(compgen -W "-g --get -s --set -d --delete -e --edit --json -h --help" -- "$curr"))
;; ;;
outdated) outdated)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "--next -h --help" -- "$curr")) COMPREPLY=($(compgen -W "--next -h --help" -- "$curr"))
;; ;;
upgrade) upgrade)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-t --to -f --from -r --registry --all --next -h --help" -- "$curr")) COMPREPLY=($(compgen -W "-t --to -f --from -r --registry --all --next -h --help" -- "$curr"))
;; ;;
migrate) migrate)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-f --from -h --help" -- "$curr")) COMPREPLY=($(compgen -W "-f --from -h --help" -- "$curr"))
;; ;;
*) *)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-h --help -v --version create add invoke inspect serve build ui init config outdated upgrade migrate info" -- "$curr")) COMPREPLY=($(compgen -W "-h --help -v --version create add invoke inspect serve build ui init config outdated upgrade migrate info" -- "$curr"))
;; ;;
esac esac
} }
complete -F __vuejs_completion vue complete -F __vuejs_completion vue
fi

View File

@ -225,17 +225,15 @@ _atomic_completion() {
actions="show hide" actions="show hide"
segments="battery clock exitcode python ruby scm sudo todo" segments="battery clock exitcode python ruby scm sudo todo"
case "${_action}" in case "${_action}" in
show) show | hide)
read -r -a COMPREPLY <<< "$(compgen -W "${segments}" -- "${cur}")" # shellcheck disable=SC2207
return 0 COMPREPLY=($(compgen -W "${segments}" -- "${cur}"))
;;
hide)
read -r -a COMPREPLY <<< "$(compgen -W "${segments}" -- "${cur}")"
return 0 return 0
;; ;;
esac esac
read -r -a COMPREPLY <<< "$(compgen -W "${actions}" -- "${cur}")" # shellcheck disable=SC2207
COMPREPLY=($(compgen -W "${actions}" -- "${cur}"))
return 0 return 0
} }

View File

@ -1,4 +1,5 @@
#!/usr/bin/env bash # shellcheck shell=bash
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=" |"

View File

@ -1,9 +1,8 @@
#!/usr/bin/env bash # shellcheck shell=bash
# Detect whether a reboot is required # Detect whether a reboot is required
function show_reboot_required() { function show_reboot_required() {
if [ ! -z "$_bf_prompt_reboot_info" ]; then if [ -n "$_bf_prompt_reboot_info" ]; then
if [ -f /var/run/reboot-required ]; then if [ -f /var/run/reboot-required ]; then
printf "Reboot required!" printf "Reboot required!"
fi fi
@ -13,10 +12,10 @@ function show_reboot_required() {
# Set different host color for local and remote sessions # Set different host color for local and remote sessions
function set_host_color() { function set_host_color() {
# Detect if connection is through SSH # Detect if connection is through SSH
if [[ ! -z $SSH_CLIENT ]]; then if [[ -n $SSH_CLIENT ]]; then
printf "${lime_yellow}" printf '%s' "${lime_yellow}"
else else
printf "${light_orange}" printf '%s' "${light_orange}"
fi fi
} }
@ -24,18 +23,17 @@ function set_host_color() {
function set_user_color() { function set_user_color() {
case $(id -u) in case $(id -u) in
0) 0)
printf "${red}" printf '%s' "${red}"
;; ;;
*) *)
printf "${cyan}" printf '%s' "${cyan}"
;; ;;
esac esac
} }
scm_prompt() { scm_prompt() {
CHAR=$(scm_char) CHAR=$(scm_char)
if [ $CHAR = $SCM_NONE_CHAR ] if [ "$CHAR" = "$SCM_NONE_CHAR" ]; then
then
return return
else else
echo "[$(scm_char)$(scm_prompt_info)]" echo "[$(scm_char)$(scm_prompt_info)]"
@ -57,7 +55,7 @@ function set_custom_colors() {
} }
__ps_time() { __ps_time() {
echo "$(clock_prompt)${normal}\n" printf '%s' "$(clock_prompt)${normal}\n"
} }
function prompt_command() { function prompt_command() {

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash # shellcheck shell=bash
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,5 @@
#!/usr/bin/env bash # shellcheck shell=bash
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=" |"

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash # shellcheck shell=bash
SCM_THEME_PROMPT_DIRTY=" ${red}" SCM_THEME_PROMPT_DIRTY=" ${red}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}" SCM_THEME_PROMPT_CLEAN=" ${bold_green}"
@ -14,10 +14,10 @@ RVM_THEME_PROMPT_PREFIX="|"
RVM_THEME_PROMPT_SUFFIX="|" RVM_THEME_PROMPT_SUFFIX="|"
__bobby_clock() { __bobby_clock() {
printf "$(clock_prompt) " printf '%s' "$(clock_prompt) "
if [ "${THEME_SHOW_CLOCK_CHAR}" == "true" ]; then if [ "${THEME_SHOW_CLOCK_CHAR}" == "true" ]; then
printf "$(clock_char) " printf '%s' "$(clock_char) "
fi fi
} }

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash # shellcheck shell=bash
# Brainy Bash Prompt for Bash-it # Brainy Bash Prompt for Bash-it
# by MunifTanjim # by MunifTanjim
@ -10,7 +10,7 @@
____brainy_top_left_parse() { ____brainy_top_left_parse() {
ifs_old="${IFS}" ifs_old="${IFS}"
IFS="|" IFS="|"
args=( $1 ) read -r -a args <<< "$@"
IFS="${ifs_old}" IFS="${ifs_old}"
if [ -n "${args[3]}" ]; then if [ -n "${args[3]}" ]; then
_TOP_LEFT+="${args[2]}${args[3]}" _TOP_LEFT+="${args[2]}${args[3]}"
@ -25,7 +25,7 @@ ____brainy_top_left_parse() {
____brainy_top_right_parse() { ____brainy_top_right_parse() {
ifs_old="${IFS}" ifs_old="${IFS}"
IFS="|" IFS="|"
args=( $1 ) read -r -a args <<< "$@"
IFS="${ifs_old}" IFS="${ifs_old}"
_TOP_RIGHT+=" " _TOP_RIGHT+=" "
if [ -n "${args[3]}" ]; then if [ -n "${args[3]}" ]; then
@ -42,7 +42,7 @@ ____brainy_top_right_parse() {
____brainy_bottom_parse() { ____brainy_bottom_parse() {
ifs_old="${IFS}" ifs_old="${IFS}"
IFS="|" IFS="|"
args=( $1 ) read -r -a args <<< "$@"
IFS="${ifs_old}" IFS="${ifs_old}"
_BOTTOM+="${args[0]}${args[1]}" _BOTTOM+="${args[0]}${args[1]}"
[ ${#args[1]} -gt 0 ] && _BOTTOM+=" " [ ${#args[1]} -gt 0 ] && _BOTTOM+=" "
@ -135,11 +135,11 @@ ___brainy_prompt_ruby() {
} }
___brainy_prompt_todo() { ___brainy_prompt_todo() {
[ "${THEME_SHOW_TODO}" != "true" ] || [ "${THEME_SHOW_TODO}" != "true" ] \
[ -z "$(which todo.sh)" ] && return || [ -z "$(which todo.sh)" ] && return
color=$bold_white color=$bold_white
box="[|]" box="[|]"
info="t:$(todo.sh ls | egrep "TODO: [0-9]+ of ([0-9]+)" | awk '{ print $4 }' )" info="t:$(todo.sh ls | grep -E "TODO: [0-9]+ of ([0-9]+)" | awk '{ print $4 }')"
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_green}" "${box}" printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_green}" "${box}"
} }
@ -152,9 +152,9 @@ ___brainy_prompt_clock() {
} }
___brainy_prompt_battery() { ___brainy_prompt_battery() {
! _command_exists battery_percentage || ! _command_exists battery_percentage \
[ "${THEME_SHOW_BATTERY}" != "true" ] || || [ "${THEME_SHOW_BATTERY}" != "true" ] \
[ "$(battery_percentage)" = "no" ] && return || [ "$(battery_percentage)" = "no" ] && return
info=$(battery_percentage) info=$(battery_percentage)
color=$bold_green color=$bold_green
@ -190,13 +190,13 @@ ___brainy_prompt_char() {
__brainy_show() { __brainy_show() {
typeset _seg=${1:-} typeset _seg=${1:-}
shift shift
export THEME_SHOW_${_seg}=true export "THEME_SHOW_${_seg}"=true
} }
__brainy_hide() { __brainy_hide() {
typeset _seg=${1:-} typeset _seg=${1:-}
shift shift
export THEME_SHOW_${_seg}=false export "THEME_SHOW_${_seg}"=false
} }
_brainy_completion() { _brainy_completion() {
@ -207,16 +207,14 @@ _brainy_completion() {
actions="show hide" actions="show hide"
segments="battery clock exitcode python ruby scm sudo todo" segments="battery clock exitcode python ruby scm sudo todo"
case "${_action}" in case "${_action}" in
show) show | hide)
COMPREPLY=( $(compgen -W "${segments}" -- "${cur}") ) # shellcheck disable=SC2207
return 0
;;
hide)
COMPREPLY=($(compgen -W "${segments}" -- "${cur}")) COMPREPLY=($(compgen -W "${segments}" -- "${cur}"))
return 0 return 0
;; ;;
esac esac
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "${actions}" -- "${cur}")) COMPREPLY=($(compgen -W "${actions}" -- "${cur}"))
return 0 return 0
} }
@ -228,9 +226,11 @@ brainy() {
typeset func typeset func
case $action in case $action in
show) show)
func=__brainy_show;; func=__brainy_show
;;
hide) hide)
func=__brainy_hide;; func=__brainy_hide
;;
esac esac
for seg in ${segs}; do for seg in ${segs}; do
seg=$(printf "%s" "${seg}" | tr '[:lower:]' '[:upper:]') seg=$(printf "%s" "${seg}" | tr '[:lower:]' '[:upper:]')

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash # shellcheck shell=bash
SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_PREFIX=""
SCM_THEME_PROMPT_SUFFIX="" SCM_THEME_PROMPT_SUFFIX=""
@ -10,16 +10,14 @@ SCM_SVN_CHAR="${bold_cyan}⑆${normal}"
SCM_HG_CHAR="${bold_red}${normal}" SCM_HG_CHAR="${bold_red}${normal}"
is_vim_shell() { is_vim_shell() {
if [ ! -z "$VIMRUNTIME" ] if [ -n "$VIMRUNTIME" ]; then
then
echo "[${cyan}vim shell${normal}]" echo "[${cyan}vim shell${normal}]"
fi fi
} }
scm_prompt() { scm_prompt() {
CHAR=$(scm_char) CHAR=$(scm_char)
if [ $CHAR = $SCM_NONE_CHAR ] if [ "$CHAR" = "$SCM_NONE_CHAR" ]; then
then
return return
else else
echo " $(scm_char) (${white}$(scm_prompt_info)${normal})" echo " $(scm_char) (${white}$(scm_prompt_info)${normal})"

View File

@ -19,38 +19,40 @@ esac
PS3=">> " PS3=">> "
is_vim_shell() { is_vim_shell() {
if [ ! -z "$VIMRUNTIME" ] if [ ! -z "$VIMRUNTIME" ]; then
then
echo "[${cyan}vim shell${normal}]" echo "[${cyan}vim shell${normal}]"
fi fi
} }
modern_scm_prompt() { modern_scm_prompt() {
CHAR=$(scm_char) CHAR=$(scm_char)
if [ $CHAR = $SCM_NONE_CHAR ] if [ $CHAR = $SCM_NONE_CHAR ]; then
then
return return
else else
echo "[$(scm_char)][$(scm_prompt_info)]" echo "[$(scm_char)][$(scm_prompt_info)]"
fi fi
} }
prompt() { detect_venv() {
if [ $? -ne 0 ] python_venv=""
then # Detect python venv
# Yes, the indenting on these is weird, but it has to be like if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then
# this otherwise it won't display properly. python_venv="($PYTHON_VENV_CHAR${CONDA_DEFAULT_ENV}) "
elif [[ -n "${VIRTUAL_ENV}" ]]; then
PS1="${TITLEBAR}${bold_red}┌─${reset_color}$(modern_scm_prompt)[${cyan}\W${normal}][$(battery_charge)]$(is_vim_shell) python_venv="($PYTHON_VENV_CHAR$(basename "${VIRTUAL_ENV}")) "
${bold_red}└─▪${normal} "
else
PS1="${TITLEBAR}┌─$(modern_scm_prompt)[${cyan}\W${normal}][$(battery_charge)]$(is_vim_shell)
└─▪ "
fi fi
} }
prompt() {
if [ $? -ne 0 ]; then
PS1="${TITLEBAR}${bold_red}┌─${reset_color}$(modern_scm_prompt)[${cyan}\u${normal}][${cyan}\w${normal}]$(is_vim_shell)\n${bold_red}└─▪${normal} "
else
PS1="${TITLEBAR}┌─$(modern_scm_prompt)[${cyan}\u${normal}][${cyan}\w${normal}]$(is_vim_shell)\n└─▪ "
fi
detect_venv
PS1+="${python_venv}${dir_color}"
}
PS2="└─▪ " PS2="└─▪ "
safe_append_prompt_command prompt safe_append_prompt_command prompt