mirror of
https://github.com/ohmybash/oh-my-bash.git
synced 2024-05-11 05:55:37 +00:00
fix: Fix quoting
Co-authored-by: Koichi Muarse <myoga.murase@gmail.com>
This commit is contained in:
committed by
Koichi Murase
parent
475a563280
commit
0c07172c02
@@ -43,10 +43,10 @@ complete -F _django_completion -o default django-admin.py manage.py django-admin
|
|||||||
_python_django_completion()
|
_python_django_completion()
|
||||||
{
|
{
|
||||||
if [[ ${COMP_CWORD} -ge 2 ]]; then
|
if [[ ${COMP_CWORD} -ge 2 ]]; then
|
||||||
PYTHON_EXE=$( basename -- ${COMP_WORDS[0]} )
|
PYTHON_EXE=$( basename -- "${COMP_WORDS[0]}" )
|
||||||
echo $PYTHON_EXE | command grep -E "python([2-9]\.[0-9])?" >/dev/null 2>&1
|
echo $PYTHON_EXE | command grep -E "python([2-9]\.[0-9])?" >/dev/null 2>&1
|
||||||
if [[ $? == 0 ]]; then
|
if [[ $? == 0 ]]; then
|
||||||
PYTHON_SCRIPT=$( basename -- ${COMP_WORDS[1]} )
|
PYTHON_SCRIPT=$( basename -- "${COMP_WORDS[1]}" )
|
||||||
echo $PYTHON_SCRIPT | command grep -E "manage\.py|django-admin(\.py)?" >/dev/null 2>&1
|
echo $PYTHON_SCRIPT | command grep -E "manage\.py|django-admin(\.py)?" >/dev/null 2>&1
|
||||||
if [[ $? == 0 ]]; then
|
if [[ $? == 0 ]]; then
|
||||||
COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]:1}" \
|
COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]:1}" \
|
||||||
@@ -58,16 +58,16 @@ _python_django_completion()
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Support for multiple interpreters.
|
# Support for multiple interpreters.
|
||||||
unset pythons
|
unset -v pythons
|
||||||
if _omb_util_command_exists whereis; then
|
if _omb_util_command_exists whereis; then
|
||||||
python_interpreters=$(whereis python | cut -d " " -f 2-)
|
_omb_util_split python_interpreters "$(whereis python | cut -d " " -f 2-)"
|
||||||
for python in $python_interpreters; do
|
pythons=()
|
||||||
pythons="${pythons} $(basename -- $python)"
|
for python in "${python_interpreters[@]}"; do
|
||||||
|
pythons+=("$(basename -- "$python")")
|
||||||
done
|
done
|
||||||
pythons=$(echo $pythons | tr " " "\n" | sort -u | tr "\n" " ")
|
pythons=($(printf '%s\n' "${pythons[@]}" | sort -u))
|
||||||
else
|
else
|
||||||
pythons=python
|
pythons=(python)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
complete -F _python_django_completion -o default $pythons
|
complete -F _python_django_completion -o default "${pythons[@]}"
|
||||||
|
|
||||||
|
@@ -200,7 +200,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)
|
||||||
|
@@ -202,7 +202,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)
|
||||||
|
@@ -83,9 +83,9 @@ function _vagrant {
|
|||||||
vagrant_state_file=$(__vagrantinvestigate) || return 1
|
vagrant_state_file=$(__vagrantinvestigate) || return 1
|
||||||
if [[ -f $vagrant_state_file ]]
|
if [[ -f $vagrant_state_file ]]
|
||||||
then
|
then
|
||||||
running_vm_list=$(grep 'active' $vagrant_state_file | sed -e 's/"active"://' | tr ',' '\n' | cut -d '"' -f 2 | tr '\n' ' ')
|
running_vm_list=$(grep 'active' "$vagrant_state_file" | sed -e 's/"active"://' | tr ',' '\n' | cut -d '"' -f 2 | tr '\n' ' ')
|
||||||
else
|
else
|
||||||
running_vm_list=$(find $vagrant_state_file -type f -name "id" | awk -F"/" '{print $(NF-2)}')
|
running_vm_list=$(find "$vagrant_state_file" -type f -name "id" | awk -F"/" '{print $(NF-2)}')
|
||||||
fi
|
fi
|
||||||
COMPREPLY=($(compgen -W "${running_vm_list}" -- ${cur}))
|
COMPREPLY=($(compgen -W "${running_vm_list}" -- ${cur}))
|
||||||
return 0
|
return 0
|
||||||
|
@@ -32,7 +32,7 @@ function _vault() {
|
|||||||
if [[ $prev =~ ^(policies|policy-write|policy-delete) ]]; then
|
if [[ $prev =~ ^(policies|policy-write|policy-delete) ]]; then
|
||||||
local policies=$(vault policies 2> /dev/null)
|
local policies=$(vault policies 2> /dev/null)
|
||||||
COMPREPLY=($(compgen -W "$policies" -- $cur))
|
COMPREPLY=($(compgen -W "$policies" -- $cur))
|
||||||
elif [ "$(echo $line | wc -w)" -le 2 ]; then
|
elif [ "$(echo "$line" | wc -w)" -le 2 ]; then
|
||||||
if [[ "$line" =~ ^vault\ (read|write|delete|list)\ $ ]]; then
|
if [[ "$line" =~ ^vault\ (read|write|delete|list)\ $ ]]; then
|
||||||
COMPREPLY=($(compgen -W "$(_vault_mounts)" -- ''))
|
COMPREPLY=($(compgen -W "$(_vault_mounts)" -- ''))
|
||||||
else
|
else
|
||||||
|
@@ -244,7 +244,7 @@ function git_prompt_vars {
|
|||||||
command git status --porcelain ${git_status_flags} 2> /dev/null) | git_status_summary)
|
command git status --porcelain ${git_status_flags} 2> /dev/null) | git_status_summary)
|
||||||
local status=$(awk 'NR==1' <<< "$status_lines")
|
local status=$(awk 'NR==1' <<< "$status_lines")
|
||||||
local counts=$(awk 'NR==2' <<< "$status_lines")
|
local counts=$(awk 'NR==2' <<< "$status_lines")
|
||||||
IFS=$'\t' read untracked_count unstaged_count staged_count <<< "$counts"
|
IFS=$'\t' read -r untracked_count unstaged_count staged_count <<< "$counts"
|
||||||
if [[ "${untracked_count}" -gt 0 || "${unstaged_count}" -gt 0 || "${staged_count}" -gt 0 ]]; then
|
if [[ "${untracked_count}" -gt 0 || "${unstaged_count}" -gt 0 || "${staged_count}" -gt 0 ]]; then
|
||||||
SCM_DIRTY=1
|
SCM_DIRTY=1
|
||||||
if [[ "${SCM_GIT_SHOW_DETAILS}" = "true" ]]; then
|
if [[ "${SCM_GIT_SHOW_DETAILS}" = "true" ]]; then
|
||||||
@@ -341,7 +341,7 @@ 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
|
||||||
@@ -349,7 +349,7 @@ function get_hg_root {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CURRENT_DIR=$(dirname $CURRENT_DIR)
|
CURRENT_DIR=$(dirname "$CURRENT_DIR")
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -87,6 +87,7 @@ function _omb_util_readlink__resolve {
|
|||||||
readlink=$(type -P readlink)
|
readlink=$(type -P readlink)
|
||||||
case $readlink in
|
case $readlink in
|
||||||
(/bin/readlink | /usr/bin/readlink)
|
(/bin/readlink | /usr/bin/readlink)
|
||||||
|
# shellcheck disable=SC2100
|
||||||
_omb_util_readlink_type=readlink-f
|
_omb_util_readlink_type=readlink-f
|
||||||
function _omb_util_readlink__resolve { readlink -f -- "$1"; } ;;
|
function _omb_util_readlink__resolve { readlink -f -- "$1"; } ;;
|
||||||
esac ;;
|
esac ;;
|
||||||
|
@@ -243,7 +243,7 @@ function _omb_log_note { printf "${_omb_term_underline}${_omb_term_bold}${_
|
|||||||
#
|
#
|
||||||
function seek_confirmation {
|
function seek_confirmation {
|
||||||
printf "\\n${_omb_term_bold}%s${_omb_term_reset}" "$@"
|
printf "\\n${_omb_term_bold}%s${_omb_term_reset}" "$@"
|
||||||
read -p " (y/n) " -n 1
|
read -rp " (y/n) " -n 1
|
||||||
printf "\\n"
|
printf "\\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,6 +309,7 @@ function _omb_util_unload {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_omb_util_original_PS1=$PS1
|
_omb_util_original_PS1=$PS1
|
||||||
|
# shellcheck disable=SC2016
|
||||||
_omb_util_unload_hook+=('PS1=$_omb_util_original_PS1')
|
_omb_util_unload_hook+=('PS1=$_omb_util_original_PS1')
|
||||||
|
|
||||||
_omb_util_prompt_command=()
|
_omb_util_prompt_command=()
|
||||||
|
@@ -107,7 +107,7 @@
|
|||||||
# export THEME=$HOME/.bash/themes/agnoster-bash/agnoster.bash
|
# export THEME=$HOME/.bash/themes/agnoster-bash/agnoster.bash
|
||||||
# if [[ -f $THEME ]]; then
|
# if [[ -f $THEME ]]; then
|
||||||
# export DEFAULT_USER=$(whoami)
|
# export DEFAULT_USER=$(whoami)
|
||||||
# source $THEME
|
# source "$THEME"
|
||||||
# fi
|
# fi
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@@ -6,7 +6,7 @@ SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}with changes"
|
|||||||
SCM_THEME_PROMPT_CLEAN=""
|
SCM_THEME_PROMPT_CLEAN=""
|
||||||
|
|
||||||
function venv {
|
function venv {
|
||||||
if [ ! -z "$VIRTUAL_ENV" ]
|
if [ -n "$VIRTUAL_ENV" ]
|
||||||
then
|
then
|
||||||
local env=$VIRTUAL_ENV
|
local env=$VIRTUAL_ENV
|
||||||
echo "${gray} in ${_omb_prompt_red}${env##*/} "
|
echo "${gray} in ${_omb_prompt_red}${env##*/} "
|
||||||
@@ -14,7 +14,7 @@ function venv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function last_two_dirs {
|
function last_two_dirs {
|
||||||
pwd|rev|awk -F / '{print $1,$2}'|rev|sed s_\ _/_|sed "s|$(sed 's,\/,,'<<<$HOME)|~|g"
|
pwd|rev|awk -F / '{print $1,$2}'|rev|sed s_\ _/_|sed "s|$(sed 's,\/,,'<<<"$HOME")|~|g"
|
||||||
}
|
}
|
||||||
|
|
||||||
function _omb_theme_PROMPT_COMMAND {
|
function _omb_theme_PROMPT_COMMAND {
|
||||||
|
@@ -169,7 +169,7 @@ function limited_pwd() {
|
|||||||
# Replace $HOME with ~ if possible
|
# Replace $HOME with ~ if possible
|
||||||
local RELATIVE_PWD=${PWD/#$HOME/\~}
|
local RELATIVE_PWD=${PWD/#$HOME/\~}
|
||||||
|
|
||||||
local offset=$((${#RELATIVE_PWD}-$MAX_PWD_LENGTH))
|
local offset=$((${#RELATIVE_PWD}-MAX_PWD_LENGTH))
|
||||||
|
|
||||||
if ((offset > 0)); then
|
if ((offset > 0)); then
|
||||||
local truncated_symbol="..."
|
local truncated_symbol="..."
|
||||||
|
Reference in New Issue
Block a user