feat(lib/omb-util): add "_omb_util_{print,put}"

This commit is contained in:
Koichi Murase 2024-08-12 23:59:41 +09:00
parent 382ecf151f
commit 4b95670330
65 changed files with 372 additions and 336 deletions

View File

@ -27,7 +27,7 @@
# 1. FILE AND FOLDER MANAGEMENT # 1. FILE AND FOLDER MANAGEMENT
# ------------------------------- # -------------------------------
alias numFiles='echo $(ls -1 | wc -l)' # numFiles: Count of non-hidden files in current dir alias numFiles='_omb_util_print $(ls -1 | wc -l)' # numFiles: Count of non-hidden files in current dir
alias make1mb='truncate -s 1m ./1MB.dat' # make1mb: Creates a file of 1mb size (all zeros) alias make1mb='truncate -s 1m ./1MB.dat' # make1mb: Creates a file of 1mb size (all zeros)
alias make5mb='truncate -s 5m ./5MB.dat' # make5mb: Creates a file of 5mb size (all zeros) alias make5mb='truncate -s 5m ./5MB.dat' # make5mb: Creates a file of 5mb size (all zeros)
alias make10mb='truncate -s 10m ./10MB.dat' # make10mb: Creates a file of 10mb size (all zeros) alias make10mb='truncate -s 10m ./10MB.dat' # make10mb: Creates a file of 10mb size (all zeros)
@ -95,7 +95,7 @@ alias mountReadWrite='mount -uw /' # mountReadWrite: For use when booted in
alias bdate="date '+%a, %b %d %Y %T %Z'" alias bdate="date '+%a, %b %d %Y %T %Z'"
alias cal3='cal -3' alias cal3='cal -3'
alias da='date "+%Y-%m-%d %A %T %Z"' alias da='date "+%Y-%m-%d %A %T %Z"'
alias daysleft='echo "There are $(($(date +%j -d"Dec 31, $(date +%Y)")-$(date +%j))) left in year $(date +%Y)."' alias daysleft='_omb_util_print "There are $(($(date +%j -d"Dec 31, $(date +%Y)")-$(date +%j))) left in year $(date +%Y)."'
alias epochtime='date +%s' alias epochtime='date +%s'
alias mytime='date +%H:%M:%S' alias mytime='date +%H:%M:%S'
alias secconvert='date -d@1234567890' alias secconvert='date -d@1234567890'

View File

@ -66,7 +66,7 @@ function _omb_completion_django_init {
python=${python##*/} python=${python##*/}
[[ $python ]] && pythons+=("$python") [[ $python ]] && pythons+=("$python")
done done
_omb_util_split pythons "$(printf '%s\n' "${pythons[@]}" | sort -u)" $'\n' _omb_util_split pythons "$(_omb_util_print_lines "${pythons[@]}" | sort -u)" $'\n'
fi fi
complete -F _omb_completion_django_python -o default "${pythons[@]}" complete -F _omb_completion_django_python -o default "${pythons[@]}"

View File

@ -278,7 +278,7 @@ EOF
# HOST - Host to be looked-up in hub config. Default is "github.com" # HOST - Host to be looked-up in hub config. Default is "github.com"
function __hub_github_user { function __hub_github_user {
if [ -n "$GITHUB_USER" ]; then if [ -n "$GITHUB_USER" ]; then
echo $GITHUB_USER _omb_util_print $GITHUB_USER
return return
fi fi
local line h k v host=${1:-github.com} config=${HUB_CONFIG:-~/.config/gh} local line h k v host=${1:-github.com} config=${HUB_CONFIG:-~/.config/gh}
@ -299,7 +299,7 @@ EOF
k=${k#* } k=${k#* }
v=${v#* } v=${v#* }
if [ "$h" = "$host" ] && [ "$k" = "user" ]; then if [ "$h" = "$host" ] && [ "$k" = "user" ]; then
echo "$v" _omb_util_print "$v"
break break
fi fi
done < "$config" done < "$config"
@ -343,7 +343,7 @@ EOF
repo=${i#*:} repo=${i#*:}
_omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ _omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/remotes/${remote}/" | while read branch; do "refs/remotes/${remote}/" | while read branch; do
echo "${repo}:${branch#${remote}/}" _omb_util_print "${repo}:${branch#${remote}/}"
done done
done done
fi fi
@ -357,7 +357,7 @@ EOF
if [ -d "$dir" ]; then if [ -d "$dir" ]; then
_omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ _omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/remotes/${remote}/" | while read i; do "refs/remotes/${remote}/" | while read i; do
echo "${i#${remote}/}" _omb_util_print "${i#${remote}/}"
done done
_omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ _omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/tags/" "refs/tags/"

View File

@ -547,7 +547,7 @@ __git_flow_prefix ()
{ {
case "$1" in case "$1" in
feature|bugfix|release|hotfix|support) feature|bugfix|release|hotfix|support)
_omb_prompt_git config "gitflow.prefix.$1" 2> /dev/null || echo "$1/" _omb_prompt_git config "gitflow.prefix.$1" 2> /dev/null || _omb_util_print "$1/"
return return
;; ;;
esac esac
@ -561,7 +561,7 @@ __git_flow_list_local_branches ()
while read -r entry; do while read -r entry; do
eval "$entry" eval "$entry"
ref="${ref#$prefix}" ref="${ref#$prefix}"
echo "$ref" _omb_util_print "$ref"
done | sort done | sort
else else
_omb_prompt_git for-each-ref --format="ref=%(refname:short)" refs/heads/ | sort _omb_prompt_git for-each-ref --format="ref=%(refname:short)" refs/heads/ | sort
@ -572,25 +572,25 @@ __git_flow_list_local_branches ()
__git_flow_list_remote_branches () __git_flow_list_remote_branches ()
{ {
local prefix="$(__git_flow_prefix $1)" local prefix="$(__git_flow_prefix $1)"
local origin="$(_omb_prompt_git config gitflow.origin 2> /dev/null || echo "origin")" local origin="$(_omb_prompt_git config gitflow.origin 2> /dev/null || _omb_util_print "origin")"
_omb_prompt_git for-each-ref --shell --format='%(refname:short)' refs/remotes/$origin/$prefix | \ _omb_prompt_git for-each-ref --shell --format='%(refname:short)' refs/remotes/$origin/$prefix | \
while read -r entry; do while read -r entry; do
eval "$entry" eval "$entry"
ref="${ref##$prefix}" ref="${ref##$prefix}"
echo "$ref" _omb_util_print "$ref"
done | sort done | sort
} }
__git_flow_list_branches () __git_flow_list_branches ()
{ {
local origin="$(_omb_prompt_git config gitflow.origin 2> /dev/null || echo "origin")" local origin="$(_omb_prompt_git config gitflow.origin 2> /dev/null || _omb_util_print "origin")"
if [ -n "$1" ]; then if [ -n "$1" ]; then
local prefix="$(__git_flow_prefix $1)" local prefix="$(__git_flow_prefix $1)"
_omb_prompt_git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix refs/remotes/$origin/$prefix | \ _omb_prompt_git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix refs/remotes/$origin/$prefix | \
while read -r entry; do while read -r entry; do
eval "$entry" eval "$entry"
ref="${ref##$prefix}" ref="${ref##$prefix}"
echo "$ref" _omb_util_print "$ref"
done | sort done | sort
else else
_omb_prompt_git for-each-ref --format="%(refname:short)" refs/heads/ refs/remotes/$origin | sort _omb_prompt_git for-each-ref --format="%(refname:short)" refs/heads/ refs/remotes/$origin | sort

View File

@ -25,18 +25,18 @@ function __gradle {
newest_gradle_file=$(find . -type f -name build.gradle -newer "$cache_dir/$gradle_files_checksum") newest_gradle_file=$(find . -type f -name build.gradle -newer "$cache_dir/$gradle_files_checksum")
if [[ $newest_gradle_file ]]; then if [[ $newest_gradle_file ]]; then
tasks=$(eval "$parsing_command") tasks=$(eval "$parsing_command")
[[ $tasks ]] && echo "$tasks" > "$cache_dir/$gradle_files_checksum" [[ $tasks ]] && _omb_util_print "$tasks" > "$cache_dir/$gradle_files_checksum"
else else
tasks=$(< "$cache_dir/$gradle_files_checksum") tasks=$(< "$cache_dir/$gradle_files_checksum")
touch "$cache_dir/$gradle_files_checksum" touch "$cache_dir/$gradle_files_checksum"
fi fi
else else
tasks=$(eval "$parsing_command") tasks=$(eval "$parsing_command")
[[ $tasks ]] && echo "$tasks" > "$cache_dir/$gradle_files_checksum" [[ $tasks ]] && _omb_util_print "$tasks" > "$cache_dir/$gradle_files_checksum"
fi fi
else else
tasks=$(eval "$parsing_command") tasks=$(eval "$parsing_command")
[[ $tasks ]] && echo "$tasks" > "$cache_dir/$gradle_files_checksum" [[ $tasks ]] && _omb_util_print "$tasks" > "$cache_dir/$gradle_files_checksum"
fi fi
COMPREPLY=($(compgen -W "$tasks" -- "$cur")) COMPREPLY=($(compgen -W "$tasks" -- "$cur"))
} }

View File

@ -28,7 +28,7 @@ function _grunt_gruntfile {
local gruntfile local gruntfile
for gruntfile in "$curpath"/{G,g}runtfile.{js,coffee}; do for gruntfile in "$curpath"/{G,g}runtfile.{js,coffee}; do
if [[ -e $gruntfile ]]; then if [[ -e $gruntfile ]]; then
echo "$gruntfile" _omb_util_print "$gruntfile"
return 0 return 0
fi fi
done done

View File

@ -300,7 +300,7 @@ EOF
# HOST - Host to be looked-up in hub config. Default is "github.com" # HOST - Host to be looked-up in hub config. Default is "github.com"
function __hub_github_user { function __hub_github_user {
if [ -n "$GITHUB_USER" ]; then if [ -n "$GITHUB_USER" ]; then
echo $GITHUB_USER _omb_util_print $GITHUB_USER
return return
fi fi
local line h k v host=${1:-github.com} config=${HUB_CONFIG:-~/.config/hub} local line h k v host=${1:-github.com} config=${HUB_CONFIG:-~/.config/hub}
@ -321,7 +321,7 @@ EOF
k=${k#* } k=${k#* }
v=${v#* } v=${v#* }
if [ "$h" = "$host" ] && [ "$k" = "user" ]; then if [ "$h" = "$host" ] && [ "$k" = "user" ]; then
echo "$v" _omb_util_print "$v"
break break
fi fi
done < "$config" done < "$config"
@ -365,7 +365,7 @@ EOF
repo=${i#*:} repo=${i#*:}
_omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ _omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/remotes/${remote}/" | while read branch; do "refs/remotes/${remote}/" | while read branch; do
echo "${repo}:${branch#${remote}/}" _omb_util_print "${repo}:${branch#${remote}/}"
done done
done done
fi fi
@ -379,7 +379,7 @@ EOF
if [ -d "$dir" ]; then if [ -d "$dir" ]; then
_omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ _omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/remotes/${remote}/" | while read i; do "refs/remotes/${remote}/" | while read i; do
echo "${i#${remote}/}" _omb_util_print "${i#${remote}/}"
done done
_omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ _omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/tags/" "refs/tags/"

View File

@ -57,9 +57,9 @@ function __find_mvn_projects {
local withoutPom=${LINE%/pom.xml} local withoutPom=${LINE%/pom.xml}
local module=${withoutPom#./} local module=${withoutPom#./}
if [[ ! $module ]]; then if [[ ! $module ]]; then
echo "." _omb_util_print "."
else else
echo $module _omb_util_print $module
fi fi
done done
} }
@ -89,7 +89,7 @@ function _realpath {
} }
# reassemble realpath # reassemble realpath
echo "$tmppwd/${1##*/}" _omb_util_print "$tmppwd/${1##*/}"
return 1 #success return 1 #success
} }

View File

@ -22,7 +22,7 @@ if ! declare -F __sdkman_build_version_csv &>/dev/null; then
done done
versions_csv=${versions_csv%?} versions_csv=${versions_csv%?}
fi fi
echo "$versions_csv" _omb_util_print "$versions_csv"
} }
fi fi

View File

@ -67,7 +67,7 @@ function _tmux {
local skip_next=0 local skip_next=0
for ((i = 1; i <= COMP_CWORD; i++)); do for ((i = 1; i <= COMP_CWORD; i++)); do
if ((skip_next == 1)); then if ((skip_next == 1)); then
#echo "Skipping" #_omb_util_print "Skipping"
skip_next=0; skip_next=0;
elif [[ ${COMP_WORDS[i]} != -* ]]; then elif [[ ${COMP_WORDS[i]} != -* ]]; then
cmd=${COMP_WORDS[i]} cmd=${COMP_WORDS[i]}
@ -82,7 +82,7 @@ function _tmux {
skip_next=0 skip_next=0
for ((i = 1; i <= COMP_CWORD; i++)); do for ((i = 1; i <= COMP_CWORD; i++)); do
if ((skip_next == 1)); then if ((skip_next == 1)); then
#echo "Skipping" #_omb_util_print "Skipping"
skip_next=0 skip_next=0
elif [[ ${COMP_WORDS[i]} == -* ]]; then elif [[ ${COMP_WORDS[i]} == -* ]]; then
option=${COMP_WORDS[i]} option=${COMP_WORDS[i]}

View File

@ -33,19 +33,19 @@ function __pwdln {
((itr++)) ((itr++))
pwdmod="${pwdmod#*/}" pwdmod="${pwdmod#*/}"
done done
echo -n $((itr-1)) _omb_util_put $((itr-1))
} }
function __vagrantinvestigate { function __vagrantinvestigate {
if [[ -f $PWD/.vagrant || -d $PWD/.vagrant ]]; then if [[ -f $PWD/.vagrant || -d $PWD/.vagrant ]]; then
echo "$PWD/.vagrant" _omb_util_print "$PWD/.vagrant"
return 0 return 0
else else
pwdmod2=$PWD pwdmod2=$PWD
for ((i = 2; i <= $(__pwdln); i++)); do for ((i = 2; i <= $(__pwdln); i++)); do
pwdmod2=${pwdmod2%/*} pwdmod2=${pwdmod2%/*}
if [[ -f $pwdmod2/.vagrant || -d $pwdmod2/.vagrant ]]; then if [[ -f $pwdmod2/.vagrant || -d $pwdmod2/.vagrant ]]; then
echo "$pwdmod2/.vagrant" _omb_util_print "$pwdmod2/.vagrant"
return 0 return 0
fi fi
done done

View File

@ -1,4 +1,11 @@
#! bash oh-my-bash.module #! bash oh-my-bash.module
#
# Taken from https://github.com/iljaweis/vault-bash-completion
#
# * 2024-08-13 Confirmed that the current version is up-to-date with the
# archived version:
# https://github.com/iljaweis/vault-bash-completion/blob/c42047c5bd6aca9045b7945db1c41654080076e1/vault-bash-completion.sh
#
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# vault-bash-completion # vault-bash-completion
# #
@ -11,7 +18,7 @@ function _vault_mounts {
( (
set -euo pipefail set -euo pipefail
if ! vault mounts 2> /dev/null | awk 'NR > 1 {print $1}'; then if ! vault mounts 2> /dev/null | awk 'NR > 1 {print $1}'; then
echo "secret" _omb_util_print "secret"
fi fi
) )
} }
@ -31,7 +38,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) <= 2)); then elif (($(wc -w <<< "$line") <= 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

View File

@ -35,8 +35,8 @@ function _vboxmanage {
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
# echo "cur: |$cur|" # _omb_util_print "cur: |$cur|"
# echo "prev: |$prev|" # _omb_util_print "prev: |$prev|"
case $prev in case $prev in
-v|--version) -v|--version)
@ -75,7 +75,7 @@ function _vboxmanage {
;; ;;
esac esac
# echo "Got vboxmanage" # _omb_util_print "Got vboxmanage"
opts=$(__vboxmanage_default) opts=$(__vboxmanage_default)
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0 return 0
@ -101,7 +101,7 @@ function _vboxmanage {
for VM in $(__vboxmanage_list_vms); do for VM in $(__vboxmanage_list_vms); do
if [ "$VM" == "$prev" ]; then if [ "$VM" == "$prev" ]; then
pprev=${COMP_WORDS[COMP_CWORD-2]} pprev=${COMP_WORDS[COMP_CWORD-2]}
# echo "previous: $pprev" # _omb_util_print "previous: $pprev"
case $pprev in case $pprev in
startvm) startvm)
opts="--type" opts="--type"
@ -127,16 +127,16 @@ function _vboxmanage {
fi fi
done done
# echo "Got to end withoug completion" # _omb_util_print "Got to end withoug completion"
} }
function _vboxmanage_realopts { function _vboxmanage_realopts {
echo $(vboxmanage | grep -Eo "^\s{2}[a-z]+") _omb_util_print $(vboxmanage | grep -Eo "^\s{2}[a-z]+")
echo " " _omb_util_print " "
} }
function __vboxmanage_nic_types { function __vboxmanage_nic_types {
echo $(vboxmanage | _omb_util_print $(vboxmanage |
grep ' nic<' | grep ' nic<' |
sed 's/.*nic<1-N> \([a-z\|]*\).*/\1/' | tr '|' ' ') sed 's/.*nic<1-N> \([a-z\|]*\).*/\1/' | tr '|' ' ')
} }
@ -155,7 +155,7 @@ function __vboxmanage_startvm {
done done
(( $MATCH == 0 )) && AVAILABLE="$AVAILABLE $VM " (( $MATCH == 0 )) && AVAILABLE="$AVAILABLE $VM "
done done
echo $AVAILABLE _omb_util_print $AVAILABLE
} }
function __vboxmanage_list { function __vboxmanage_list {
@ -173,7 +173,7 @@ function __vboxmanage_list {
PRUNED=$INPUT PRUNED=$INPUT
fi fi
echo $PRUNED _omb_util_print $PRUNED
} }
@ -190,7 +190,7 @@ function __vboxmanage_list_vms {
VMS="${VMS}${VM}" VMS="${VMS}${VM}"
done done
echo $VMS _omb_util_print $VMS
} }
function __vboxmanage_list_runningvms { function __vboxmanage_list_runningvms {
@ -206,21 +206,21 @@ function __vboxmanage_list_runningvms {
VMS="${VMS}${VM}" VMS="${VMS}${VM}"
done done
echo $VMS _omb_util_print $VMS
} }
function __vboxmanage_controlvm { function __vboxmanage_controlvm {
echo "pause resume reset poweroff savestate acpipowerbutton" _omb_util_print "pause resume reset poweroff savestate acpipowerbutton"
echo "acpisleepbutton keyboardputscancode guestmemoryballoon" _omb_util_print "acpisleepbutton keyboardputscancode guestmemoryballoon"
echo "gueststatisticsinterval usbattach usbdetach vrde vrdeport" _omb_util_print "gueststatisticsinterval usbattach usbdetach vrde vrdeport"
echo "vrdeproperty vrdevideochannelquality setvideomodehint" _omb_util_print "vrdeproperty vrdevideochannelquality setvideomodehint"
echo "screenshotpng setcredentials teleport plugcpu unplugcpu" _omb_util_print "screenshotpng setcredentials teleport plugcpu unplugcpu"
echo "cpuexecutioncap" _omb_util_print "cpuexecutioncap"
# setlinkstate<1-N> # setlinkstate<1-N>
activenics=$(__vboxmanage_showvminfo_active_nics $1) activenics=$(__vboxmanage_showvminfo_active_nics $1)
for nic in $(echo "${activenics}" | tr -d 'nic'); do for nic in $(_omb_util_print "${activenics}" | tr -d 'nic'); do
echo "setlinkstate${nic}" _omb_util_print "setlinkstate${nic}"
done done
# nic<1-N> null|nat|bridged|intnet|hostonly|generic # nic<1-N> null|nat|bridged|intnet|hostonly|generic
@ -240,14 +240,14 @@ function __vboxmanage_modifyvm {
for i in {1..8}; do for i in {1..8}; do
options="$options --nic${i}" options="$options --nic${i}"
done done
echo $options _omb_util_print $options
} }
function __vboxmanage_showvminfo_active_nics { function __vboxmanage_showvminfo_active_nics {
nics=$(vboxmanage showvminfo $1 --machinereadable | nics=$(vboxmanage showvminfo $1 --machinereadable |
awk '/^nic/ && ! /none/' | awk '/^nic/ && ! /none/' |
awk '{ split($1, names, "="); print names[1] }') awk '{ split($1, names, "="); print names[1] }')
echo $nics _omb_util_print $nics
} }
function __vboxmanage_default { function __vboxmanage_default {
@ -255,12 +255,12 @@ function __vboxmanage_default {
opts=$realopts$(vboxmanage | grep -i vboxmanage | cut -d' ' -f2 | grep -v '\[' | sort | uniq) opts=$realopts$(vboxmanage | grep -i vboxmanage | cut -d' ' -f2 | grep -v '\[' | sort | uniq)
pruned="" pruned=""
# echo "" # _omb_util_print ""
# echo "DEBUG: cur: $cur, prev: $prev" # _omb_util_print "DEBUG: cur: $cur, prev: $prev"
# echo "DEBUG: default: |$p1|$p2|$p3|$p4|" # _omb_util_print "DEBUG: default: |$p1|$p2|$p3|$p4|"
case ${cur} in case ${cur} in
-*) -*)
echo $opts _omb_util_print $opts
# COMPREPLY=($(compgen -W "${opts}" -- ${cur})) # COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0 return 0
;; ;;
@ -269,7 +269,7 @@ function __vboxmanage_default {
for WORD in $opts; do for WORD in $opts; do
MATCH=0 MATCH=0
for OPT in ${COMP_WORDS[@]}; do for OPT in ${COMP_WORDS[@]}; do
# opts=$(echo ${opts} | grep -v $OPT); # opts=$(_omb_util_print ${opts} | grep -v $OPT);
if [ "$OPT" == "$WORD" ]; then if [ "$OPT" == "$WORD" ]; then
MATCH=1 MATCH=1
break; break;
@ -297,6 +297,6 @@ function __vboxmanage_default {
done done
# COMPREPLY=($(compgen -W "${pruned}" -- ${cur})) # COMPREPLY=($(compgen -W "${pruned}" -- ${cur}))
echo $pruned _omb_util_print $pruned
return 0 return 0
} }

View File

@ -99,10 +99,10 @@ function extract {
*.zip) unzip "$1" ;; *.zip) unzip "$1" ;;
*.Z) uncompress "$1" ;; *.Z) uncompress "$1" ;;
*.7z) 7z x "$1" ;; *.7z) 7z x "$1" ;;
*) echo "'$1' cannot be extracted via extract()" ;; *) _omb_util_print "'$1' cannot be extracted via extract()" ;;
esac esac
else else
echo "'$1' is not a valid file" _omb_util_print "'$1' is not a valid file"
fi fi
} }
@ -144,13 +144,13 @@ function mkiso {
fi fi
if [ ! -f "${destpath}${isoname}.iso" ]; then if [ ! -f "${destpath}${isoname}.iso" ]; then
echo "writing ${isoname}.iso to ${destpath} from ${srcpath}" _omb_util_print "writing ${isoname}.iso to ${destpath} from ${srcpath}"
mkisofs -V "${isoname}" -iso-level 3 -r -o "${destpath}${isoname}.iso" "${srcpath}" mkisofs -V "${isoname}" -iso-level 3 -r -o "${destpath}${isoname}.iso" "${srcpath}"
else else
echo "${destpath}${isoname}.iso already exists" _omb_util_print "${destpath}${isoname}.iso already exists"
fi fi
else else
echo "mkisofs cmd does not exist, please install cdrtools" _omb_util_print "mkisofs cmd does not exist, please install cdrtools"
fi fi
} }
@ -204,7 +204,7 @@ function ips {
then then
ip addr | grep -oP 'inet \K[\d.]+' ip addr | grep -oP 'inet \K[\d.]+'
else else
echo "You don't have ifconfig or ip command installed!" _omb_util_print "You don't have ifconfig or ip command installed!"
fi fi
} }
@ -218,24 +218,23 @@ function down4me {
# ------------------------------------------------------------------- # -------------------------------------------------------------------
function myip { function myip {
res=$(curl -s checkip.dyndns.org | grep -Eo '[0-9\.]+') res=$(curl -s checkip.dyndns.org | grep -Eo '[0-9\.]+')
echo -e "Your public IP is: ${_omb_term_bold_green} $res ${_omb_term_normal}" _omb_util_print "Your public IP is: ${_omb_term_bold_green} $res ${_omb_term_normal}"
} }
# ii: display useful host related informaton # ii: display useful host related informaton
# ------------------------------------------------------------------- # -------------------------------------------------------------------
function ii { function ii {
echo -e "\\nYou are logged on ${_omb_term_brown}$HOST" _omb_util_print $'\n'"You are logged on ${_omb_term_brown}$HOST"
echo -e "\\nAdditionnal information:$NC " ; uname -a _omb_util_print $'\n'"Additionnal information:$NC "; uname -a
echo -e "\\n${_omb_term_brown}Users logged on:$NC " ; w -h _omb_util_print $'\n'"${_omb_term_brown}Users logged on:$NC "; w -h
echo -e "\\n${_omb_term_brown}Current date :$NC " ; date _omb_util_print $'\n'"${_omb_term_brown}Current date :$NC "; date
echo -e "\\n${_omb_term_brown}Machine stats :$NC " ; uptime _omb_util_print $'\n'"${_omb_term_brown}Machine stats :$NC "; uptime
[[ "$OSTYPE" == darwin* ]] && echo -e "\\n${_omb_term_brown}Current network location :$NC " ; scselect [[ "$OSTYPE" == darwin* ]] && _omb_util_print $'\n'"${_omb_term_brown}Current network location :$NC " ; scselect
echo -e "\\n${_omb_term_brown}Public facing IP Address :$NC " ;myip _omb_util_print $'\n'"${_omb_term_brown}Public facing IP Address :$NC " ;myip
[[ "$OSTYPE" == darwin* ]] && echo -e "\\n${_omb_term_brown}DNS Configuration:$NC " ; scutil --dns [[ "$OSTYPE" == darwin* ]] && _omb_util_print $'\n'"${_omb_term_brown}DNS Configuration:$NC " ; scutil --dns
echo _omb_util_print
} }
# --------------------------------------- # ---------------------------------------
# 6. SYSTEMS OPERATIONS & INFORMATION # 6. SYSTEMS OPERATIONS & INFORMATION
# --------------------------------------- # ---------------------------------------
@ -243,15 +242,15 @@ function ii {
# batch_chmod: Batch chmod for all files & sub-directories in the current one # batch_chmod: Batch chmod for all files & sub-directories in the current one
# ------------------------------------------------------------------- # -------------------------------------------------------------------
function batch_chmod { function batch_chmod {
echo -ne "${_omb_term_bold_navy}Applying 0755 permission for all directories..." _omb_util_put "${_omb_term_bold_navy}Applying 0755 permission for all directories..."
(find . -type d -print0 | xargs -0 chmod 0755) & (find . -type d -print0 | xargs -0 chmod 0755) &
spinner spinner
echo -ne "${_omb_term_normal}" _omb_util_put "${_omb_term_normal}"
echo -ne "${_omb_term_bold_navy}Applying 0644 permission for all files..." _omb_util_put "${_omb_term_bold_navy}Applying 0644 permission for all files..."
(find . -type f -print0 | xargs -0 chmod 0644) & (find . -type f -print0 | xargs -0 chmod 0644) &
spinner spinner
echo -ne "${_omb_term_normal}" _omb_util_put "${_omb_term_normal}"
} }
# usage: disk usage per directory, in Mac OS X and Linux # usage: disk usage per directory, in Mac OS X and Linux
@ -292,9 +291,9 @@ function pickfrom {
# shellcheck disable=SC2086 # shellcheck disable=SC2086
function passgen { function passgen {
local i pass length=${1:-4} local i pass length=${1:-4}
pass=$(echo $(for i in $(eval echo "{1..$length}"); do pickfrom /usr/share/dict/words; done)) pass=$(_omb_util_print $(for ((i=1;i<=length;i++)); do pickfrom /usr/share/dict/words; done))
echo "With spaces (easier to memorize): $pass" _omb_util_print "With spaces (easier to memorize): $pass"
echo "Without (use this as the password): $(echo $pass | tr -d ' ')" _omb_util_print "Without (use this as the password): $(tr -d ' ' <<< "$pass")"
} }

View File

@ -87,7 +87,7 @@ _omb_util_alias_delayed ls
# Add an "alert" alias for long running commands. Use like so: # Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert # sleep 10; alert
if _omb_util_binary_exists notify-send; then if _omb_util_binary_exists notify-send; then
_omb_util_alias alert='notify-send --urgency=low -i "$(if (($? == 0)); then echo terminal; else echo error; fi)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' _omb_util_alias alert='notify-send --urgency=low -i "$(if (($? == 0)); then _omb_util_print terminal; else _omb_util_print error; fi)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
fi fi
# Alias definitions. # Alias definitions.

View File

@ -25,7 +25,7 @@ function open_command() {
cygwin*) open_cmd='cygstart' ;; cygwin*) open_cmd='cygstart' ;;
linux*) open_cmd='xdg-open' ;; linux*) open_cmd='xdg-open' ;;
msys*) open_cmd='start ""' ;; msys*) open_cmd='start ""' ;;
*) echo "Platform $OSTYPE not supported" *) _omb_util_print "Platform $OSTYPE not supported"
return 1 return 1
;; ;;
esac esac
@ -51,12 +51,12 @@ function open_command() {
# #
if ((_omb_bash_version >= 40000)); then if ((_omb_bash_version >= 40000)); then
function alias_value() { function alias_value() {
[[ ${BASH_ALIASES[$1]+set} ]] && echo "${BASH_ALIASES[$1]}" [[ ${BASH_ALIASES[$1]+set} ]] && _omb_util_print "${BASH_ALIASES[$1]}"
} }
else else
function alias_value() { function alias_value() {
local value= local value=
value=$(alias "$1" 2>/dev/null) && eval "value=${value#*=}" && echo "$value" value=$(alias "$1" 2>/dev/null) && eval "value=${value#*=}" && _omb_util_print "$value"
} }
fi fi
@ -72,7 +72,7 @@ fi
# Always 0 # Always 0
# #
function try_alias_value() { function try_alias_value() {
alias_value "$1" || echo "$1" alias_value "$1" || _omb_util_print "$1"
} }
# #

View File

@ -15,7 +15,7 @@ _omb_deprecate_declare 20000 POST_1_7_2_GIT _omb_git_post_1_7_2 sync
# if [[ $(_omb_prompt_git config --get oh-my-bash.hide-status 2>/dev/null) != 1 ]]; then # if [[ $(_omb_prompt_git config --get oh-my-bash.hide-status 2>/dev/null) != 1 ]]; then
# ref=$(_omb_prompt_git symbolic-ref HEAD 2> /dev/null) || \ # ref=$(_omb_prompt_git symbolic-ref HEAD 2> /dev/null) || \
# ref=$(_omb_prompt_git rev-parse --short HEAD 2> /dev/null) || return 0 # ref=$(_omb_prompt_git rev-parse --short HEAD 2> /dev/null) || return 0
# echo "$OSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$OSH_THEME_GIT_PROMPT_SUFFIX" # _omb_util_print "$OSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$OSH_THEME_GIT_PROMPT_SUFFIX"
# fi # fi
# } # }
@ -33,9 +33,9 @@ function parse_git_dirty {
STATUS=$(_omb_prompt_git status "${FLAGS[@]}" 2> /dev/null | tail -n1) STATUS=$(_omb_prompt_git status "${FLAGS[@]}" 2> /dev/null | tail -n1)
fi fi
if [[ $STATUS ]]; then if [[ $STATUS ]]; then
echo "$OSH_THEME_GIT_PROMPT_DIRTY" _omb_util_print "$OSH_THEME_GIT_PROMPT_DIRTY"
else else
echo "$OSH_THEME_GIT_PROMPT_CLEAN" _omb_util_print "$OSH_THEME_GIT_PROMPT_CLEAN"
fi fi
} }
@ -65,7 +65,7 @@ function git_remote_status {
git_remote_status=$OSH_THEME_GIT_PROMPT_REMOTE_STATUS_PREFIX$remote$git_remote_status_detailed$OSH_THEME_GIT_PROMPT_REMOTE_STATUS_SUFFIX git_remote_status=$OSH_THEME_GIT_PROMPT_REMOTE_STATUS_PREFIX$remote$git_remote_status_detailed$OSH_THEME_GIT_PROMPT_REMOTE_STATUS_SUFFIX
fi fi
echo "$git_remote_status" _omb_util_print "$git_remote_status"
fi fi
} }
@ -81,7 +81,7 @@ function git_current_branch {
[[ $ret == 128 ]] && return # no git repo. [[ $ret == 128 ]] && return # no git repo.
ref=$(_omb_prompt_git rev-parse --short HEAD 2> /dev/null) || return ref=$(_omb_prompt_git rev-parse --short HEAD 2> /dev/null) || return
fi fi
echo ${ref#refs/heads/} _omb_util_print ${ref#refs/heads/}
} }
@ -90,7 +90,7 @@ function git_commits_ahead {
if _omb_prompt_git rev-parse --git-dir &>/dev/null; then if _omb_prompt_git rev-parse --git-dir &>/dev/null; then
local commits=$(_omb_prompt_git rev-list --count @{upstream}..HEAD) local commits=$(_omb_prompt_git rev-list --count @{upstream}..HEAD)
if ((commits != 0)); then if ((commits != 0)); then
echo "$OSH_THEME_GIT_COMMITS_AHEAD_PREFIX$commits$OSH_THEME_GIT_COMMITS_AHEAD_SUFFIX" _omb_util_print "$OSH_THEME_GIT_COMMITS_AHEAD_PREFIX$commits$OSH_THEME_GIT_COMMITS_AHEAD_SUFFIX"
fi fi
fi fi
} }
@ -100,7 +100,7 @@ function git_commits_behind {
if _omb_prompt_git rev-parse --git-dir &>/dev/null; then if _omb_prompt_git rev-parse --git-dir &>/dev/null; then
local commits=$(_omb_prompt_git rev-list --count HEAD..@{upstream}) local commits=$(_omb_prompt_git rev-list --count HEAD..@{upstream})
if ((commits != 0)); then if ((commits != 0)); then
echo "$OSH_THEME_GIT_COMMITS_BEHIND_PREFIX$commits$OSH_THEME_GIT_COMMITS_BEHIND_SUFFIX" _omb_util_print "$OSH_THEME_GIT_COMMITS_BEHIND_PREFIX$commits$OSH_THEME_GIT_COMMITS_BEHIND_SUFFIX"
fi fi
fi fi
} }
@ -108,23 +108,23 @@ function git_commits_behind {
# Outputs if current branch is ahead of remote # Outputs if current branch is ahead of remote
function git_prompt_ahead { function git_prompt_ahead {
if [[ $(_omb_prompt_git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null) ]]; then if [[ $(_omb_prompt_git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null) ]]; then
echo "$OSH_THEME_GIT_PROMPT_AHEAD" _omb_util_print "$OSH_THEME_GIT_PROMPT_AHEAD"
fi fi
} }
# Outputs if current branch is behind remote # Outputs if current branch is behind remote
function git_prompt_behind { function git_prompt_behind {
if [[ $(_omb_prompt_git rev-list HEAD..origin/$(git_current_branch) 2> /dev/null) ]]; then if [[ $(_omb_prompt_git rev-list HEAD..origin/$(git_current_branch) 2> /dev/null) ]]; then
echo "$OSH_THEME_GIT_PROMPT_BEHIND" _omb_util_print "$OSH_THEME_GIT_PROMPT_BEHIND"
fi fi
} }
# Outputs if current branch exists on remote or not # Outputs if current branch exists on remote or not
function git_prompt_remote { function git_prompt_remote {
if [[ $(_omb_prompt_git show-ref origin/$(git_current_branch) 2> /dev/null) ]]; then if [[ $(_omb_prompt_git show-ref origin/$(git_current_branch) 2> /dev/null) ]]; then
echo "$OSH_THEME_GIT_PROMPT_REMOTE_EXISTS" _omb_util_print "$OSH_THEME_GIT_PROMPT_REMOTE_EXISTS"
else else
echo "$OSH_THEME_GIT_PROMPT_REMOTE_MISSING" _omb_util_print "$OSH_THEME_GIT_PROMPT_REMOTE_MISSING"
fi fi
} }
@ -132,14 +132,14 @@ function git_prompt_remote {
function git_prompt_short_sha { function git_prompt_short_sha {
local SHA local SHA
SHA=$(_omb_prompt_git rev-parse --short HEAD 2> /dev/null) && SHA=$(_omb_prompt_git rev-parse --short HEAD 2> /dev/null) &&
echo "$OSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$OSH_THEME_GIT_PROMPT_SHA_AFTER" _omb_util_print "$OSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$OSH_THEME_GIT_PROMPT_SHA_AFTER"
} }
# Formats prompt string for current git commit long SHA # Formats prompt string for current git commit long SHA
function git_prompt_long_sha { function git_prompt_long_sha {
local SHA local SHA
SHA=$(_omb_prompt_git rev-parse HEAD 2> /dev/null) && SHA=$(_omb_prompt_git rev-parse HEAD 2> /dev/null) &&
echo "$OSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$OSH_THEME_GIT_PROMPT_SHA_AFTER" _omb_util_print "$OSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$OSH_THEME_GIT_PROMPT_SHA_AFTER"
} }
# Get the status of the working tree # Get the status of the working tree
@ -176,7 +176,7 @@ function git_prompt_status {
if command grep -q '^## [^ ]\+ .*diverged' <<< "$INDEX"; then if command grep -q '^## [^ ]\+ .*diverged' <<< "$INDEX"; then
STATUS=$OSH_THEME_GIT_PROMPT_DIVERGED$STATUS STATUS=$OSH_THEME_GIT_PROMPT_DIVERGED$STATUS
fi fi
echo "$STATUS" _omb_util_print "$STATUS"
} }
# Compares the provided version of git to the version installed and on path # Compares the provided version of git to the version installed and on path
@ -191,15 +191,15 @@ function git_compare_version {
local i local i
for i in {0..2}; do for i in {0..2}; do
if ((INSTALLED_GIT_VERSION[i] > INPUT_GIT_VERSION[i])); then if ((INSTALLED_GIT_VERSION[i] > INPUT_GIT_VERSION[i])); then
echo 1 _omb_util_print 1
return 0 return 0
fi fi
if ((INSTALLED_GIT_VERSION[i] < INPUT_GIT_VERSION[i])); then if ((INSTALLED_GIT_VERSION[i] < INPUT_GIT_VERSION[i])); then
echo -1 _omb_util_print -1
return 0 return 0
fi fi
done done
echo 0 _omb_util_print 0
} }
# Outputs the name of the current user # Outputs the name of the current user

View File

@ -2,7 +2,7 @@
# is x grep argument available? # is x grep argument available?
function _omb_grep_flag_available { function _omb_grep_flag_available {
echo | grep "$1" "" >/dev/null 2>&1 : | grep "$1" "" >/dev/null 2>&1
} }
_omb_grep_options=() _omb_grep_options=()

View File

@ -6,5 +6,5 @@ function nvm_prompt_info() {
nvm_prompt=$(node -v 2>/dev/null) nvm_prompt=$(node -v 2>/dev/null)
[[ "${nvm_prompt}x" == "x" ]] && return [[ "${nvm_prompt}x" == "x" ]] && return
nvm_prompt=${nvm_prompt:1} nvm_prompt=${nvm_prompt:1}
echo "${OSH_THEME_NVM_PROMPT_PREFIX}${nvm_prompt}${OSH_THEME_NVM_PROMPT_SUFFIX}" _omb_util_print "${OSH_THEME_NVM_PROMPT_PREFIX}${nvm_prompt}${OSH_THEME_NVM_PROMPT_SUFFIX}"
} }

View File

@ -11,7 +11,7 @@ function _omb_deprecate_warning {
else else
func= func=
fi fi
printf '%s\n' "$src$sep$line$func$sep$_omb_term_reset $msg" _omb_util_print "$src$sep$line$func$sep$_omb_term_reset $msg"
} }
function _omb_deprecate_function__notify { function _omb_deprecate_function__notify {
@ -62,9 +62,9 @@ function _omb_deprecate_declare__init {
__opts=$__opts:notified __opts=$__opts:notified
if ((_omb_version >= __ver)); then if ((_omb_version >= __ver)); then
if [[ $__new ]]; then if [[ $__new ]]; then
printf '%s\n' "oh-my-bash: The variable '$__old' is set but has been renamed to '$__new'. Please use '$__new'." _omb_util_print "oh-my-bash: The variable '$__old' is set but has been renamed to '$__new'. Please use '$__new'."
else else
printf '%s\n' "oh-my-bash: The variable '$__old' is set but has been deprecated.${__msg+ $__msg}" _omb_util_print "oh-my-bash: The variable '$__old' is set but has been deprecated.${__msg+ $__msg}"
fi >/dev/tty fi >/dev/tty
fi fi
if [[ $__new && ! ${!__new+set} ]]; then if [[ $__new && ! ${!__new+set} ]]; then
@ -104,7 +104,7 @@ if ((_omb_bash_version >= 40300)); then
_omb_deprecate_warning 1 "The variable '$esc_old' has been deprecated.${__msg+ $__msg}" _omb_deprecate_warning 1 "The variable '$esc_old' has been deprecated.${__msg+ $__msg}"
fi >/dev/tty fi >/dev/tty
fi fi
echo 1 _omb_util_print 1
} }
else else
_omb_deprecate_declare=() _omb_deprecate_declare=()
@ -152,9 +152,9 @@ else
local esc_old=$_omb_term_bold_brown$__old$_omb_term_reset local esc_old=$_omb_term_bold_brown$__old$_omb_term_reset
local esc_new=$_omb_term_bold_navy$__new$_omb_term_reset local esc_new=$_omb_term_bold_navy$__new$_omb_term_reset
if [[ $__new ]]; then if [[ $__new ]]; then
printf '%s\n' "oh-my-bash: The variable '$esc_old' is changed but has been renamed to '$esc_new'. Please use '$esc_new'." _omb_util_print "oh-my-bash: The variable '$esc_old' is changed but has been renamed to '$esc_new'. Please use '$esc_new'."
else else
printf '%s\n' "oh-my-bash: The variable '$esc_old' is changed but has been deprecated.${__msg+ $__msg}" _omb_util_print "oh-my-bash: The variable '$esc_old' is changed but has been deprecated.${__msg+ $__msg}"
fi >/dev/tty fi >/dev/tty
fi fi
@ -215,7 +215,7 @@ if ((_omb_bash_version >= 40300)); then
_omb_deprecate_warning 1 "The variable '$esc_old' has been deprecated.${__msg+ $__msg}" >&2 _omb_deprecate_warning 1 "The variable '$esc_old' has been deprecated.${__msg+ $__msg}" >&2
fi fi
fi fi
echo 1 _omb_util_print 1
} }
function _omb_deprecate_const__sync { function _omb_deprecate_const__sync {
local __index __old __curval __compaction= local __index __old __curval __compaction=

View File

@ -185,7 +185,7 @@ function git_clean_branch {
local stripped_ref=${unsafe_ref##refs/heads/} local stripped_ref=${unsafe_ref##refs/heads/}
local clean_ref=${stripped_ref//[\$\`\\]/-} local clean_ref=${stripped_ref//[\$\`\\]/-}
clean_ref=${clean_ref//[^[:print:]]/-} # strip escape sequences, etc. clean_ref=${clean_ref//[^[:print:]]/-} # strip escape sequences, etc.
echo $clean_ref _omb_util_print $clean_ref
} }
function git_prompt_minimal_info { function git_prompt_minimal_info {
@ -360,7 +360,7 @@ function get_hg_root {
while [ "$CURRENT_DIR" != "/" ]; do while [ "$CURRENT_DIR" != "/" ]; do
if [ -d "$CURRENT_DIR/.hg" ]; then if [ -d "$CURRENT_DIR/.hg" ]; then
echo "$CURRENT_DIR/.hg" _omb_util_print "$CURRENT_DIR/.hg"
return return
fi fi
@ -620,7 +620,7 @@ if ! _omb_util_command_exists 'battery_charge' ; then
# if user has installed battery plugin, skip this... # if user has installed battery plugin, skip this...
function battery_charge (){ function battery_charge (){
# no op # no op
echo -n _omb_util_put
} }
fi fi
@ -629,15 +629,15 @@ fi
if ! _omb_util_command_exists 'battery_percentage' ; then if ! _omb_util_command_exists 'battery_percentage' ; then
function battery_char (){ function battery_char (){
# no op # no op
echo -n _omb_util_put
} }
fi fi
function aws_profile { function aws_profile {
if [[ $AWS_DEFAULT_PROFILE ]]; then if [[ $AWS_DEFAULT_PROFILE ]]; then
echo -e "${AWS_DEFAULT_PROFILE}" _omb_util_print "$AWS_DEFAULT_PROFILE"
else else
echo -e "default" _omb_util_print "default"
fi fi
} }

View File

@ -53,14 +53,14 @@ function _omb_theme__construct_sgr {
else else
color="8;5;$(((r * 36 + b * 6 + g) / 51 + 16))" color="8;5;$(((r * 36 + b * 6 + g) / 51 + 16))"
fi ;; fi ;;
*) printf '%s\n' "_omb_theme_color: unknown color '$color'" >&2 *) _omb_util_print "_omb_theme_color: unknown color '$color'" >&2
continue ;; continue ;;
esac esac
out=${out:+$out;}$prefix$color ;; out=${out:+$out;}$prefix$color ;;
'') '')
out="${out:+$out;}$*" ;; out="${out:+$out;}$*" ;;
*) *)
printf '%s\n' "_omb_theme_color: unknown token '$next'" >&2 ;; _omb_util_print "_omb_theme_color: unknown token '$next'" >&2 ;;
esac esac
done done

View File

@ -1,5 +1,18 @@
#! bash oh-my-bash.module #! bash oh-my-bash.module
function _omb_util_put {
printf '%s' "$@"
}
function _omb_util_print {
local IFS=$' \t\n'
printf '%s\n' "$*"
}
function _omb_util_print_lines {
printf '%s\n' "$@"
}
function _omb_string_escape_prompt { function _omb_string_escape_prompt {
REPLY=$1 REPLY=$1
local specialchars='\`$' local specialchars='\`$'

View File

@ -8,6 +8,9 @@
## print the real path of the filename which is possibly a symbolic link. ## print the real path of the filename which is possibly a symbolic link.
## ##
# use _omb_util_print
_omb_module_require lib:omb-util
# use _omb_util_function_exists, _omb_util_binary_exists
_omb_module_require lib:utils _omb_module_require lib:utils
if ((_omb_bash_version >= 40000)); then if ((_omb_bash_version >= 40000)); then
@ -73,7 +76,7 @@ function _omb_util_readlink__resolve_loop {
fi fi
while [[ $path == ?*/ ]]; do path=${path%/}; done while [[ $path == ?*/ ]]; do path=${path%/}; done
done done
echo "$path" _omb_util_print "$path"
} }
function _omb_util_readlink__resolve { function _omb_util_readlink__resolve {
@ -105,6 +108,6 @@ function _omb_util_readlink {
if [[ -h $1 ]]; then if [[ -h $1 ]]; then
_omb_util_readlink__resolve "$1" _omb_util_readlink__resolve "$1"
else else
echo "$1" _omb_util_print "$1"
fi fi
} }

View File

@ -77,7 +77,7 @@ function _omb_util_setexit {
} }
function _omb_util_defun_print { function _omb_util_defun_print {
builtin eval -- "function $1 { local $3; $2 \"\$@\" && printf '%s\n' \"\${$3}\"; }" builtin eval -- "function $1 { local $3; $2 \"\$@\" && _omb_util_print \"\${$3}\"; }"
} }
# #

View File

@ -69,7 +69,7 @@ function _omb_module_require {
completion) locations=({"$OSH_CUSTOM","$OSH"}/completions/"$name".completion.{bash,sh}) ;; completion) locations=({"$OSH_CUSTOM","$OSH"}/completions/"$name".completion.{bash,sh}) ;;
theme) locations=({"$OSH_CUSTOM"{,/themes},"$OSH"/themes}/"$name"/"$name".theme.{bash,sh}) ;; theme) locations=({"$OSH_CUSTOM"{,/themes},"$OSH"/themes}/"$name"/"$name".theme.{bash,sh}) ;;
*) *)
echo "oh-my-bash (module_require): unknown module type '$type'." >&2 printf '%s\n' "oh-my-bash (module_require): unknown module type '$type'." >&2
status=2 status=2
continue ;; continue ;;
esac esac
@ -83,7 +83,7 @@ function _omb_module_require {
fi fi
done done
echo "oh-my-bash (module_require): module '$type:$name' not found." >&2 printf '%s\n' "oh-my-bash (module_require): module '$type:$name' not found." >&2
status=127 status=127
done done
@ -108,6 +108,7 @@ function _omb_module_require_theme { _omb_module_require "${@/#/theme:}"; }
# Load all of the config files in ~/.oh-my-bash/lib that end in .sh # Load all of the config files in ~/.oh-my-bash/lib that end in .sh
# TIP: Add files you don't want in git to .gitignore # TIP: Add files you don't want in git to .gitignore
_omb_module_require_lib omb-util
_omb_module_require_lib utils _omb_module_require_lib utils
_omb_util_glob_expand _omb_init_files '{"$OSH","$OSH_CUSTOM"}/lib/*.{bash,sh}' _omb_util_glob_expand _omb_init_files '{"$OSH","$OSH_CUSTOM"}/lib/*.{bash,sh}'
_omb_init_files=("${_omb_init_files[@]##*/}") _omb_init_files=("${_omb_init_files[@]##*/}")
@ -162,7 +163,7 @@ if [[ $OSH_THEME == random ]]; then
OMB_THEME_RANDOM_SELECTED=${_omb_init_file##*/} OMB_THEME_RANDOM_SELECTED=${_omb_init_file##*/}
OMB_THEME_RANDOM_SELECTED=${OMB_THEME_RANDOM_SELECTED%.theme.bash} OMB_THEME_RANDOM_SELECTED=${OMB_THEME_RANDOM_SELECTED%.theme.bash}
OMB_THEME_RANDOM_SELECTED=${OMB_THEME_RANDOM_SELECTED%.theme.sh} OMB_THEME_RANDOM_SELECTED=${OMB_THEME_RANDOM_SELECTED%.theme.sh}
echo "[oh-my-bash] Random theme '$OMB_THEME_RANDOM_SELECTED' ($_omb_init_file) loaded..." printf '%s\n' "[oh-my-bash] Random theme '$OMB_THEME_RANDOM_SELECTED' ($_omb_init_file) loaded..."
fi fi
unset -v _omb_init_files _omb_init_file unset -v _omb_init_files _omb_init_file
elif [[ $OSH_THEME ]]; then elif [[ $OSH_THEME ]]; then

View File

@ -1,18 +1,18 @@
#! bash oh-my-bash.module #! bash oh-my-bash.module
# Functions # Functions
function ansible-version(){ function ansible-version(){
ansible --version ansible --version
} }
function ansible-role-init(){ function ansible-role-init(){
if ! [ -z $1] ; then if ! [ -z $1] ; then
echo "Ansible Role : $1 Creating...." _omb_util_print "Ansible Role : $1 Creating...."
ansible-galaxy init $1 ansible-galaxy init $1
tree $1 tree $1
else else
echo "Usage : ansible-role-init <role name>" _omb_util_print "Usage : ansible-role-init <role name>"
echo "Example : ansible-role-init role1" _omb_util_print "Example : ansible-role-init role1"
fi fi
} }
# Aliases # Aliases

View File

@ -10,7 +10,7 @@
export AWS_HOME=~/.aws export AWS_HOME=~/.aws
function agp { function agp {
echo $AWS_DEFAULT_PROFILE _omb_util_print $AWS_DEFAULT_PROFILE
} }
function asp { function asp {

View File

@ -100,7 +100,7 @@ function bm {
*) *)
if [[ $1 == -* ]]; then if [[ $1 == -* ]]; then
# unrecognized option. echo error message and usage [ bm -X ] # unrecognized option. echo error message and usage [ bm -X ]
echo "Unknown option '$1'" _omb_util_print "Unknown option '$1'"
_bashmarks_usage _bashmarks_usage
kill -SIGINT $$ kill -SIGINT $$
exit 1 exit 1
@ -117,21 +117,21 @@ function bm {
# print usage information # print usage information
function _bashmarks_usage { function _bashmarks_usage {
echo 'USAGE:' _omb_util_print 'USAGE:'
echo "bm -h - Prints this usage info" _omb_util_print "bm -h - Prints this usage info"
echo 'bm -a <bookmark_name> - Saves the current directory as "bookmark_name"' _omb_util_print 'bm -a <bookmark_name> - Saves the current directory as "bookmark_name"'
echo 'bm [-g] <bookmark_name> - Goes (cd) to the directory associated with "bookmark_name"' _omb_util_print 'bm [-g] <bookmark_name> - Goes (cd) to the directory associated with "bookmark_name"'
echo 'bm -p <bookmark_name> - Prints the directory associated with "bookmark_name"' _omb_util_print 'bm -p <bookmark_name> - Prints the directory associated with "bookmark_name"'
echo 'bm -d <bookmark_name> - Deletes the bookmark' _omb_util_print 'bm -d <bookmark_name> - Deletes the bookmark'
echo 'bm -l - Lists all available bookmarks' _omb_util_print 'bm -l - Lists all available bookmarks'
} }
# save current directory to bookmarks # save current directory to bookmarks
function _bashmarks_save { function _bashmarks_save {
if _bashmarks_is_valid_bookmark_name "$@"; then if _bashmarks_is_valid_bookmark_name "$@"; then
_bashmarks_purge_line "$BASHMARKS_SDIRS" "export DIR_$1=" _bashmarks_purge_line "$BASHMARKS_SDIRS" "export DIR_$1="
CURDIR=$(echo $PWD| sed "s#^$HOME#\$HOME#g") CURDIR=$(sed "s#^$HOME#\$HOME#g" <<< "$PWD")
echo "export DIR_$1=\"$CURDIR\"" >> "$BASHMARKS_SDIRS" _omb_util_print "export DIR_$1=\"$CURDIR\"" >> "$BASHMARKS_SDIRS"
fi fi
} }
@ -151,9 +151,9 @@ function _bashmarks_goto {
if [[ -d $target ]]; then if [[ -d $target ]]; then
cd "$target" cd "$target"
elif [[ ! $target ]]; then elif [[ ! $target ]]; then
printf '%s\n' "${_omb_term_brown}WARNING: '${1}' bashmark does not exist${_omb_term_reset}" _omb_util_print "${_omb_term_brown}WARNING: '${1}' bashmark does not exist${_omb_term_reset}"
else else
printf '%s\n' "${_omb_term_brown}WARNING: '${target}' does not exist${_omb_term_reset}" _omb_util_print "${_omb_term_brown}WARNING: '${target}' does not exist${_omb_term_reset}"
fi fi
} }
@ -184,11 +184,11 @@ function _bashmarks_is_valid_bookmark_name {
local exit_message="" local exit_message=""
if [[ ! $1 ]]; then if [[ ! $1 ]]; then
exit_message="bookmark name required" exit_message="bookmark name required"
echo "$exit_message" >&2 _omb_util_print "$exit_message" >&2
return 1 return 1
elif [[ $1 == *[!A-Za-z0-9_]* ]]; then elif [[ $1 == *[!A-Za-z0-9_]* ]]; then
exit_message="bookmark name is not valid" exit_message="bookmark name is not valid"
echo "$exit_message" >&2 _omb_util_print "$exit_message" >&2
return 1 return 1
fi fi
} }

View File

@ -49,65 +49,65 @@ function battery_percentage {
if _omb_util_command_exists upower; then if _omb_util_command_exists upower; then
local UPOWER_OUTPUT=$(_omb_plugin_battery__upower_print_info | sed -n 's/.*percentage[:[:blank:]]*\([0-9%]\{1,\}\)$/\1/p') local UPOWER_OUTPUT=$(_omb_plugin_battery__upower_print_info | sed -n 's/.*percentage[:[:blank:]]*\([0-9%]\{1,\}\)$/\1/p')
[[ $UPOWER_OUTPUT ]] && [[ $UPOWER_OUTPUT ]] &&
echo "${UPOWER_OUTPUT::-1}" _omb_util_print "${UPOWER_OUTPUT::-1}"
elif _omb_util_command_exists acpi; then elif _omb_util_command_exists acpi; then
local ACPI_OUTPUT=$(acpi -b) local ACPI_OUTPUT=$(acpi -b)
case $ACPI_OUTPUT in case $ACPI_OUTPUT in
*" Unknown"*) *" Unknown"*)
local PERC_OUTPUT=$(echo $ACPI_OUTPUT | head -c 22 | tail -c 2) local PERC_OUTPUT=$(head -c 22 <<< "$ACPI_OUTPUT" | tail -c 2)
case $PERC_OUTPUT in case $PERC_OUTPUT in
*%) *%)
echo "0${PERC_OUTPUT}" | head -c 2 head -c 2 <<< "0${PERC_OUTPUT}"
;; ;;
*) *)
echo ${PERC_OUTPUT} _omb_util_print ${PERC_OUTPUT}
;; ;;
esac esac
;; ;;
*" Charging"* | *" Discharging"*) *" Charging"* | *" Discharging"*)
local PERC_OUTPUT=$(echo $ACPI_OUTPUT | awk -F, '/,/{gsub(/ /, "", $0); gsub(/%/,"", $0); print $2}' ) local PERC_OUTPUT=$(awk -F, '/,/{gsub(/ /, "", $0); gsub(/%/,"", $0); print $2}' <<< "$ACPI_OUTPUT")
echo ${PERC_OUTPUT} _omb_util_print ${PERC_OUTPUT}
;; ;;
*" Full"*) *" Full"*)
echo '100' _omb_util_print '100'
;; ;;
*) *)
echo '-1' _omb_util_print '-1'
;; ;;
esac esac
elif _omb_util_command_exists pmset; then elif _omb_util_command_exists pmset; then
local PMSET_OUTPUT=$(pmset -g ps | sed -n 's/.*[[:blank:]]+*\(.*%\).*/\1/p') local PMSET_OUTPUT=$(pmset -g ps | sed -n 's/.*[[:blank:]]+*\(.*%\).*/\1/p')
case $PMSET_OUTPUT in case $PMSET_OUTPUT in
100*) 100*)
echo '100' _omb_util_print '100'
;; ;;
*) *)
echo $PMSET_OUTPUT | head -c 2 head -c 2 <<< "$PMSET_OUTPUT"
;; ;;
esac esac
elif _omb_util_command_exists ioreg; then elif _omb_util_command_exists ioreg; then
local IOREG_OUTPUT=$(ioreg -n AppleSmartBattery -r | awk '$1~/Capacity/{c[$1]=$3} END{OFMT="%05.2f%%"; max=c["\"MaxCapacity\""]; print (max>0? 100*c["\"CurrentCapacity\""]/max: "?")}') local IOREG_OUTPUT=$(ioreg -n AppleSmartBattery -r | awk '$1~/Capacity/{c[$1]=$3} END{OFMT="%05.2f%%"; max=c["\"MaxCapacity\""]; print (max>0? 100*c["\"CurrentCapacity\""]/max: "?")}')
case $IOREG_OUTPUT in case $IOREG_OUTPUT in
100*) 100*)
echo '100' _omb_util_print '100'
;; ;;
*) *)
echo $IOREG_OUTPUT | head -c 2 head -c 2 <<< "$IOREG_OUTPUT"
;; ;;
esac esac
elif _omb_util_command_exists WMIC; then elif _omb_util_command_exists WMIC; then
local WINPC=$(echo porcent=$(WMIC PATH Win32_Battery Get EstimatedChargeRemaining /Format:List) | grep -o '[0-9]*') local WINPC=$(grep -o '[0-9]*' <<< "porcent=$(WMIC PATH Win32_Battery Get EstimatedChargeRemaining /Format:List)")
case $WINPC in case $WINPC in
100*) 100*)
echo '100' _omb_util_print '100'
;; ;;
*) *)
echo $WINPC _omb_util_print $WINPC
;; ;;
esac esac
elif [[ -r /sys/class/power_supply/BAT0/capacity ]]; then elif [[ -r /sys/class/power_supply/BAT0/capacity ]]; then
echo "$(< /sys/class/power_supply/BAT0/capacity)" _omb_util_print "$(< /sys/class/power_supply/BAT0/capacity)"
fi fi
} }
@ -128,52 +128,52 @@ function battery_charge {
case $BATTERY_PERC in case $BATTERY_PERC in
no) no)
echo "" _omb_util_print ""
;; ;;
9*) 9*)
echo "${FULL_COLOR}${F_C}${F_C}${F_C}${F_C}${F_C}${_omb_prompt_normal}" _omb_util_print "${FULL_COLOR}${F_C}${F_C}${F_C}${F_C}${F_C}${_omb_prompt_normal}"
;; ;;
8*) 8*)
echo "${FULL_COLOR}${F_C}${F_C}${F_C}${F_C}${HALF_COLOR}${F_C}${_omb_prompt_normal}" _omb_util_print "${FULL_COLOR}${F_C}${F_C}${F_C}${F_C}${HALF_COLOR}${F_C}${_omb_prompt_normal}"
;; ;;
7*) 7*)
echo "${FULL_COLOR}${F_C}${F_C}${F_C}${F_C}${DEPLETED_COLOR}${D_C}${_omb_prompt_normal}" _omb_util_print "${FULL_COLOR}${F_C}${F_C}${F_C}${F_C}${DEPLETED_COLOR}${D_C}${_omb_prompt_normal}"
;; ;;
6*) 6*)
echo "${FULL_COLOR}${F_C}${F_C}${F_C}${HALF_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${_omb_prompt_normal}" _omb_util_print "${FULL_COLOR}${F_C}${F_C}${F_C}${HALF_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${_omb_prompt_normal}"
;; ;;
5*) 5*)
echo "${FULL_COLOR}${F_C}${F_C}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${_omb_prompt_normal}" _omb_util_print "${FULL_COLOR}${F_C}${F_C}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${_omb_prompt_normal}"
;; ;;
4*) 4*)
echo "${FULL_COLOR}${F_C}${F_C}${HALF_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${_omb_prompt_normal}" _omb_util_print "${FULL_COLOR}${F_C}${F_C}${HALF_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${_omb_prompt_normal}"
;; ;;
3*) 3*)
echo "${FULL_COLOR}${F_C}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${_omb_prompt_normal}" _omb_util_print "${FULL_COLOR}${F_C}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${_omb_prompt_normal}"
;; ;;
2*) 2*)
echo "${FULL_COLOR}${F_C}${HALF_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${_omb_prompt_normal}" _omb_util_print "${FULL_COLOR}${F_C}${HALF_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${_omb_prompt_normal}"
;; ;;
1*) 1*)
echo "${FULL_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${_omb_prompt_normal}" _omb_util_print "${FULL_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${_omb_prompt_normal}"
;; ;;
05) 05)
echo "${DANGER_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${_omb_prompt_normal}" _omb_util_print "${DANGER_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${_omb_prompt_normal}"
;; ;;
04) 04)
echo "${DANGER_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${_omb_prompt_normal}" _omb_util_print "${DANGER_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${_omb_prompt_normal}"
;; ;;
03) 03)
echo "${DANGER_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${_omb_prompt_normal}" _omb_util_print "${DANGER_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${_omb_prompt_normal}"
;; ;;
02) 02)
echo "${DANGER_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${_omb_prompt_normal}" _omb_util_print "${DANGER_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${_omb_prompt_normal}"
;; ;;
0*) 0*)
echo "${HALF_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${_omb_prompt_normal}" _omb_util_print "${HALF_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${_omb_prompt_normal}"
;; ;;
*) *)
echo "${DANGER_COLOR}UNPLG${_omb_prompt_normal}" _omb_util_print "${DANGER_COLOR}UNPLG${_omb_prompt_normal}"
;; ;;
esac esac
} }

View File

@ -15,12 +15,12 @@ function current_repository() {
if ! $_omb_git_git_cmd rev-parse --is-inside-work-tree &> /dev/null; then if ! $_omb_git_git_cmd rev-parse --is-inside-work-tree &> /dev/null; then
return return
fi fi
echo $($_omb_git_git_cmd remote -v | cut -d':' -f 2) _omb_util_print $($_omb_git_git_cmd remote -v | cut -d':' -f 2)
} }
# Warn if the current branch is a WIP # Warn if the current branch is a WIP
function work_in_progress() { function work_in_progress() {
if $(git log -n 1 2>/dev/null | grep -q -c "\-\-wip\-\-"); then if $(git log -n 1 2>/dev/null | grep -q -c "\-\-wip\-\-"); then
echo "WIP!!" _omb_util_print "WIP!!"
fi fi
} }
@ -30,11 +30,11 @@ function git_develop_branch() {
local branch local branch
for branch in dev devel development; do for branch in dev devel development; do
if command git show-ref -q --verify refs/heads/"$branch"; then if command git show-ref -q --verify refs/heads/"$branch"; then
echo "$branch" _omb_util_print "$branch"
return return
fi fi
done done
echo develop _omb_util_print develop
} }
# Check if main exists and use instead of master # Check if main exists and use instead of master
@ -43,11 +43,11 @@ function git_main_branch() {
local ref local ref
for ref in refs/{heads,remotes/{origin,upstream}}/{main,trunk,mainline,default}; do for ref in refs/{heads,remotes/{origin,upstream}}/{main,trunk,mainline,default}; do
if command git show-ref -q --verify "$ref"; then if command git show-ref -q --verify "$ref"; then
echo "${ref##*/}" _omb_util_print "${ref##*/}"
return return
fi fi
done done
echo master _omb_util_print master
} }
# #
@ -306,7 +306,7 @@ alias grhh='command git reset --hard'
alias grhk='command git reset --keep' alias grhk='command git reset --keep'
alias grhs='command git reset --soft' alias grhs='command git reset --soft'
alias groh='command git reset "origin/$(git_current_branch)" --hard' alias groh='command git reset "origin/$(git_current_branch)" --hard'
alias grt='cd $(command git rev-parse --show-toplevel || echo ".")' alias grt='cd $(command git rev-parse --show-toplevel || _omb_util_print ".")'
alias gru='command git reset --' alias gru='command git reset --'
alias grs='command git restore' alias grs='command git restore'

View File

@ -50,7 +50,7 @@ if _omb_util_command_exists nvm && [[ ${OMB_PLUGIN_NVM_AUTO_USE-} == true ]]; th
while [[ $path && ! -e $path/$1 ]]; do while [[ $path && ! -e $path/$1 ]]; do
path=${path%/*} path=${path%/*}
done done
echo "$path" _omb_util_print "$path"
} }
function _omb_plugin_nvm_cd { function _omb_plugin_nvm_cd {

View File

@ -35,26 +35,26 @@ function progress()
PARAM_PROGRESS=$1; PARAM_PROGRESS=$1;
PARAM_STATUS=$2; PARAM_STATUS=$2;
if [ $CURRENT_PROGRESS -le 0 -a $PARAM_PROGRESS -ge 0 ] ; then echo -ne "[..........................] (0%) $PARAM_PHASE \r" ; delay; fi; if [ $CURRENT_PROGRESS -le 0 -a $PARAM_PROGRESS -ge 0 ] ; then printf "[..........................] (0%) %s \r" "$PARAM_PHASE" ; delay; fi;
if [ $CURRENT_PROGRESS -le 5 -a $PARAM_PROGRESS -ge 5 ] ; then echo -ne "[#.........................] (5%) $PARAM_PHASE \r" ; delay; fi; if [ $CURRENT_PROGRESS -le 5 -a $PARAM_PROGRESS -ge 5 ] ; then printf "[#.........................] (5%) %s \r" "$PARAM_PHASE" ; delay; fi;
if [ $CURRENT_PROGRESS -le 10 -a $PARAM_PROGRESS -ge 10 ]; then echo -ne "[##........................] (10%) $PARAM_PHASE \r" ; delay; fi; if [ $CURRENT_PROGRESS -le 10 -a $PARAM_PROGRESS -ge 10 ]; then printf "[##........................] (10%) %s \r" "$PARAM_PHASE" ; delay; fi;
if [ $CURRENT_PROGRESS -le 15 -a $PARAM_PROGRESS -ge 15 ]; then echo -ne "[###.......................] (15%) $PARAM_PHASE \r" ; delay; fi; if [ $CURRENT_PROGRESS -le 15 -a $PARAM_PROGRESS -ge 15 ]; then printf "[###.......................] (15%) %s \r" "$PARAM_PHASE" ; delay; fi;
if [ $CURRENT_PROGRESS -le 20 -a $PARAM_PROGRESS -ge 20 ]; then echo -ne "[####......................] (20%) $PARAM_PHASE \r" ; delay; fi; if [ $CURRENT_PROGRESS -le 20 -a $PARAM_PROGRESS -ge 20 ]; then printf "[####......................] (20%) %s \r" "$PARAM_PHASE" ; delay; fi;
if [ $CURRENT_PROGRESS -le 25 -a $PARAM_PROGRESS -ge 25 ]; then echo -ne "[#####.....................] (25%) $PARAM_PHASE \r" ; delay; fi; if [ $CURRENT_PROGRESS -le 25 -a $PARAM_PROGRESS -ge 25 ]; then printf "[#####.....................] (25%) %s \r" "$PARAM_PHASE" ; delay; fi;
if [ $CURRENT_PROGRESS -le 30 -a $PARAM_PROGRESS -ge 30 ]; then echo -ne "[######....................] (30%) $PARAM_PHASE \r" ; delay; fi; if [ $CURRENT_PROGRESS -le 30 -a $PARAM_PROGRESS -ge 30 ]; then printf "[######....................] (30%) %s \r" "$PARAM_PHASE" ; delay; fi;
if [ $CURRENT_PROGRESS -le 35 -a $PARAM_PROGRESS -ge 35 ]; then echo -ne "[#######...................] (35%) $PARAM_PHASE \r" ; delay; fi; if [ $CURRENT_PROGRESS -le 35 -a $PARAM_PROGRESS -ge 35 ]; then printf "[#######...................] (35%) %s \r" "$PARAM_PHASE" ; delay; fi;
if [ $CURRENT_PROGRESS -le 40 -a $PARAM_PROGRESS -ge 40 ]; then echo -ne "[########..................] (40%) $PARAM_PHASE \r" ; delay; fi; if [ $CURRENT_PROGRESS -le 40 -a $PARAM_PROGRESS -ge 40 ]; then printf "[########..................] (40%) %s \r" "$PARAM_PHASE" ; delay; fi;
if [ $CURRENT_PROGRESS -le 45 -a $PARAM_PROGRESS -ge 45 ]; then echo -ne "[#########.................] (45%) $PARAM_PHASE \r" ; delay; fi; if [ $CURRENT_PROGRESS -le 45 -a $PARAM_PROGRESS -ge 45 ]; then printf "[#########.................] (45%) %s \r" "$PARAM_PHASE" ; delay; fi;
if [ $CURRENT_PROGRESS -le 50 -a $PARAM_PROGRESS -ge 50 ]; then echo -ne "[##########................] (50%) $PARAM_PHASE \r" ; delay; fi; if [ $CURRENT_PROGRESS -le 50 -a $PARAM_PROGRESS -ge 50 ]; then printf "[##########................] (50%) %s \r" "$PARAM_PHASE" ; delay; fi;
if [ $CURRENT_PROGRESS -le 55 -a $PARAM_PROGRESS -ge 55 ]; then echo -ne "[###########...............] (55%) $PARAM_PHASE \r" ; delay; fi; if [ $CURRENT_PROGRESS -le 55 -a $PARAM_PROGRESS -ge 55 ]; then printf "[###########...............] (55%) %s \r" "$PARAM_PHASE" ; delay; fi;
if [ $CURRENT_PROGRESS -le 60 -a $PARAM_PROGRESS -ge 60 ]; then echo -ne "[############..............] (60%) $PARAM_PHASE \r" ; delay; fi; if [ $CURRENT_PROGRESS -le 60 -a $PARAM_PROGRESS -ge 60 ]; then printf "[############..............] (60%) %s \r" "$PARAM_PHASE" ; delay; fi;
if [ $CURRENT_PROGRESS -le 65 -a $PARAM_PROGRESS -ge 65 ]; then echo -ne "[#############.............] (65%) $PARAM_PHASE \r" ; delay; fi; if [ $CURRENT_PROGRESS -le 65 -a $PARAM_PROGRESS -ge 65 ]; then printf "[#############.............] (65%) %s \r" "$PARAM_PHASE" ; delay; fi;
if [ $CURRENT_PROGRESS -le 70 -a $PARAM_PROGRESS -ge 70 ]; then echo -ne "[###############...........] (70%) $PARAM_PHASE \r" ; delay; fi; if [ $CURRENT_PROGRESS -le 70 -a $PARAM_PROGRESS -ge 70 ]; then printf "[###############...........] (70%) %s \r" "$PARAM_PHASE" ; delay; fi;
if [ $CURRENT_PROGRESS -le 75 -a $PARAM_PROGRESS -ge 75 ]; then echo -ne "[#################.........] (75%) $PARAM_PHASE \r" ; delay; fi; if [ $CURRENT_PROGRESS -le 75 -a $PARAM_PROGRESS -ge 75 ]; then printf "[#################.........] (75%) %s \r" "$PARAM_PHASE" ; delay; fi;
if [ $CURRENT_PROGRESS -le 80 -a $PARAM_PROGRESS -ge 80 ]; then echo -ne "[####################......] (80%) $PARAM_PHASE \r" ; delay; fi; if [ $CURRENT_PROGRESS -le 80 -a $PARAM_PROGRESS -ge 80 ]; then printf "[####################......] (80%) %s \r" "$PARAM_PHASE" ; delay; fi;
if [ $CURRENT_PROGRESS -le 85 -a $PARAM_PROGRESS -ge 85 ]; then echo -ne "[#######################...] (90%) $PARAM_PHASE \r" ; delay; fi; if [ $CURRENT_PROGRESS -le 85 -a $PARAM_PROGRESS -ge 85 ]; then printf "[#######################...] (90%) %s \r" "$PARAM_PHASE" ; delay; fi;
if [ $CURRENT_PROGRESS -le 90 -a $PARAM_PROGRESS -ge 90 ]; then echo -ne "[##########################] (100%) $PARAM_PHASE \r" ; delay; fi; if [ $CURRENT_PROGRESS -le 90 -a $PARAM_PROGRESS -ge 90 ]; then printf "[##########################] (100%) %s \r" "$PARAM_PHASE"; delay; fi;
if [ $CURRENT_PROGRESS -le 100 -a $PARAM_PROGRESS -ge 100 ];then echo -ne 'Done! \n' ; delay; fi; if [ $CURRENT_PROGRESS -le 100 -a $PARAM_PROGRESS -ge 100 ];then printf 'Done! \n' ; delay; fi;
CURRENT_PROGRESS=$PARAM_PROGRESS; CURRENT_PROGRESS=$PARAM_PROGRESS;
} }

View File

@ -8,21 +8,21 @@ function vagrant-version() {
function vagrant-init() { function vagrant-init() {
if [[ $1 ]]; then if [[ $1 ]]; then
echo "Vagrant init for : $1 Creating...." _omb_util_print "Vagrant init for : $1 Creating...."
vagrant init -m "$1" vagrant init -m "$1"
else else
echo "Usage : vai <box name>" >&2 _omb_util_print "Usage : vai <box name>" >&2
echo "Example : vai centos/7" >&2 _omb_util_print "Example : vai centos/7" >&2
return 2 return 2
fi fi
} }
function vagrant-up() { function vagrant-up() {
if [[ $1 ]]; then if [[ $1 ]]; then
echo "Vagrant up for provider : $1 Running...." _omb_util_print "Vagrant up for provider : $1 Running...."
vagrant up --provider "$1" vagrant up --provider "$1"
else else
echo "Vagrant up for provider : virtualbox Running...." _omb_util_print "Vagrant up for provider : virtualbox Running...."
vagrant up vagrant up
fi fi
} }
@ -30,16 +30,16 @@ function vagrant-up() {
function vagrant-plugin-vm() { function vagrant-plugin-vm() {
case "$1" in case "$1" in
"virtualbox") "virtualbox")
echo "Vagrant plugin install for provider : $1 Running...." _omb_util_print "Vagrant plugin install for provider : $1 Running...."
vagrant plugin install vagrant-vbguest vagrant plugin install vagrant-vbguest
;; ;;
"libvirt") "libvirt")
echo "Vagrant plugin install for provider : $1 Running...." _omb_util_print "Vagrant plugin install for provider : $1 Running...."
vagrant plugin install vagrant-libvirt vagrant plugin install vagrant-libvirt
;; ;;
*) *)
echo "Usage : vapvm <provider name>" >&2 _omb_util_print "Usage : vapvm <provider name>" >&2
echo "Example : vapvm virtualbox" >&2 _omb_util_print "Example : vapvm virtualbox" >&2
return 2 return 2
;; ;;
esac esac
@ -61,20 +61,20 @@ function vagrant-ssh() {
if ((VMDEFAULT == 1)); then if ((VMDEFAULT == 1)); then
if [[ $1 ]]; then if [[ $1 ]]; then
echo "SKIP : $1 Server...." _omb_util_print "SKIP : $1 Server...."
fi fi
echo "Login to : default Server...." _omb_util_print "Login to : default Server...."
vagrant ssh vagrant ssh
elif [[ $1 ]] && ((VMCOUNT > 1)); then elif [[ $1 ]] && ((VMCOUNT > 1)); then
echo "Login to : $1 Server...." _omb_util_print "Login to : $1 Server...."
vagrant ssh "$1" vagrant ssh "$1"
elif ((VMCOUNT == 0)); then elif ((VMCOUNT == 0)); then
echo "Seems like that not there running servers" >&2 _omb_util_print "Seems like that not there running servers" >&2
return 1 return 1
else else
echo -e "Please choose a server from this list:\\n" _omb_util_put $'Please choose a server from this list:\n\n'
vagrant status | awk '/running/{print $1}' vagrant status | awk '/running/{print $1}'
echo -e "\\nThen fill: vagrant ssh [ option ]" _omb_util_put $'\nThen fill: vagrant ssh [ option ]\n'
fi fi
} }

View File

@ -15,7 +15,7 @@ function _omb_plugin_xterm_short_dirname {
if [[ ${OMB_PLUGIN_XTERM_SHORT_TERM_LINE-} == true ]] && ((${#dir_name} > 8)); then if [[ ${OMB_PLUGIN_XTERM_SHORT_TERM_LINE-} == true ]] && ((${#dir_name} > 8)); then
dir_name=${dir_name##*/} dir_name=${dir_name##*/}
fi fi
echo "$dir_name" _omb_util_print "$dir_name"
} }
function _omb_plugin_xterm_short_command { function _omb_plugin_xterm_short_command {
@ -23,7 +23,7 @@ function _omb_plugin_xterm_short_command {
if [[ ${OMB_PLUGIN_XTERM_SHORT_TERM_LINE-} == true ]] && ((${#input_command} > 8)); then if [[ ${OMB_PLUGIN_XTERM_SHORT_TERM_LINE-} == true ]] && ((${#input_command} > 8)); then
input_command=${input_command%% *} input_command=${input_command%% *}
fi fi
echo "$input_command" _omb_util_print "$input_command"
} }
function _omb_plugin_xterm_set_title { function _omb_plugin_xterm_set_title {

View File

@ -11,7 +11,7 @@ fi
function show_reboot_required() { function show_reboot_required() {
if [ ! -z "$_bf_prompt_reboot_info" ]; then if [ ! -z "$_bf_prompt_reboot_info" ]; then
if [ -f /var/run/reboot-required ]; then if [ -f /var/run/reboot-required ]; then
printf "Reboot required!" _omb_util_put "Reboot required!"
fi fi
fi fi
} }
@ -20,9 +20,9 @@ function show_reboot_required() {
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 [[ ! -z $SSH_CLIENT ]]; then
printf "${lime_yellow}" _omb_util_put "${lime_yellow}"
else else
printf "${light_orange}" _omb_util_put "${light_orange}"
fi fi
} }
@ -30,10 +30,10 @@ function set_host_color() {
function set_user_color() { function set_user_color() {
case $(id -u) in case $(id -u) in
0) 0)
printf "${_omb_prompt_brown}" _omb_util_put "${_omb_prompt_brown}"
;; ;;
*) *)
printf "${_omb_prompt_teal}" _omb_util_put "${_omb_prompt_teal}"
;; ;;
esac esac
} }
@ -44,7 +44,7 @@ function scm_prompt {
then then
return return
else else
echo "[$(scm_char)$(scm_prompt_info)]" _omb_util_print "[$(scm_char)$(scm_prompt_info)]"
fi fi
} }
@ -63,7 +63,7 @@ function set_custom_colors() {
} }
function __ps_time { function __ps_time {
echo "$(clock_prompt)${_omb_prompt_normal}\n" _omb_util_print "$(clock_prompt)${_omb_prompt_normal}\n"
} }
function _omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND() {

View File

@ -14,10 +14,10 @@ RVM_THEME_PROMPT_PREFIX="|"
RVM_THEME_PROMPT_SUFFIX="|" RVM_THEME_PROMPT_SUFFIX="|"
function __bobby_clock { function __bobby_clock {
printf "$(clock_prompt) " _omb_util_put "$(clock_prompt) "
if [ "${THEME_SHOW_CLOCK_CHAR}" == "true" ]; then if [ "${THEME_SHOW_CLOCK_CHAR}" == "true" ]; then
printf "$(clock_char) " _omb_util_put "$(clock_char) "
fi fi
} }

View File

@ -12,7 +12,7 @@ SCM_HG_CHAR="${_omb_prompt_bold_brown}☿${_omb_prompt_normal}"
function is_vim_shell { function is_vim_shell {
if [ ! -z "$VIMRUNTIME" ] if [ ! -z "$VIMRUNTIME" ]
then then
echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]" _omb_util_print "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]"
fi fi
} }
@ -22,7 +22,7 @@ function scm_prompt {
then then
return return
else else
echo " $(scm_char) (${_omb_prompt_white}$(scm_prompt_info)${_omb_prompt_normal})" _omb_util_print " $(scm_char) (${_omb_prompt_white}$(scm_prompt_info)${_omb_prompt_normal})"
fi fi
} }

View File

@ -14,7 +14,7 @@ GIT_SHA_PREFIX="${_omb_prompt_navy}"
GIT_SHA_SUFFIX="${_omb_prompt_reset_color}" GIT_SHA_SUFFIX="${_omb_prompt_reset_color}"
function git_short_sha() { function git_short_sha() {
SHA=$(_omb_prompt_git rev-parse --short HEAD 2> /dev/null) && echo "$GIT_SHA_PREFIX$SHA$GIT_SHA_SUFFIX" SHA=$(_omb_prompt_git rev-parse --short HEAD 2> /dev/null) && _omb_util_print "$GIT_SHA_PREFIX$SHA$GIT_SHA_SUFFIX"
} }
function _omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND() {

View File

@ -63,8 +63,13 @@ function winname {
# Displays the current prompt # Displays the current prompt
function _omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND() {
PS1="\n${icon_start}$(_omb_prompt_print_python_venv)${icon_user}${_omb_prompt_bold_brown}\u${_omb_prompt_normal}${icon_host}${_omb_prompt_bold_teal}\h${_omb_prompt_normal}${icon_directory}${_omb_prompt_bold_purple}\W${_omb_prompt_normal}\$([[ -n \$(_omb_prompt_git branch 2> /dev/null) ]] && echo \" on ${icon_branch} \")${_omb_prompt_white}$(scm_prompt_info)${_omb_prompt_normal}\n${icon_end}" PS1='\n'$icon_start$(_omb_prompt_print_python_venv)
PS2="${icon_end}" PS1+=$icon_user$_omb_prompt_bold_brown'\u'
PS1+=$_omb_prompt_normal$icon_host$_omb_prompt_bold_teal'\h'
PS1+=$_omb_prompt_normal$icon_directory$_omb_prompt_bold_purple'\W'
PS1+=$_omb_prompt_normal$([[ -n $(_omb_prompt_git branch 2> /dev/null) ]] && _omb_util_print " on $icon_branch ")
PS1+=$_omb_prompt_white$(scm_prompt_info)$_omb_prompt_normal'\n'$icon_end
PS2=$icon_end
} }
# Runs prompt (this bypasses oh-my-bash $PROMPT setting) # Runs prompt (this bypasses oh-my-bash $PROMPT setting)

View File

@ -58,7 +58,7 @@ esac
function is_vim_shell { function is_vim_shell {
if [ ! -z "$VIMRUNTIME" ]; if [ ! -z "$VIMRUNTIME" ];
then then
echo "${D_INTERMEDIATE_COLOR}on ${D_VIMSHELL_COLOR}\ _omb_util_print "${D_INTERMEDIATE_COLOR}on ${D_VIMSHELL_COLOR}\
vim shell${D_DEFAULT_COLOR} " vim shell${D_DEFAULT_COLOR} "
fi fi
} }
@ -67,7 +67,7 @@ function mitsuhikos_lastcommandfailed {
code=$? code=$?
if [ $code != 0 ]; if [ $code != 0 ];
then then
echo "${D_INTERMEDIATE_COLOR}exited ${D_CMDFAIL_COLOR}\ _omb_util_print "${D_INTERMEDIATE_COLOR}exited ${D_CMDFAIL_COLOR}\
$code ${D_DEFAULT_COLOR}" $code ${D_DEFAULT_COLOR}"
fi fi
} }

View File

@ -33,9 +33,9 @@ function doubletime_scm_prompt {
if [ $CHAR = $SCM_NONE_CHAR ]; then if [ $CHAR = $SCM_NONE_CHAR ]; then
return return
elif [ $CHAR = $SCM_GIT_CHAR ]; then elif [ $CHAR = $SCM_GIT_CHAR ]; then
echo "$(git_prompt_status)" _omb_util_print "$(git_prompt_status)"
else else
echo "[$(scm_prompt_info)]" _omb_util_print "[$(scm_prompt_info)]"
fi fi
} }
@ -56,17 +56,17 @@ _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND
function git_prompt_status { function git_prompt_status {
local git_status_output local git_status_output
git_status_output=$(_omb_prompt_git status 2> /dev/null ) git_status_output=$(_omb_prompt_git status 2> /dev/null )
if [ -n "$(echo $git_status_output | grep 'Changes not staged')" ]; then if [ -n "$(grep 'Changes not staged' <<< "$git_status_output")" ]; then
git_status="${_omb_prompt_bold_brown}$(scm_prompt_info)" git_status="${_omb_prompt_bold_brown}$(scm_prompt_info)"
elif [ -n "$(echo $git_status_output | grep 'Changes to be committed')" ]; then elif [ -n "$(grep 'Changes to be committed' <<< "$git_status_output")" ]; then
git_status="${_omb_prompt_bold_olive}$(scm_prompt_info) ^" git_status="${_omb_prompt_bold_olive}$(scm_prompt_info) ^"
elif [ -n "$(echo $git_status_output | grep 'Untracked files')" ]; then elif [ -n "$(grep 'Untracked files' <<< "$git_status_output")" ]; then
git_status="${_omb_prompt_bold_teal}$(scm_prompt_info) +" git_status="${_omb_prompt_bold_teal}$(scm_prompt_info) +"
elif [ -n "$(echo $git_status_output | grep 'nothing to commit')" ]; then elif [ -n "$(grep 'nothing to commit' <<< "$git_status_output")" ]; then
git_status="${_omb_prompt_bold_green}$(scm_prompt_info) ${_omb_prompt_green}" git_status="${_omb_prompt_bold_green}$(scm_prompt_info) ${_omb_prompt_green}"
else else
git_status="$(scm_prompt_info)" git_status="$(scm_prompt_info)"
fi fi
echo "[$git_status${_omb_prompt_normal}]" _omb_util_print "[$git_status${_omb_prompt_normal}]"
} }

View File

@ -9,7 +9,7 @@ function venv {
if [ -n "$VIRTUAL_ENV" ] if [ -n "$VIRTUAL_ENV" ]
then then
local env=$VIRTUAL_ENV local env=$VIRTUAL_ENV
echo "${gray} in ${_omb_prompt_red}${env##*/} " _omb_util_print "${gray} in ${_omb_prompt_red}${env##*/} "
fi fi
} }

View File

@ -25,7 +25,7 @@ function get_hour_color {
else else
hour_color=$_omb_prompt_brown hour_color=$_omb_prompt_brown
fi fi
echo "$hour_color" _omb_util_print "$hour_color"
} }
function __emperor_clock { function __emperor_clock {

View File

@ -20,7 +20,7 @@ function scm_prompt {
then then
return return
else else
echo "$(scm_prompt_info) " _omb_util_print "$(scm_prompt_info) "
fi fi
} }

View File

@ -18,28 +18,28 @@ SCM_NONE_CHAR=""
function _omb_theme_ht_exit_color { function _omb_theme_ht_exit_color {
case $1 in case $1 in
0) 0)
echo "$_omb_prompt_green" _omb_util_print "$_omb_prompt_green"
;; ;;
1) 1)
echo "$_omb_prompt_red" _omb_util_print "$_omb_prompt_red"
;; ;;
2) 2)
echo "$_omb_prompt_gray" _omb_util_print "$_omb_prompt_gray"
;; ;;
126) 126)
echo "$_omb_prompt_cyan" _omb_util_print "$_omb_prompt_cyan"
;; ;;
127) 127)
echo "$_omb_prompt_magenta" _omb_util_print "$_omb_prompt_magenta"
;; ;;
130) 130)
echo "$_omb_prompt_black" _omb_util_print "$_omb_prompt_black"
;; ;;
148) 148)
echo "$_omb_prompt_yellow" _omb_util_print "$_omb_prompt_yellow"
;; ;;
*) *)
echo "$_omb_prompt_blue" _omb_util_print "$_omb_prompt_blue"
;; ;;
esac esac
} }

View File

@ -62,8 +62,13 @@ function winname {
# Displays the current prompt # Displays the current prompt
function _omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND() {
PS1="${icon_start}$(_omb_prompt_print_python_venv)${icon_user}${_omb_prompt_bold_brown}\u${_omb_prompt_normal}${icon_host}${_omb_prompt_bold_teal}\h${_omb_prompt_normal}${icon_directory}${_omb_prompt_bold_purple}\w${_omb_prompt_normal}\$([[ -n \$(_omb_prompt_git branch 2> /dev/null) ]] && echo \" on (${icon_branch} \")${_omb_prompt_white}$(scm_prompt_info)${_omb_prompt_normal}\n${icon_end}" PS1=$icon_start$(_omb_prompt_print_python_venv)
PS2="${icon_end}" PS1+=$icon_user$_omb_prompt_bold_brown'\u'
PS1+=$_omb_prompt_normal$icon_host$_omb_prompt_bold_teal'\h'
PS1+=$_omb_prompt_normal$icon_directory$_omb_prompt_bold_purple'\w'
PS1+=$_omb_prompt_normal$([[ -n $(_omb_prompt_git branch 2> /dev/null) ]] && _omb_util_print " on (${icon_branch} ")
PS1+=$_omb_prompt_white$(scm_prompt_info)$_omb_prompt_normal'\n'$icon_end
PS2=$icon_end
} }
# Runs prompt (this bypasses oh-my-bash $PROMPT setting) # Runs prompt (this bypasses oh-my-bash $PROMPT setting)

View File

@ -60,12 +60,12 @@ function __my_rvm_ruby_version {
[[ $gemset ]] && gemset=@$gemset [[ $gemset ]] && gemset=@$gemset
local version=$(awk -F'-' '{print $2}' <<< "$MY_RUBY_HOME") local version=$(awk -F'-' '{print $2}' <<< "$MY_RUBY_HOME")
local full=$version$gemset local full=$version$gemset
[[ $full ]] && echo "[$full]" [[ $full ]] && _omb_util_print "[$full]"
} }
function is_vim_shell { function is_vim_shell {
if [[ $VIMRUNTIME ]]; then if [[ $VIMRUNTIME ]]; then
echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]" _omb_util_print "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]"
fi fi
} }
@ -74,7 +74,7 @@ function modern_scm_prompt {
if [[ $CHAR == "$SCM_NONE_CHAR" ]]; then if [[ $CHAR == "$SCM_NONE_CHAR" ]]; then
return return
else else
echo "[$(scm_char)][$GREEN$(scm_prompt_info)]" _omb_util_print "[$(scm_char)][$GREEN$(scm_prompt_info)]"
fi fi
} }
@ -82,7 +82,7 @@ function modern_scm_prompt {
function chroot { function chroot {
if [[ $debian_chroot ]]; then if [[ $debian_chroot ]]; then
local my_ps_chroot=$_omb_prompt_bold_teal$debian_chroot$_omb_prompt_normal local my_ps_chroot=$_omb_prompt_bold_teal$debian_chroot$_omb_prompt_normal
echo "($my_ps_chroot)" _omb_util_print "($my_ps_chroot)"
fi fi
} }
@ -91,9 +91,9 @@ function my_ve {
if [[ $VIRTUAL_ENV ]]; then if [[ $VIRTUAL_ENV ]]; then
local ve=$(basename "$VIRTUAL_ENV") local ve=$(basename "$VIRTUAL_ENV")
local my_ps_ve=$_omb_prompt_bold_purple$ve$_omb_prompt_normal local my_ps_ve=$_omb_prompt_bold_purple$ve$_omb_prompt_normal
echo "($my_ps_ve)" _omb_util_print "($my_ps_ve)"
fi fi
echo "" _omb_util_print ""
} }
function _omb_theme_PROMPT_COMMAND { function _omb_theme_PROMPT_COMMAND {

View File

@ -14,7 +14,8 @@ GIT_SHA_PREFIX=" ${_omb_prompt_olive}"
GIT_SHA_SUFFIX="${_omb_prompt_reset_color}" GIT_SHA_SUFFIX="${_omb_prompt_reset_color}"
function git_short_sha() { function git_short_sha() {
SHA=$(_omb_prompt_git rev-parse --short HEAD 2> /dev/null) && echo "$GIT_SHA_PREFIX$SHA$GIT_SHA_SUFFIX" SHA=$(_omb_prompt_git rev-parse --short HEAD 2> /dev/null) &&
_omb_util_print "$GIT_SHA_PREFIX$SHA$GIT_SHA_SUFFIX"
} }
function _omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND() {

View File

@ -21,7 +21,7 @@ PS3=">> "
function is_vim_shell { function is_vim_shell {
if [[ $VIMRUNTIME ]]; then if [[ $VIMRUNTIME ]]; then
echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]" _omb_util_print "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]"
fi fi
} }
@ -30,7 +30,7 @@ function modern_scm_prompt {
if [[ $CHAR == "$SCM_NONE_CHAR" ]]; then if [[ $CHAR == "$SCM_NONE_CHAR" ]]; then
return return
else else
echo "[$(scm_char)][$(scm_prompt_info)]" _omb_util_print "[$(scm_char)][$(scm_prompt_info)]"
fi fi
} }
@ -54,5 +54,5 @@ PS2="└─▪ "
_omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND
if [[ -t 2 ]] && ! _omb_util_binary_exists t; then if [[ -t 2 ]] && ! _omb_util_binary_exists t; then
printf '%s\n' "${_omb_term_bold_navy}oh-my-bash (theme:modern-t)${_omb_term_normal}: command \"t\" not found. The theme \"Modern T\" depends on a todo-list manager \"t\" (${_omb_term_underline}https://github.com/sjl/t${_omb_term_normal})." >&2 _omb_util_print "${_omb_term_bold_navy}oh-my-bash (theme:modern-t)${_omb_term_normal}: command \"t\" not found. The theme \"Modern T\" depends on a todo-list manager \"t\" (${_omb_term_underline}https://github.com/sjl/t${_omb_term_normal})." >&2
fi fi

View File

@ -21,7 +21,7 @@ PS3=">> "
function is_vim_shell { function is_vim_shell {
if [[ $VIMRUNTIME ]]; then if [[ $VIMRUNTIME ]]; then
echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]" _omb_util_print "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]"
fi fi
} }
@ -30,7 +30,7 @@ function modern_scm_prompt {
if [[ $CHAR == "$SCM_NONE_CHAR" ]]; then if [[ $CHAR == "$SCM_NONE_CHAR" ]]; then
return return
else else
echo "[$(scm_char)][$(scm_prompt_info)]" _omb_util_print "[$(scm_char)][$(scm_prompt_info)]"
fi fi
} }

View File

@ -58,7 +58,7 @@ function randomize_nwinkler {
THEME_CLOCK_COLOR=$TIME_COLOR THEME_CLOCK_COLOR=$TIME_COLOR
PATH_COLOR=${AVAILABLE_COLORS[$RANDOM % ${#AVAILABLE_COLORS[@]} ]} PATH_COLOR=${AVAILABLE_COLORS[$RANDOM % ${#AVAILABLE_COLORS[@]} ]}
echo "$USERNAME_COLOR,$HOSTNAME_COLOR,$TIME_COLOR,$PATH_COLOR," > $RANDOM_COLOR_FILE _omb_util_print "$USERNAME_COLOR,$HOSTNAME_COLOR,$TIME_COLOR,$PATH_COLOR," > $RANDOM_COLOR_FILE
} }
if [ -f $RANDOM_COLOR_FILE ]; if [ -f $RANDOM_COLOR_FILE ];
@ -74,13 +74,13 @@ else
# No colors stored yet. Generate them! # No colors stored yet. Generate them!
randomize_nwinkler randomize_nwinkler
echo _omb_util_print
echo "Looks like you are using the nwinkler_random_color bashit theme for the first time." _omb_util_print "Looks like you are using the nwinkler_random_color bashit theme for the first time."
echo "Random colors have been generated to be used in your prompt." _omb_util_print "Random colors have been generated to be used in your prompt."
echo "If you don't like them, run the command:" _omb_util_print "If you don't like them, run the command:"
echo " randomize_nwinkler" _omb_util_print " randomize_nwinkler"
echo "until you get a combination that you like." _omb_util_print "until you get a combination that you like."
echo _omb_util_print
fi fi
PROMPT_END_CLEAN="${_omb_prompt_green}${_omb_prompt_reset_color}" PROMPT_END_CLEAN="${_omb_prompt_green}${_omb_prompt_reset_color}"

View File

@ -13,7 +13,7 @@ function __pb10k_remove_empty_elements {
trimmed=${trimmed%"${trimmed##*[![:space:]]}"} trimmed=${trimmed%"${trimmed##*[![:space:]]}"}
[[ $trimmed ]] && new_array+=("$element") [[ $trimmed ]] && new_array+=("$element")
done done
echo "${new_array[@]}" _omb_util_print "${new_array[*]}"
} }
function __pb10k_format_duration { function __pb10k_format_duration {
@ -23,11 +23,11 @@ function __pb10k_format_duration {
local hours=$((duration / 3600)) local hours=$((duration / 3600))
if ((hours > 0)); then if ((hours > 0)); then
echo "${hours}h ${minutes}m ${seconds}s" _omb_util_print "${hours}h ${minutes}m ${seconds}s"
elif ((minutes > 0)); then elif ((minutes > 0)); then
echo "${minutes}m ${seconds}s" _omb_util_print "${minutes}m ${seconds}s"
else else
echo "${seconds}s" _omb_util_print "${seconds}s"
fi fi
} }
@ -152,8 +152,8 @@ function __pb10k_prompt_scm {
local color=$_omb_prompt_bold_green local color=$_omb_prompt_bold_green
scm scm
local box="" local box=""
local info="$(if [ "$SCM" == "git" ]; then echo " "; fi)" local info="$(if [ "$SCM" == "git" ]; then _omb_util_print " "; fi)"
info+="$(if [ "$SCM" != "NONE" ]; then echo "$(scm_prompt_info)"; fi)" info+="$(if [ "$SCM" != "NONE" ]; then _omb_util_print "$(scm_prompt_info)"; fi)"
[[ $info ]] || return 0 [[ $info ]] || return 0
printf "%s|%s|%s|%s" "$color" "$info" "$_omb_prompt_bold_green" "$box" printf "%s|%s|%s|%s" "$color" "$info" "$_omb_prompt_bold_green" "$box"
} }
@ -227,9 +227,9 @@ function __pb10k_prompt_exitcode {
function __pb10k_prompt_char { function __pb10k_prompt_char {
local color=$( local color=$(
if ((exitcode != 0)); then if ((exitcode != 0)); then
echo "$_omb_prompt_bold_red" _omb_util_print "$_omb_prompt_bold_red"
else else
echo "$_omb_prompt_bold_green" _omb_util_print "$_omb_prompt_bold_green"
fi fi
) )
printf "%s|%s" "$color" "$__PB10K_PROMPT_CHAR_PS1" printf "%s|%s" "$color" "$__PB10K_PROMPT_CHAR_PS1"

View File

@ -32,17 +32,17 @@ function __powerline_user_info_prompt {
fi fi
;; ;;
esac esac
[[ -n "${user_info}" ]] && echo "$OMB_THEME_POWERLINE_ICON_USER ${user_info} `date +%X\ %D`|${color}|${secondary_color}" [[ -n "${user_info}" ]] && _omb_util_print "$OMB_THEME_POWERLINE_ICON_USER ${user_info} `date +%X\ %D`|${color}|${secondary_color}"
} }
function __powerline_cwd_prompt { function __powerline_cwd_prompt {
echo "$(pwd | sed "s|^${HOME}|$OMB_THEME_POWERLINE_ICON_HOME|")|${CWD_THEME_PROMPT_COLOR}" _omb_util_print "$(pwd | sed "s|^${HOME}|$OMB_THEME_POWERLINE_ICON_HOME|")|${CWD_THEME_PROMPT_COLOR}"
} }
function __powerline_last_status_prompt { function __powerline_last_status_prompt {
if [[ "$1" -ne 0 ]]; then if [[ "$1" -ne 0 ]]; then
echo "$OMB_THEME_POWERLINE_ICON_EXIT_FAILURE${1}|${LAST_STATUS_THEME_PROMPT_COLOR}" _omb_util_print "$OMB_THEME_POWERLINE_ICON_EXIT_FAILURE${1}|${LAST_STATUS_THEME_PROMPT_COLOR}"
else else
echo "$OMB_THEME_POWERLINE_ICON_EXIT_SUCCESS|${LAST_STATUS_THEME_PROMPT_COLOR_SUCCESS}" _omb_util_print "$OMB_THEME_POWERLINE_ICON_EXIT_SUCCESS|${LAST_STATUS_THEME_PROMPT_COLOR_SUCCESS}"
fi fi
} }

View File

@ -3,7 +3,7 @@
source "$OSH/themes/powerline/powerline.base.sh" source "$OSH/themes/powerline/powerline.base.sh"
function __powerline_last_status_prompt { function __powerline_last_status_prompt {
[[ "$1" -ne 0 ]] && echo "$(set_color ${LAST_STATUS_THEME_PROMPT_COLOR} -) ${1} ${_omb_prompt_normal}" [[ "$1" -ne 0 ]] && _omb_util_print "$(set_color ${LAST_STATUS_THEME_PROMPT_COLOR} -) ${1} ${_omb_prompt_normal}"
} }
function __powerline_right_segment { function __powerline_right_segment {

View File

@ -69,7 +69,7 @@ function __powerline_user_info_prompt {
fi fi
;; ;;
esac esac
[[ -n "${user_info}" ]] && echo "${user_info}|${color}|${secondary_color}" [[ -n "${user_info}" ]] && _omb_util_print "${user_info}|${color}|${secondary_color}"
} }
function __powerline_ruby_prompt { function __powerline_ruby_prompt {
@ -81,7 +81,7 @@ function __powerline_ruby_prompt {
ruby_version=$(rbenv_version_prompt) ruby_version=$(rbenv_version_prompt)
fi fi
[[ -n "${ruby_version}" ]] && echo "${RUBY_CHAR}${ruby_version}|${RUBY_THEME_PROMPT_COLOR}" [[ -n "${ruby_version}" ]] && _omb_util_print "${RUBY_CHAR}${ruby_version}|${RUBY_THEME_PROMPT_COLOR}"
} }
function __powerline_python_venv_prompt { function __powerline_python_venv_prompt {
@ -94,7 +94,7 @@ function __powerline_python_venv_prompt {
python_venv=$(basename "${VIRTUAL_ENV}") python_venv=$(basename "${VIRTUAL_ENV}")
fi fi
[[ -n "${python_venv}" ]] && echo "${PYTHON_VENV_CHAR}${python_venv}|${PYTHON_VENV_THEME_PROMPT_COLOR}" [[ -n "${python_venv}" ]] && _omb_util_print "${PYTHON_VENV_CHAR}${python_venv}|${PYTHON_VENV_THEME_PROMPT_COLOR}"
} }
function __powerline_scm_prompt { function __powerline_scm_prompt {
@ -116,16 +116,16 @@ function __powerline_scm_prompt {
if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then
scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}"
fi fi
echo "${scm_prompt}${scm}|${color}" _omb_util_print "${scm_prompt}${scm}|${color}"
fi fi
} }
function __powerline_cwd_prompt { function __powerline_cwd_prompt {
echo "$(pwd | sed "s|^${HOME}|~|")|${CWD_THEME_PROMPT_COLOR}" _omb_util_print "$(pwd | sed "s|^${HOME}|~|")|${CWD_THEME_PROMPT_COLOR}"
} }
function __powerline_clock_prompt { function __powerline_clock_prompt {
echo "$(date +"${THEME_CLOCK_FORMAT}")|${CLOCK_THEME_PROMPT_COLOR}" _omb_util_print "$(date +"${THEME_CLOCK_FORMAT}")|${CLOCK_THEME_PROMPT_COLOR}"
} }
function __powerline_battery_prompt { function __powerline_battery_prompt {
@ -143,13 +143,13 @@ function __powerline_battery_prompt {
color="${BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR}" color="${BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR}"
fi fi
ac_adapter_connected && battery_status="${BATTERY_AC_CHAR}${battery_status}" ac_adapter_connected && battery_status="${BATTERY_AC_CHAR}${battery_status}"
echo "${battery_status}%|${color}" _omb_util_print "${battery_status}%|${color}"
fi fi
} }
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}" _omb_util_print "${IN_VIM_THEME_PROMPT_TEXT}|${IN_VIM_THEME_PROMPT_COLOR}"
fi fi
} }
@ -171,7 +171,7 @@ function __powerline_left_segment {
} }
function __powerline_last_status_prompt { function __powerline_last_status_prompt {
[[ "$1" -ne 0 ]] && echo "${1}|${LAST_STATUS_THEME_PROMPT_COLOR}" [[ "$1" -ne 0 ]] && _omb_util_print "${1}|${LAST_STATUS_THEME_PROMPT_COLOR}"
} }
function __powerline_prompt_command { function __powerline_prompt_command {

View File

@ -20,7 +20,7 @@ function scm_prompt {
then then
return return
else else
echo "[$(scm_char)$(scm_prompt_info)]" _omb_util_print "[$(scm_char)$(scm_prompt_info)]"
fi fi
} }

View File

@ -41,14 +41,14 @@ esac
function is_vim_shell { function is_vim_shell {
if [[ ${VIMRUNTIME-} ]]; then if [[ ${VIMRUNTIME-} ]]; then
echo "${D_INTERMEDIATE_COLOR}on ${D_VIMSHELL_COLOR}vim shell${D_DEFAULT_COLOR} " _omb_util_print "${D_INTERMEDIATE_COLOR}on ${D_VIMSHELL_COLOR}vim shell${D_DEFAULT_COLOR} "
fi fi
} }
function mitsuhikos_lastcommandfailed { function mitsuhikos_lastcommandfailed {
local status=$? local status=$?
if ((status != 0)); then if ((status != 0)); then
echo " ${D_DEFAULT_COLOR}C:${D_CMDFAIL_COLOR}$code ${D_DEFAULT_COLOR}" _omb_util_print " ${D_DEFAULT_COLOR}C:${D_CMDFAIL_COLOR}$code ${D_DEFAULT_COLOR}"
fi fi
} }
@ -78,9 +78,9 @@ function prompt_git {
branchName=$( branchName=$(
_omb_prompt_git symbolic-ref --quiet --short HEAD 2> /dev/null || _omb_prompt_git symbolic-ref --quiet --short HEAD 2> /dev/null ||
_omb_prompt_git rev-parse --short HEAD 2> /dev/null || _omb_prompt_git rev-parse --short HEAD 2> /dev/null ||
echo '(unknown)'); _omb_util_print '(unknown)');
echo "${D_GIT_DEFAULT_COLOR}on ${D_GIT_BRANCH_COLOR}${branchName} " _omb_util_print "${D_GIT_DEFAULT_COLOR}on ${D_GIT_BRANCH_COLOR}${branchName} "
else else
return return
fi fi
@ -98,9 +98,9 @@ function limited_pwd {
if ((offset > 0)); then if ((offset > 0)); then
local truncated_symbol='...' local truncated_symbol='...'
local TRUNCATED_PWD=${RELATIVE_PWD:offset:MAX_PWD_LENGTH} local TRUNCATED_PWD=${RELATIVE_PWD:offset:MAX_PWD_LENGTH}
echo -n "${truncated_symbol}/${TRUNCATED_PWD#*/}" _omb_util_put "${truncated_symbol}/${TRUNCATED_PWD#*/}"
else else
echo -n "${RELATIVE_PWD}" _omb_util_put "${RELATIVE_PWD}"
fi fi
} }

View File

@ -85,14 +85,14 @@ esac
function is_vim_shell { function is_vim_shell {
if [[ ${VIMRUNTIME-} ]]; then if [[ ${VIMRUNTIME-} ]]; then
echo "${D_INTERMEDIATE_COLOR}on ${D_VIMSHELL_COLOR}vim shell${D_DEFAULT_COLOR} " _omb_util_print "${D_INTERMEDIATE_COLOR}on ${D_VIMSHELL_COLOR}vim shell${D_DEFAULT_COLOR} "
fi fi
} }
function mitsuhikos_lastcommandfailed { function mitsuhikos_lastcommandfailed {
local status=$? local status=$?
if ((status != 0)); then if ((status != 0)); then
echo "${D_INTERMEDIATE_COLOR}exited ${D_CMDFAIL_COLOR}$status ${D_DEFAULT_COLOR}" _omb_util_print "${D_INTERMEDIATE_COLOR}exited ${D_CMDFAIL_COLOR}$status ${D_DEFAULT_COLOR}"
fi fi
} }
@ -152,7 +152,7 @@ function prompt_git {
branchName=$( branchName=$(
_omb_prompt_git symbolic-ref --quiet --short HEAD 2> /dev/null || _omb_prompt_git symbolic-ref --quiet --short HEAD 2> /dev/null ||
_omb_prompt_git rev-parse --short HEAD 2> /dev/null || _omb_prompt_git rev-parse --short HEAD 2> /dev/null ||
echo '(unknown)') _omb_util_print '(unknown)')
[[ $s ]] && s=" [$s]" [[ $s ]] && s=" [$s]"

View File

@ -34,12 +34,12 @@ function __my_rvm_ruby_version {
local version=$(awk -F'-' '{print $2}' <<< "${MY_RUBY_HOME}") local version=$(awk -F'-' '{print $2}' <<< "${MY_RUBY_HOME}")
[[ $gemset ]] && gemset=@$gemset [[ $gemset ]] && gemset=@$gemset
local full=$version$gemset local full=$version$gemset
[[ $full ]] && echo "${OMB_THEME_BRACKET_COLOR}[${OMB_THEME_STRING_COLOR}${full}${OMB_THEME_BRACKET_COLOR}]${_omb_prompt_normal}" [[ $full ]] && _omb_util_print "${OMB_THEME_BRACKET_COLOR}[${OMB_THEME_STRING_COLOR}${full}${OMB_THEME_BRACKET_COLOR}]${_omb_prompt_normal}"
} }
function is_vim_shell { function is_vim_shell {
if [[ $VIMRUNTIME ]]; then if [[ $VIMRUNTIME ]]; then
echo "${OMB_THEME_BRACKET_COLOR}[${OMB_THEME_STRING_COLOR}vim shell${OMB_THEME_BRACKET_COLOR}]${_omb_prompt_normal}" _omb_util_print "${OMB_THEME_BRACKET_COLOR}[${OMB_THEME_STRING_COLOR}vim shell${OMB_THEME_BRACKET_COLOR}]${_omb_prompt_normal}"
fi fi
} }
@ -55,7 +55,7 @@ function todo_txt_count {
local count=$(todo.sh ls \ local count=$(todo.sh ls \
| awk '/TODO: [0-9]+ of ([0-9]+) tasks shown/ { print $4 }') | awk '/TODO: [0-9]+ of ([0-9]+) tasks shown/ { print $4 }')
if is_integer "${count}"; then # did we get a sane answer back if is_integer "${count}"; then # did we get a sane answer back
echo "${OMB_THEME_BRACKET_COLOR}[${OMB_THEME_STRING_COLOR}T:$count${OMB_THEME_BRACKET_COLOR}]$_omb_prompt_normal" _omb_util_print "${OMB_THEME_BRACKET_COLOR}[${OMB_THEME_STRING_COLOR}T:$count${OMB_THEME_BRACKET_COLOR}]$_omb_prompt_normal"
fi fi
fi fi
} }
@ -65,7 +65,7 @@ function modern_scm_prompt {
if [[ $CHAR != "$SCM_NONE_CHAR" ]]; then if [[ $CHAR != "$SCM_NONE_CHAR" ]]; then
local char=$OMB_THEME_BRACKET_COLOR[$CHAR$OMB_THEME_BRACKET_COLOR] local char=$OMB_THEME_BRACKET_COLOR[$CHAR$OMB_THEME_BRACKET_COLOR]
local info=[$OMB_THEME_STRING_COLOR$(scm_prompt_info)$OMB_THEME_BRACKET_COLOR] local info=[$OMB_THEME_STRING_COLOR$(scm_prompt_info)$OMB_THEME_BRACKET_COLOR]
printf '%s\n' "$char$info$_omb_prompt_normal" _omb_util_print "$char$info$_omb_prompt_normal"
fi fi
} }

View File

@ -27,7 +27,7 @@ OMB_PROMPT_CONDAENV_USE_BASENAME=true
OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=false} OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=false}
function parse_git_dirty { function parse_git_dirty {
[[ $(_omb_prompt_git status 2> /dev/null | tail -n1 | cut -c 1-17) != "nothing to commit" ]] && echo "*" [[ $(_omb_prompt_git status 2> /dev/null | tail -n1 | cut -c 1-17) != "nothing to commit" ]] && _omb_util_print "*"
} }
function parse_git_branch { function parse_git_branch {
_omb_prompt_git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" _omb_prompt_git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
@ -36,7 +36,9 @@ function parse_git_branch {
function _omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND() {
local python_venv local python_venv
_omb_prompt_get_python_venv _omb_prompt_get_python_venv
PS1="$python_venv${MAGENTA}\u ${WHITE}at ${ORANGE}\h ${WHITE}in ${GREEN}\w${WHITE}\$([[ -n \$(_omb_prompt_git branch 2> /dev/null) ]] && echo \" on \")${PURPLE}\$(parse_git_branch)${WHITE}\n\$ ${RESET}" local git_prefix
git_prefix=$([[ -n $(_omb_prompt_git branch 2> /dev/null) ]] && _omb_util_print ' on ')
PS1="$python_venv${MAGENTA}\u ${WHITE}at ${ORANGE}\h ${WHITE}in ${GREEN}\w${WHITE}$git_prefix${PURPLE}\$(parse_git_branch)${WHITE}\n\$ ${RESET}"
} }
_omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND

View File

@ -13,7 +13,7 @@ function _omb_theme_sirup_rubygem {
[[ $version == 1.9.2 ]] && version= [[ $version == 1.9.2 ]] && version=
local full=$version$gemset local full=$version$gemset
[[ $full ]] && echo "$full" [[ $full ]] && _omb_util_print "$full"
} }
function _omb_theme_PROMPT_COMMAND { function _omb_theme_PROMPT_COMMAND {

View File

@ -27,18 +27,18 @@ function __my_rvm_ruby_version {
[[ $gemset ]] && gemset=@$gemset [[ $gemset ]] && gemset=@$gemset
local version=$(awk -F'-' '{print $2}' <<< "$MY_RUBY_HOME") local version=$(awk -F'-' '{print $2}' <<< "$MY_RUBY_HOME")
local full=$version$gemset local full=$version$gemset
[[ $full ]] && echo "[$full]" [[ $full ]] && _omb_util_print "[$full]"
} }
function __my_venv_prompt { function __my_venv_prompt {
if [[ $VIRTUAL_ENV ]]; then if [[ $VIRTUAL_ENV ]]; then
echo "[${_omb_prompt_navy}@${_omb_prompt_normal}${VIRTUAL_ENV##*/}]" _omb_util_print "[${_omb_prompt_navy}@${_omb_prompt_normal}${VIRTUAL_ENV##*/}]"
fi fi
} }
function is_vim_shell { function is_vim_shell {
if [[ $VIMRUNTIME ]]; then if [[ $VIMRUNTIME ]]; then
echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]" _omb_util_print "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]"
fi fi
} }
@ -47,7 +47,7 @@ function modern_scm_prompt {
if [[ $CHAR == "$SCM_NONE_CHAR" ]]; then if [[ $CHAR == "$SCM_NONE_CHAR" ]]; then
return return
else else
echo "[$(scm_char)][$(scm_prompt_info)]" _omb_util_print "[$(scm_char)][$(scm_prompt_info)]"
fi fi
} }

View File

@ -13,7 +13,7 @@ function __tonka_date {
function __tonka_clock { function __tonka_clock {
local LIGHT_BLUE="\[\033[1;34m\]" local LIGHT_BLUE="\[\033[1;34m\]"
if [[ "${THEME_SHOW_CLOCK}" = "true" ]]; then if [[ "${THEME_SHOW_CLOCK}" = "true" ]]; then
echo "$(__tonka_time)${LIGHT_BLUE}:$(__tonka_date)${LIGHT_BLUE}:" _omb_util_print "$(__tonka_time)${LIGHT_BLUE}:$(__tonka_date)${LIGHT_BLUE}:"
fi fi
} }

View File

@ -27,12 +27,12 @@ function __my_rvm_ruby_version {
[[ $gemset ]] && gemset=@$gemset [[ $gemset ]] && gemset=@$gemset
local version=$(awk -F'-' '{print $2}' <<< "$MY_RUBY_HOME") local version=$(awk -F'-' '{print $2}' <<< "$MY_RUBY_HOME")
local full=$version$gemset local full=$version$gemset
[[ $full ]] && echo "[$full]" [[ $full ]] && _omb_util_print "[$full]"
} }
function is_vim_shell { function is_vim_shell {
if [[ $VIMRUNTIME ]]; then if [[ $VIMRUNTIME ]]; then
echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]" _omb_util_print "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]"
fi fi
} }
@ -41,7 +41,7 @@ function modern_scm_prompt {
if [[ $CHAR == "$SCM_NONE_CHAR" ]]; then if [[ $CHAR == "$SCM_NONE_CHAR" ]]; then
return return
else else
echo "[$(scm_char)][$(scm_prompt_info)]" _omb_util_print "[$(scm_char)][$(scm_prompt_info)]"
fi fi
} }
@ -49,7 +49,7 @@ function modern_scm_prompt {
function chroot { function chroot {
if [[ $debian_chroot ]]; then if [[ $debian_chroot ]]; then
local my_ps_chroot=$_omb_prompt_bold_teal$debian_chroot$_omb_prompt_normal local my_ps_chroot=$_omb_prompt_bold_teal$debian_chroot$_omb_prompt_normal
echo "($my_ps_chroot)" _omb_util_print "($my_ps_chroot)"
fi fi
} }
@ -58,9 +58,9 @@ function my_ve {
if [[ $VIRTUAL_ENV ]]; then if [[ $VIRTUAL_ENV ]]; then
local ve=$(basename "$VIRTUAL_ENV") local ve=$(basename "$VIRTUAL_ENV")
local my_ps_ve=$_omb_prompt_bold_purple$ve$_omb_prompt_normal local my_ps_ve=$_omb_prompt_bold_purple$ve$_omb_prompt_normal
echo "($my_ps_ve)" _omb_util_print "($my_ps_ve)"
fi fi
echo "" _omb_util_print ""
} }
function _omb_theme_PROMPT_COMMAND { function _omb_theme_PROMPT_COMMAND {