global: Switch the function-declarations to avoid unexpected alias expansions

This commit is contained in:
Koichi Murase 2023-02-10 00:38:56 +09:00
parent 0368b46c61
commit 59f6ef145b
74 changed files with 543 additions and 543 deletions

@ -3,7 +3,7 @@
# apm-bash-completion is written by Ugur Ozyilmazel # apm-bash-completion is written by Ugur Ozyilmazel
# repo: https://github.com/vigo/apm-bash-completion # repo: https://github.com/vigo/apm-bash-completion
__apm(){ function __apm {
local cur prev options apm_command local cur prev options apm_command
COMPREPLY=() COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
@ -30,7 +30,7 @@ __apm(){
fi fi
COMPREPLY=($(compgen -W "$options" -- "$cur")) COMPREPLY=($(compgen -W "$options" -- "$cur"))
} }
__apm_get_command() { function __apm_get_command {
local i local i
for ((i=1; i < $COMP_CWORD; ++i)); do for ((i=1; i < $COMP_CWORD; ++i)); do
local arg=${COMP_WORDS[$i]} local arg=${COMP_WORDS[$i]}

@ -8,7 +8,7 @@
# To use, source this file on bash: # To use, source this file on bash:
# . completion-bundle # . completion-bundle
__bundle() { function __bundle {
local cur=$2 local cur=$2
local prev=$3 local prev=$3
local bundle_command local bundle_command
@ -30,7 +30,7 @@ __bundle() {
COMPREPLY=($(compgen -W "$options" -- "$cur")) COMPREPLY=($(compgen -W "$options" -- "$cur"))
} }
__bundle_get_command() { function __bundle_get_command {
local i local i
for ((i=1; i < $COMP_CWORD; ++i)); do for ((i=1; i < $COMP_CWORD; ++i)); do
local arg=${COMP_WORDS[$i]} local arg=${COMP_WORDS[$i]}

@ -3,7 +3,7 @@
export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/} export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/}
_capcomplete() { function _capcomplete {
if [ -f Capfile ]; then if [ -f Capfile ]; then
recent=`ls -t .cap_tasks~ Capfile **/*.cap 2> /dev/null | head -n 1` recent=`ls -t .cap_tasks~ Capfile **/*.cap 2> /dev/null | head -n 1`
if [[ $recent != '.cap_tasks~' ]]; then if [[ $recent != '.cap_tasks~' ]]; then

@ -1,7 +1,7 @@
#! bash oh-my-bash.module #! bash oh-my-bash.module
# Bash completion support for the 'dirs' plugin (commands G, R). # Bash completion support for the 'dirs' plugin (commands G, R).
_dirs-complete() { function _dirs-complete {
local CURRENT_PROMPT="${COMP_WORDS[COMP_CWORD]}" local CURRENT_PROMPT="${COMP_WORDS[COMP_CWORD]}"
# parse all defined shortcuts from ~/.dirs # parse all defined shortcuts from ~/.dirs

@ -17,13 +17,13 @@
# . ~/.docker-compose-completion.sh # . ~/.docker-compose-completion.sh
__docker_compose_q() { function __docker_compose_q {
docker-compose 2>/dev/null $daemon_options "$@" docker-compose 2>/dev/null $daemon_options "$@"
} }
# Transforms a multiline list of strings into a single line string # Transforms a multiline list of strings into a single line string
# with the words separated by "|". # with the words separated by "|".
__docker_compose_to_alternatives() { function __docker_compose_to_alternatives {
local parts=( $1 ) local parts=( $1 )
local IFS='|' local IFS='|'
echo "${parts[*]}" echo "${parts[*]}"
@ -31,29 +31,29 @@ __docker_compose_to_alternatives() {
# Transforms a multiline list of options into an extglob pattern # Transforms a multiline list of options into an extglob pattern
# suitable for use in case statements. # suitable for use in case statements.
__docker_compose_to_extglob() { function __docker_compose_to_extglob {
local extglob=$( __docker_compose_to_alternatives "$1" ) local extglob=$( __docker_compose_to_alternatives "$1" )
echo "@($extglob)" echo "@($extglob)"
} }
# suppress trailing whitespace # suppress trailing whitespace
__docker_compose_nospace() { function __docker_compose_nospace {
# compopt is not available in ancient bash versions # compopt is not available in ancient bash versions
_omb_util_command_exists compopt && compopt -o nospace _omb_util_command_exists compopt && compopt -o nospace
} }
# Extracts all service names from the compose file. # Extracts all service names from the compose file.
___docker_compose_all_services_in_compose_file() { function ___docker_compose_all_services_in_compose_file {
__docker_compose_q config --services __docker_compose_q config --services
} }
# All services, even those without an existing container # All services, even those without an existing container
__docker_compose_services_all() { function __docker_compose_services_all {
COMPREPLY=( $(compgen -W "$(___docker_compose_all_services_in_compose_file)" -- "$cur") ) COMPREPLY=( $(compgen -W "$(___docker_compose_all_services_in_compose_file)" -- "$cur") )
} }
# All services that have an entry with the given key in their compose_file section # All services that have an entry with the given key in their compose_file section
___docker_compose_services_with_key() { function ___docker_compose_services_with_key {
# flatten sections under "services" to one line, then filter lines containing the key and return section name # flatten sections under "services" to one line, then filter lines containing the key and return section name
__docker_compose_q config \ __docker_compose_q config \
| sed -n -e '/^services:/,/^[^ ]/p' \ | sed -n -e '/^services:/,/^[^ ]/p' \
@ -63,18 +63,18 @@ ___docker_compose_services_with_key() {
} }
# All services that are defined by a Dockerfile reference # All services that are defined by a Dockerfile reference
__docker_compose_services_from_build() { function __docker_compose_services_from_build {
COMPREPLY=( $(compgen -W "$(___docker_compose_services_with_key build)" -- "$cur") ) COMPREPLY=( $(compgen -W "$(___docker_compose_services_with_key build)" -- "$cur") )
} }
# All services that are defined by an image # All services that are defined by an image
__docker_compose_services_from_image() { function __docker_compose_services_from_image {
COMPREPLY=( $(compgen -W "$(___docker_compose_services_with_key image)" -- "$cur") ) COMPREPLY=( $(compgen -W "$(___docker_compose_services_with_key image)" -- "$cur") )
} }
# The services for which containers have been created, optionally filtered # The services for which containers have been created, optionally filtered
# by a boolean expression passed in as argument. # by a boolean expression passed in as argument.
__docker_compose_services_with() { function __docker_compose_services_with {
local containers names local containers names
containers="$(__docker_compose_q ps -q)" containers="$(__docker_compose_q ps -q)"
names=$(docker 2>/dev/null inspect -f "{{if ${1:-true}}}{{range \$k, \$v := .Config.Labels}}{{if eq \$k \"com.docker.compose.service\"}}{{\$v}}{{end}}{{end}}{{end}}" $containers) names=$(docker 2>/dev/null inspect -f "{{if ${1:-true}}}{{range \$k, \$v := .Config.Labels}}{{if eq \$k \"com.docker.compose.service\"}}{{\$v}}{{end}}{{end}}{{end}}" $containers)
@ -82,22 +82,22 @@ __docker_compose_services_with() {
} }
# The services for which at least one paused container exists # The services for which at least one paused container exists
__docker_compose_services_paused() { function __docker_compose_services_paused {
__docker_compose_services_with '.State.Paused' __docker_compose_services_with '.State.Paused'
} }
# The services for which at least one running container exists # The services for which at least one running container exists
__docker_compose_services_running() { function __docker_compose_services_running {
__docker_compose_services_with '.State.Running' __docker_compose_services_with '.State.Running'
} }
# The services for which at least one stopped container exists # The services for which at least one stopped container exists
__docker_compose_services_stopped() { function __docker_compose_services_stopped {
__docker_compose_services_with 'not .State.Running' __docker_compose_services_with 'not .State.Running'
} }
_docker_compose_build() { function _docker_compose_build {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--force-rm --help --no-cache --pull" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--force-rm --help --no-cache --pull" -- "$cur" ) )
@ -109,7 +109,7 @@ _docker_compose_build() {
} }
_docker_compose_bundle() { function _docker_compose_bundle {
case "$prev" in case "$prev" in
--output|-o) --output|-o)
_filedir _filedir
@ -121,12 +121,12 @@ _docker_compose_bundle() {
} }
_docker_compose_config() { function _docker_compose_config {
COMPREPLY=( $( compgen -W "--help --quiet -q --services" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help --quiet -q --services" -- "$cur" ) )
} }
_docker_compose_create() { function _docker_compose_create {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--force-recreate --help --no-build --no-recreate" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--force-recreate --help --no-build --no-recreate" -- "$cur" ) )
@ -138,7 +138,7 @@ _docker_compose_create() {
} }
_docker_compose_docker_compose() { function _docker_compose_docker_compose {
case "$prev" in case "$prev" in
--tlscacert|--tlscert|--tlskey) --tlscacert|--tlscert|--tlskey)
_filedir _filedir
@ -164,7 +164,7 @@ _docker_compose_docker_compose() {
} }
_docker_compose_down() { function _docker_compose_down {
case "$prev" in case "$prev" in
--rmi) --rmi)
COMPREPLY=( $( compgen -W "all local" -- "$cur" ) ) COMPREPLY=( $( compgen -W "all local" -- "$cur" ) )
@ -180,7 +180,7 @@ _docker_compose_down() {
} }
_docker_compose_events() { function _docker_compose_events {
case "$prev" in case "$prev" in
--json) --json)
return return
@ -198,7 +198,7 @@ _docker_compose_events() {
} }
_docker_compose_exec() { function _docker_compose_exec {
case "$prev" in case "$prev" in
--index|--user) --index|--user)
return return
@ -216,12 +216,12 @@ _docker_compose_exec() {
} }
_docker_compose_help() { function _docker_compose_help {
COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) ) COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) )
} }
_docker_compose_kill() { function _docker_compose_kill {
case "$prev" in case "$prev" in
-s) -s)
COMPREPLY=( $( compgen -W "SIGHUP SIGINT SIGKILL SIGUSR1 SIGUSR2" -- "$(echo $cur | tr '[:lower:]' '[:upper:]')" ) ) COMPREPLY=( $( compgen -W "SIGHUP SIGINT SIGKILL SIGUSR1 SIGUSR2" -- "$(echo $cur | tr '[:lower:]' '[:upper:]')" ) )
@ -240,7 +240,7 @@ _docker_compose_kill() {
} }
_docker_compose_logs() { function _docker_compose_logs {
case "$prev" in case "$prev" in
--tail) --tail)
return return
@ -258,7 +258,7 @@ _docker_compose_logs() {
} }
_docker_compose_pause() { function _docker_compose_pause {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
@ -270,7 +270,7 @@ _docker_compose_pause() {
} }
_docker_compose_port() { function _docker_compose_port {
case "$prev" in case "$prev" in
--protocol) --protocol)
COMPREPLY=( $( compgen -W "tcp udp" -- "$cur" ) ) COMPREPLY=( $( compgen -W "tcp udp" -- "$cur" ) )
@ -292,7 +292,7 @@ _docker_compose_port() {
} }
_docker_compose_ps() { function _docker_compose_ps {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help -q" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help -q" -- "$cur" ) )
@ -304,7 +304,7 @@ _docker_compose_ps() {
} }
_docker_compose_pull() { function _docker_compose_pull {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help --ignore-pull-failures" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help --ignore-pull-failures" -- "$cur" ) )
@ -316,7 +316,7 @@ _docker_compose_pull() {
} }
_docker_compose_push() { function _docker_compose_push {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help --ignore-push-failures" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help --ignore-push-failures" -- "$cur" ) )
@ -328,7 +328,7 @@ _docker_compose_push() {
} }
_docker_compose_restart() { function _docker_compose_restart {
case "$prev" in case "$prev" in
--timeout|-t) --timeout|-t)
return return
@ -346,7 +346,7 @@ _docker_compose_restart() {
} }
_docker_compose_rm() { function _docker_compose_rm {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--force -f --help -v" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--force -f --help -v" -- "$cur" ) )
@ -358,7 +358,7 @@ _docker_compose_rm() {
} }
_docker_compose_run() { function _docker_compose_run {
case "$prev" in case "$prev" in
-e) -e)
COMPREPLY=( $( compgen -e -- "$cur" ) ) COMPREPLY=( $( compgen -e -- "$cur" ) )
@ -381,7 +381,7 @@ _docker_compose_run() {
} }
_docker_compose_scale() { function _docker_compose_scale {
case "$prev" in case "$prev" in
=) =)
COMPREPLY=("$cur") COMPREPLY=("$cur")
@ -404,7 +404,7 @@ _docker_compose_scale() {
} }
_docker_compose_start() { function _docker_compose_start {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
@ -416,7 +416,7 @@ _docker_compose_start() {
} }
_docker_compose_stop() { function _docker_compose_stop {
case "$prev" in case "$prev" in
--timeout|-t) --timeout|-t)
return return
@ -434,7 +434,7 @@ _docker_compose_stop() {
} }
_docker_compose_unpause() { function _docker_compose_unpause {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
@ -446,7 +446,7 @@ _docker_compose_unpause() {
} }
_docker_compose_up() { function _docker_compose_up {
case "$prev" in case "$prev" in
--timeout|-t) --timeout|-t)
return return
@ -464,7 +464,7 @@ _docker_compose_up() {
} }
_docker_compose_version() { function _docker_compose_version {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--short" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--short" -- "$cur" ) )
@ -473,7 +473,7 @@ _docker_compose_version() {
} }
_docker_compose() { function _docker_compose {
local previous_extglob_setting=$(shopt -p extglob) local previous_extglob_setting=$(shopt -p extglob)
shopt -s extglob shopt -s extglob

@ -15,7 +15,7 @@
# . ~/.docker-machine-completion.sh # . ~/.docker-machine-completion.sh
# #
_docker_machine_active() { function _docker_machine_active {
if [[ "${cur}" == -* ]]; then if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}")) COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else else
@ -23,7 +23,7 @@ _docker_machine_active() {
fi fi
} }
_docker_machine_config() { function _docker_machine_config {
if [[ "${cur}" == -* ]]; then if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--swarm --help" -- "${cur}")) COMPREPLY=($(compgen -W "--swarm --help" -- "${cur}"))
else else
@ -31,12 +31,12 @@ _docker_machine_config() {
fi fi
} }
_docker_machine_create() { function _docker_machine_create {
# cheating, b/c there are approximately one zillion options to create # cheating, b/c there are approximately one zillion options to create
COMPREPLY=($(compgen -W "$(docker-machine create --help | grep '^ -' | sed 's/^ //; s/[^a-z0-9-].*$//')" -- "${cur}")) COMPREPLY=($(compgen -W "$(docker-machine create --help | grep '^ -' | sed 's/^ //; s/[^a-z0-9-].*$//')" -- "${cur}"))
} }
_docker_machine_env() { function _docker_machine_env {
case "${prev}" in case "${prev}" in
--shell) --shell)
# What are the options for --shell? # What are the options for --shell?
@ -52,7 +52,7 @@ _docker_machine_env() {
} }
# See docker-machine-wrapper.bash for the use command # See docker-machine-wrapper.bash for the use command
_docker_machine_use() { function _docker_machine_use {
if [[ "${cur}" == -* ]]; then if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--swarm --unset --help" -- "${cur}")) COMPREPLY=($(compgen -W "--swarm --unset --help" -- "${cur}"))
else else
@ -60,7 +60,7 @@ _docker_machine_use() {
fi fi
} }
_docker_machine_inspect() { function _docker_machine_inspect {
case "${prev}" in case "${prev}" in
-f|--format) -f|--format)
COMPREPLY=() COMPREPLY=()
@ -75,7 +75,7 @@ _docker_machine_inspect() {
esac esac
} }
_docker_machine_ip() { function _docker_machine_ip {
if [[ "${cur}" == -* ]]; then if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}")) COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else else
@ -83,7 +83,7 @@ _docker_machine_ip() {
fi fi
} }
_docker_machine_kill() { function _docker_machine_kill {
if [[ "${cur}" == -* ]]; then if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}")) COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else else
@ -91,7 +91,7 @@ _docker_machine_kill() {
fi fi
} }
_docker_machine_ls() { function _docker_machine_ls {
case "${prev}" in case "${prev}" in
--filter) --filter)
COMPREPLY=() COMPREPLY=()
@ -102,7 +102,7 @@ _docker_machine_ls() {
esac esac
} }
_docker_machine_regenerate_certs() { function _docker_machine_regenerate_certs {
if [[ "${cur}" == -* ]]; then if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help --force" -- "${cur}")) COMPREPLY=($(compgen -W "--help --force" -- "${cur}"))
else else
@ -110,7 +110,7 @@ _docker_machine_regenerate_certs() {
fi fi
} }
_docker_machine_restart() { function _docker_machine_restart {
if [[ "${cur}" == -* ]]; then if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}")) COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else else
@ -118,7 +118,7 @@ _docker_machine_restart() {
fi fi
} }
_docker_machine_rm() { function _docker_machine_rm {
if [[ "${cur}" == -* ]]; then if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help --force -y" -- "${cur}")) COMPREPLY=($(compgen -W "--help --force -y" -- "${cur}"))
else else
@ -127,7 +127,7 @@ _docker_machine_rm() {
fi fi
} }
_docker_machine_ssh() { function _docker_machine_ssh {
if [[ "${cur}" == -* ]]; then if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}")) COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else else
@ -135,7 +135,7 @@ _docker_machine_ssh() {
fi fi
} }
_docker_machine_scp() { function _docker_machine_scp {
if [[ "${cur}" == -* ]]; then if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help --recursive" -- "${cur}")) COMPREPLY=($(compgen -W "--help --recursive" -- "${cur}"))
else else
@ -146,7 +146,7 @@ _docker_machine_scp() {
fi fi
} }
_docker_machine_start() { function _docker_machine_start {
if [[ "${cur}" == -* ]]; then if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}")) COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else else
@ -154,7 +154,7 @@ _docker_machine_start() {
fi fi
} }
_docker_machine_status() { function _docker_machine_status {
if [[ "${cur}" == -* ]]; then if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}")) COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else else
@ -162,7 +162,7 @@ _docker_machine_status() {
fi fi
} }
_docker_machine_stop() { function _docker_machine_stop {
if [[ "${cur}" == -* ]]; then if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}")) COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else else
@ -170,7 +170,7 @@ _docker_machine_stop() {
fi fi
} }
_docker_machine_upgrade() { function _docker_machine_upgrade {
if [[ "${cur}" == -* ]]; then if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}")) COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else else
@ -178,7 +178,7 @@ _docker_machine_upgrade() {
fi fi
} }
_docker_machine_url() { function _docker_machine_url {
if [[ "${cur}" == -* ]]; then if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}")) COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else else
@ -186,7 +186,7 @@ _docker_machine_url() {
fi fi
} }
_docker_machine_version() { function _docker_machine_version {
if [[ "${cur}" == -* ]]; then if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}")) COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else else
@ -194,7 +194,7 @@ _docker_machine_version() {
fi fi
} }
_docker_machine_help() { function _docker_machine_help {
if [[ "${cur}" == -* ]]; then if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}")) COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else else
@ -202,7 +202,7 @@ _docker_machine_help() {
fi fi
} }
_docker_machine_docker_machine() { function _docker_machine_docker_machine {
if [[ " ${wants_file[*]} " =~ " ${prev} " ]]; then if [[ " ${wants_file[*]} " =~ " ${prev} " ]]; then
_filedir _filedir
elif [[ " ${wants_dir[*]} " =~ " ${prev} " ]]; then elif [[ " ${wants_dir[*]} " =~ " ${prev} " ]]; then
@ -214,7 +214,7 @@ _docker_machine_docker_machine() {
fi fi
} }
_docker_machine() { function _docker_machine {
COMPREPLY=() COMPREPLY=()
local commands=(active config create env inspect ip kill ls regenerate-certs restart rm ssh scp start status stop upgrade url version help) local commands=(active config create env inspect ip kill ls regenerate-certs restart rm ssh scp start status stop upgrade url version help)

@ -54,11 +54,11 @@
__docker_previous_extglob_setting=$(shopt -p extglob) __docker_previous_extglob_setting=$(shopt -p extglob)
shopt -s extglob shopt -s extglob
__docker_q() { function __docker_q {
docker ${host:+-H "$host"} ${config:+--config "$config"} 2>/dev/null "$@" docker ${host:+-H "$host"} ${config:+--config "$config"} 2>/dev/null "$@"
} }
__docker_complete_containers_all() { function __docker_complete_containers_all {
local IFS=$'\n' local IFS=$'\n'
local containers=( $(__docker_q ps -aq --no-trunc) ) local containers=( $(__docker_q ps -aq --no-trunc) )
if [ "$1" ]; then if [ "$1" ]; then
@ -70,35 +70,35 @@ __docker_complete_containers_all() {
COMPREPLY=( $(compgen -W "${names[*]} ${containers[*]}" -- "$cur") ) COMPREPLY=( $(compgen -W "${names[*]} ${containers[*]}" -- "$cur") )
} }
__docker_complete_containers_running() { function __docker_complete_containers_running {
__docker_complete_containers_all '.State.Running' __docker_complete_containers_all '.State.Running'
} }
__docker_complete_containers_stopped() { function __docker_complete_containers_stopped {
__docker_complete_containers_all 'not .State.Running' __docker_complete_containers_all 'not .State.Running'
} }
__docker_complete_containers_pauseable() { function __docker_complete_containers_pauseable {
__docker_complete_containers_all 'and .State.Running (not .State.Paused)' __docker_complete_containers_all 'and .State.Running (not .State.Paused)'
} }
__docker_complete_containers_unpauseable() { function __docker_complete_containers_unpauseable {
__docker_complete_containers_all '.State.Paused' __docker_complete_containers_all '.State.Paused'
} }
__docker_complete_container_names() { function __docker_complete_container_names {
local containers=( $(__docker_q ps -aq --no-trunc) ) local containers=( $(__docker_q ps -aq --no-trunc) )
local names=( $(__docker_q inspect --format '{{.Name}}' "${containers[@]}") ) local names=( $(__docker_q inspect --format '{{.Name}}' "${containers[@]}") )
names=( "${names[@]#/}" ) # trim off the leading "/" from the container names names=( "${names[@]#/}" ) # trim off the leading "/" from the container names
COMPREPLY=( $(compgen -W "${names[*]}" -- "$cur") ) COMPREPLY=( $(compgen -W "${names[*]}" -- "$cur") )
} }
__docker_complete_container_ids() { function __docker_complete_container_ids {
local containers=( $(__docker_q ps -aq) ) local containers=( $(__docker_q ps -aq) )
COMPREPLY=( $(compgen -W "${containers[*]}" -- "$cur") ) COMPREPLY=( $(compgen -W "${containers[*]}" -- "$cur") )
} }
__docker_complete_images() { function __docker_complete_images {
local images_args="" local images_args=""
case "$DOCKER_COMPLETION_SHOW_IMAGE_IDS" in case "$DOCKER_COMPLETION_SHOW_IMAGE_IDS" in
@ -132,18 +132,18 @@ __docker_complete_images() {
__ltrim_colon_completions "$cur" __ltrim_colon_completions "$cur"
} }
__docker_complete_image_repos() { function __docker_complete_image_repos {
local repos="$(__docker_q images | awk 'NR>1 && $1 != "<none>" { print $1 }')" local repos="$(__docker_q images | awk 'NR>1 && $1 != "<none>" { print $1 }')"
COMPREPLY=( $(compgen -W "$repos" -- "$cur") ) COMPREPLY=( $(compgen -W "$repos" -- "$cur") )
} }
__docker_complete_image_repos_and_tags() { function __docker_complete_image_repos_and_tags {
local reposAndTags="$(__docker_q images | awk 'NR>1 && $1 != "<none>" { print $1; print $1":"$2 }')" local reposAndTags="$(__docker_q images | awk 'NR>1 && $1 != "<none>" { print $1; print $1":"$2 }')"
COMPREPLY=( $(compgen -W "$reposAndTags" -- "$cur") ) COMPREPLY=( $(compgen -W "$reposAndTags" -- "$cur") )
__ltrim_colon_completions "$cur" __ltrim_colon_completions "$cur"
} }
__docker_complete_containers_and_images() { function __docker_complete_containers_and_images {
__docker_complete_containers_all __docker_complete_containers_all
local containers=( "${COMPREPLY[@]}" ) local containers=( "${COMPREPLY[@]}" )
__docker_complete_images __docker_complete_images
@ -152,7 +152,7 @@ __docker_complete_containers_and_images() {
# Returns the names and optionally IDs of networks. # Returns the names and optionally IDs of networks.
# The selection can be narrowed by an optional filter parameter, e.g. 'type=custom' # The selection can be narrowed by an optional filter parameter, e.g. 'type=custom'
__docker_networks() { function __docker_networks {
local filter="$1" local filter="$1"
# By default, only network names are completed. # By default, only network names are completed.
# Set DOCKER_COMPLETION_SHOW_NETWORK_IDS=yes to also complete network IDs. # Set DOCKER_COMPLETION_SHOW_NETWORK_IDS=yes to also complete network IDs.
@ -162,40 +162,40 @@ __docker_networks() {
#__docker_q network ls --no-trunc | awk "NR>1 {print $fields}" #__docker_q network ls --no-trunc | awk "NR>1 {print $fields}"
} }
__docker_complete_networks() { function __docker_complete_networks {
COMPREPLY=( $(compgen -W "$(__docker_networks $@)" -- "$cur") ) COMPREPLY=( $(compgen -W "$(__docker_networks $@)" -- "$cur") )
} }
__docker_complete_network_ids() { function __docker_complete_network_ids {
COMPREPLY=( $(compgen -W "$(__docker_q network ls -q --no-trunc)" -- "$cur") ) COMPREPLY=( $(compgen -W "$(__docker_q network ls -q --no-trunc)" -- "$cur") )
} }
__docker_complete_network_names() { function __docker_complete_network_names {
COMPREPLY=( $(compgen -W "$(__docker_q network ls | awk 'NR>1 {print $2}')" -- "$cur") ) COMPREPLY=( $(compgen -W "$(__docker_q network ls | awk 'NR>1 {print $2}')" -- "$cur") )
} }
__docker_complete_containers_in_network() { function __docker_complete_containers_in_network {
local containers=$(__docker_q network inspect -f '{{range $i, $c := .Containers}}{{$i}} {{$c.Name}} {{end}}' "$1") local containers=$(__docker_q network inspect -f '{{range $i, $c := .Containers}}{{$i}} {{$c.Name}} {{end}}' "$1")
COMPREPLY=( $(compgen -W "$containers" -- "$cur") ) COMPREPLY=( $(compgen -W "$containers" -- "$cur") )
} }
__docker_complete_volumes() { function __docker_complete_volumes {
COMPREPLY=( $(compgen -W "$(__docker_q volume ls -q)" -- "$cur") ) COMPREPLY=( $(compgen -W "$(__docker_q volume ls -q)" -- "$cur") )
} }
__docker_plugins() { function __docker_plugins {
__docker_q info | sed -n "/^Plugins/,/^[^ ]/s/ $1: //p" __docker_q info | sed -n "/^Plugins/,/^[^ ]/s/ $1: //p"
} }
__docker_complete_plugins() { function __docker_complete_plugins {
COMPREPLY=( $(compgen -W "$(__docker_plugins $1)" -- "$cur") ) COMPREPLY=( $(compgen -W "$(__docker_plugins $1)" -- "$cur") )
} }
__docker_runtimes() { function __docker_runtimes {
__docker_q info | sed -n 's/^Runtimes: \(.*\)/\1/p' __docker_q info | sed -n 's/^Runtimes: \(.*\)/\1/p'
} }
__docker_complete_runtimes() { function __docker_complete_runtimes {
COMPREPLY=( $(compgen -W "$(__docker_runtimes)" -- "$cur") ) COMPREPLY=( $(compgen -W "$(__docker_runtimes)" -- "$cur") )
} }
@ -207,7 +207,7 @@ __docker_complete_runtimes() {
# An optional first argument `--id|--name` may be used to limit # An optional first argument `--id|--name` may be used to limit
# the output to the IDs or names of matching nodes. This setting takes # the output to the IDs or names of matching nodes. This setting takes
# precedence over the environment setting. # precedence over the environment setting.
__docker_nodes() { function __docker_nodes {
local fields='$2' # default: node name only local fields='$2' # default: node name only
[ "${DOCKER_COMPLETION_SHOW_NODE_IDS}" = yes ] && fields='$1,$2' # ID and name [ "${DOCKER_COMPLETION_SHOW_NODE_IDS}" = yes ] && fields='$1,$2' # ID and name
@ -224,7 +224,7 @@ __docker_nodes() {
# Applies completion of nodes based on the current value of `$cur` or # Applies completion of nodes based on the current value of `$cur` or
# the value of the optional first argument `--cur`, if given. # the value of the optional first argument `--cur`, if given.
# Additional filters may be appended, see `__docker_nodes`. # Additional filters may be appended, see `__docker_nodes`.
__docker_complete_nodes() { function __docker_complete_nodes {
local current=$cur local current=$cur
if [ "$1" = "--cur" ] ; then if [ "$1" = "--cur" ] ; then
current="$2" current="$2"
@ -233,7 +233,7 @@ __docker_complete_nodes() {
COMPREPLY=( $(compgen -W "$(__docker_nodes "$@")" -- "$current") ) COMPREPLY=( $(compgen -W "$(__docker_nodes "$@")" -- "$current") )
} }
__docker_complete_nodes_plus_self() { function __docker_complete_nodes_plus_self {
__docker_complete_nodes "$@" __docker_complete_nodes "$@"
COMPREPLY+=( self ) COMPREPLY+=( self )
} }
@ -246,7 +246,7 @@ __docker_complete_nodes_plus_self() {
# An optional first argument `--id|--name` may be used to limit # An optional first argument `--id|--name` may be used to limit
# the output to the IDs or names of matching services. This setting takes # the output to the IDs or names of matching services. This setting takes
# precedence over the environment setting. # precedence over the environment setting.
__docker_services() { function __docker_services {
local fields='$2' # default: service name only local fields='$2' # default: service name only
[ "${DOCKER_COMPLETION_SHOW_SERVICE_IDS}" = yes ] && fields='$1,$2' # ID & name [ "${DOCKER_COMPLETION_SHOW_SERVICE_IDS}" = yes ] && fields='$1,$2' # ID & name
@ -263,7 +263,7 @@ __docker_services() {
# Applies completion of services based on the current value of `$cur` or # Applies completion of services based on the current value of `$cur` or
# the value of the optional first argument `--cur`, if given. # the value of the optional first argument `--cur`, if given.
# Additional filters may be appended, see `__docker_services`. # Additional filters may be appended, see `__docker_services`.
__docker_complete_services() { function __docker_complete_services {
local current=$cur local current=$cur
if [ "$1" = "--cur" ] ; then if [ "$1" = "--cur" ] ; then
current="$2" current="$2"
@ -275,7 +275,7 @@ __docker_complete_services() {
# Appends the word passed as an argument to every word in `$COMPREPLY`. # Appends the word passed as an argument to every word in `$COMPREPLY`.
# Normally you do this with `compgen -S`. This function exists so that you can use # Normally you do this with `compgen -S`. This function exists so that you can use
# the __docker_complete_XXX functions in cases where you need a suffix. # the __docker_complete_XXX functions in cases where you need a suffix.
__docker_append_to_completions() { function __docker_append_to_completions {
COMPREPLY=( ${COMPREPLY[@]/%/"$1"} ) COMPREPLY=( ${COMPREPLY[@]/%/"$1"} )
} }
@ -283,7 +283,7 @@ __docker_append_to_completions() {
# If there are options that require arguments, you should pass a glob describing those # If there are options that require arguments, you should pass a glob describing those
# options, e.g. "--option1|-o|--option2" # options, e.g. "--option1|-o|--option2"
# Use this function to restrict completions to exact positions after the argument list. # Use this function to restrict completions to exact positions after the argument list.
__docker_pos_first_nonflag() { function __docker_pos_first_nonflag {
local argument_flags=$1 local argument_flags=$1
local counter=$((${subcommand_pos:-${command_pos}} + 1)) local counter=$((${subcommand_pos:-${command_pos}} + 1))
@ -317,7 +317,7 @@ __docker_pos_first_nonflag() {
# If we are currently completing the value of a map option (key=value) # If we are currently completing the value of a map option (key=value)
# which matches the extglob given as an argument, returns key. # which matches the extglob given as an argument, returns key.
# This function is needed for key-specific completions. # This function is needed for key-specific completions.
__docker_map_key_of_current_option() { function __docker_map_key_of_current_option {
local glob="$1" local glob="$1"
local key glob_pos local key glob_pos
@ -343,7 +343,7 @@ __docker_map_key_of_current_option() {
# Valid values for option_glob are option names like '--log-level' and # Valid values for option_glob are option names like '--log-level' and
# globs like '--log-level|-l' # globs like '--log-level|-l'
# Only positions between the command and the current word are considered. # Only positions between the command and the current word are considered.
__docker_value_of_option() { function __docker_value_of_option {
local option_extglob=$(__docker_to_extglob "$1") local option_extglob=$(__docker_to_extglob "$1")
local counter=$((command_pos + 1)) local counter=$((command_pos + 1))
@ -361,7 +361,7 @@ __docker_value_of_option() {
# Transforms a multiline list of strings into a single line string # Transforms a multiline list of strings into a single line string
# with the words separated by "|". # with the words separated by "|".
# This is used to prepare arguments to __docker_pos_first_nonflag(). # This is used to prepare arguments to __docker_pos_first_nonflag().
__docker_to_alternatives() { function __docker_to_alternatives {
local parts=( $1 ) local parts=( $1 )
local IFS='|' local IFS='|'
echo "${parts[*]}" echo "${parts[*]}"
@ -369,7 +369,7 @@ __docker_to_alternatives() {
# Transforms a multiline list of options into an extglob pattern # Transforms a multiline list of options into an extglob pattern
# suitable for use in case statements. # suitable for use in case statements.
__docker_to_extglob() { function __docker_to_extglob {
local extglob=$( __docker_to_alternatives "$1" ) local extglob=$( __docker_to_alternatives "$1" )
echo "@($extglob)" echo "@($extglob)"
} }
@ -384,7 +384,7 @@ __docker_to_extglob() {
# TODO if the preceding command has options that accept arguments and an # TODO if the preceding command has options that accept arguments and an
# argument is equal ot one of the subcommands, this is falsely detected as # argument is equal ot one of the subcommands, this is falsely detected as
# a match. # a match.
__docker_subcommands() { function __docker_subcommands {
local subcommands="$1" local subcommands="$1"
local counter=$(($command_pos + 1)) local counter=$(($command_pos + 1))
@ -404,17 +404,17 @@ __docker_subcommands() {
} }
# suppress trailing whitespace # suppress trailing whitespace
__docker_nospace() { function __docker_nospace {
# compopt is not available in ancient bash versions # compopt is not available in ancient bash versions
_omb_util_command_exists compopt && compopt -o nospace _omb_util_command_exists compopt && compopt -o nospace
} }
__docker_complete_resolved_hostname() { function __docker_complete_resolved_hostname {
_omb_util_command_exists host || return _omb_util_command_exists host || return
COMPREPLY=( $(host 2>/dev/null "${cur%:}" | awk '/has address/ {print $4}') ) COMPREPLY=( $(host 2>/dev/null "${cur%:}" | awk '/has address/ {print $4}') )
} }
__docker_complete_capabilities() { function __docker_complete_capabilities {
# The list of capabilities is defined in types.go, ALL was added manually. # The list of capabilities is defined in types.go, ALL was added manually.
COMPREPLY=( $( compgen -W " COMPREPLY=( $( compgen -W "
ALL ALL
@ -459,7 +459,7 @@ __docker_complete_capabilities() {
" -- "$cur" ) ) " -- "$cur" ) )
} }
__docker_complete_detach-keys() { function __docker_complete_detach-keys {
case "$prev" in case "$prev" in
--detach-keys) --detach-keys)
case "$cur" in case "$cur" in
@ -478,11 +478,11 @@ __docker_complete_detach-keys() {
return 1 return 1
} }
__docker_complete_isolation() { function __docker_complete_isolation {
COMPREPLY=( $( compgen -W "default hyperv process" -- "$cur" ) ) COMPREPLY=( $( compgen -W "default hyperv process" -- "$cur" ) )
} }
__docker_complete_log_drivers() { function __docker_complete_log_drivers {
COMPREPLY=( $( compgen -W " COMPREPLY=( $( compgen -W "
awslogs awslogs
etwlogs etwlogs
@ -497,7 +497,7 @@ __docker_complete_log_drivers() {
" -- "$cur" ) ) " -- "$cur" ) )
} }
__docker_complete_log_options() { function __docker_complete_log_options {
# see docs/reference/logging/index.md # see docs/reference/logging/index.md
local awslogs_options="awslogs-region awslogs-group awslogs-stream" local awslogs_options="awslogs-region awslogs-group awslogs-stream"
local fluentd_options="env fluentd-address fluentd-async-connect fluentd-buffer-limit fluentd-retry-wait fluentd-max-retries labels tag" local fluentd_options="env fluentd-address fluentd-async-connect fluentd-buffer-limit fluentd-retry-wait fluentd-max-retries labels tag"
@ -546,7 +546,7 @@ __docker_complete_log_options() {
__docker_nospace __docker_nospace
} }
__docker_complete_log_driver_options() { function __docker_complete_log_driver_options {
local key=$(__docker_map_key_of_current_option '--log-opt') local key=$(__docker_map_key_of_current_option '--log-opt')
case "$key" in case "$key" in
fluentd-async-connect) fluentd-async-connect)
@ -623,11 +623,11 @@ __docker_complete_log_driver_options() {
return 1 return 1
} }
__docker_complete_log_levels() { function __docker_complete_log_levels {
COMPREPLY=( $( compgen -W "debug info warn error fatal" -- "$cur" ) ) COMPREPLY=( $( compgen -W "debug info warn error fatal" -- "$cur" ) )
} }
__docker_complete_restart() { function __docker_complete_restart {
case "$prev" in case "$prev" in
--restart) --restart)
case "$cur" in case "$cur" in
@ -645,7 +645,7 @@ __docker_complete_restart() {
# a selection of the available signals that is most likely of interest in the # a selection of the available signals that is most likely of interest in the
# context of docker containers. # context of docker containers.
__docker_complete_signals() { function __docker_complete_signals {
local signals=( local signals=(
SIGCONT SIGCONT
SIGHUP SIGHUP
@ -660,7 +660,7 @@ __docker_complete_signals() {
COMPREPLY=( $( compgen -W "${signals[*]} ${signals[*]#SIG}" -- "$( echo $cur | tr '[:lower:]' '[:upper:]')" ) ) COMPREPLY=( $( compgen -W "${signals[*]} ${signals[*]#SIG}" -- "$( echo $cur | tr '[:lower:]' '[:upper:]')" ) )
} }
__docker_complete_user_group() { function __docker_complete_user_group {
if [[ $cur == *:* ]] ; then if [[ $cur == *:* ]] ; then
COMPREPLY=( $(compgen -g -- "${cur#*:}") ) COMPREPLY=( $(compgen -g -- "${cur#*:}") )
else else
@ -670,7 +670,7 @@ __docker_complete_user_group() {
} }
# global options that may appear after the docker command # global options that may appear after the docker command
_docker_docker() { function _docker_docker {
local boolean_options=" local boolean_options="
$global_boolean_options $global_boolean_options
--help --help
@ -704,7 +704,7 @@ _docker_docker() {
esac esac
} }
_docker_attach() { function _docker_attach {
__docker_complete_detach-keys && return __docker_complete_detach-keys && return
case "$cur" in case "$cur" in
@ -720,7 +720,7 @@ _docker_attach() {
esac esac
} }
_docker_build() { function _docker_build {
local options_with_args=" local options_with_args="
--build-arg --build-arg
--cgroup-parent --cgroup-parent
@ -787,7 +787,7 @@ _docker_build() {
esac esac
} }
_docker_commit() { function _docker_commit {
case "$prev" in case "$prev" in
--author|-a|--change|-c|--message|-m) --author|-a|--change|-c|--message|-m)
return return
@ -815,7 +815,7 @@ _docker_commit() {
esac esac
} }
_docker_cp() { function _docker_cp {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--follow-link -L --help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--follow-link -L --help" -- "$cur" ) )
@ -860,11 +860,11 @@ _docker_cp() {
esac esac
} }
_docker_create() { function _docker_create {
_docker_run _docker_run
} }
_docker_daemon() { function _docker_daemon {
local boolean_options=" local boolean_options="
$global_boolean_options $global_boolean_options
--disable-legacy-registry --disable-legacy-registry
@ -1041,7 +1041,7 @@ _docker_daemon() {
esac esac
} }
_docker_diff() { function _docker_diff {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
@ -1055,7 +1055,7 @@ _docker_diff() {
esac esac
} }
_docker_events() { function _docker_events {
local key=$(__docker_map_key_of_current_option '-f|--filter') local key=$(__docker_map_key_of_current_option '-f|--filter')
case "$key" in case "$key" in
container) container)
@ -1147,7 +1147,7 @@ _docker_events() {
esac esac
} }
_docker_exec() { function _docker_exec {
__docker_complete_detach-keys && return __docker_complete_detach-keys && return
case "$prev" in case "$prev" in
@ -1167,7 +1167,7 @@ _docker_exec() {
esac esac
} }
_docker_export() { function _docker_export {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
@ -1181,14 +1181,14 @@ _docker_export() {
esac esac
} }
_docker_help() { function _docker_help {
local counter=$(__docker_pos_first_nonflag) local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then if [ $cword -eq $counter ]; then
COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) ) COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) )
fi fi
} }
_docker_history() { function _docker_history {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help --human=false -H=false --no-trunc --quiet -q" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help --human=false -H=false --no-trunc --quiet -q" -- "$cur" ) )
@ -1202,7 +1202,7 @@ _docker_history() {
esac esac
} }
_docker_images() { function _docker_images {
local key=$(__docker_map_key_of_current_option '--filter|-f') local key=$(__docker_map_key_of_current_option '--filter|-f')
case "$key" in case "$key" in
before) before)
@ -1248,7 +1248,7 @@ _docker_images() {
esac esac
} }
_docker_import() { function _docker_import {
case "$prev" in case "$prev" in
--change|-c|--message|-m) --change|-c|--message|-m)
return return
@ -1274,7 +1274,7 @@ _docker_import() {
esac esac
} }
_docker_info() { function _docker_info {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
@ -1282,7 +1282,7 @@ _docker_info() {
esac esac
} }
_docker_inspect() { function _docker_inspect {
case "$prev" in case "$prev" in
--format|-f) --format|-f)
return return
@ -1313,7 +1313,7 @@ _docker_inspect() {
esac esac
} }
_docker_kill() { function _docker_kill {
case "$prev" in case "$prev" in
--signal|-s) --signal|-s)
__docker_complete_signals __docker_complete_signals
@ -1331,7 +1331,7 @@ _docker_kill() {
esac esac
} }
_docker_load() { function _docker_load {
case "$prev" in case "$prev" in
--input|-i) --input|-i)
_filedir _filedir
@ -1346,7 +1346,7 @@ _docker_load() {
esac esac
} }
_docker_login() { function _docker_login {
case "$prev" in case "$prev" in
--password|-p|--username|-u) --password|-p|--username|-u)
return return
@ -1360,7 +1360,7 @@ _docker_login() {
esac esac
} }
_docker_logout() { function _docker_logout {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
@ -1368,7 +1368,7 @@ _docker_logout() {
esac esac
} }
_docker_logs() { function _docker_logs {
case "$prev" in case "$prev" in
--since|--tail) --since|--tail)
return return
@ -1388,7 +1388,7 @@ _docker_logs() {
esac esac
} }
_docker_network_connect() { function _docker_network_connect {
local options_with_args=" local options_with_args="
--alias --alias
--ip --ip
@ -1434,7 +1434,7 @@ _docker_network_connect() {
esac esac
} }
_docker_network_create() { function _docker_network_create {
case "$prev" in case "$prev" in
--aux-address|--gateway|--internal|--ip-range|--ipam-opt|--ipv6|--opt|-o|--subnet) --aux-address|--gateway|--internal|--ip-range|--ipam-opt|--ipv6|--opt|-o|--subnet)
return return
@ -1463,7 +1463,7 @@ _docker_network_create() {
esac esac
} }
_docker_network_disconnect() { function _docker_network_disconnect {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
@ -1479,7 +1479,7 @@ _docker_network_disconnect() {
esac esac
} }
_docker_network_inspect() { function _docker_network_inspect {
case "$prev" in case "$prev" in
--format|-f) --format|-f)
return return
@ -1495,7 +1495,7 @@ _docker_network_inspect() {
esac esac
} }
_docker_network_ls() { function _docker_network_ls {
local key=$(__docker_map_key_of_current_option '--filter|-f') local key=$(__docker_map_key_of_current_option '--filter|-f')
case "$key" in case "$key" in
driver) driver)
@ -1534,7 +1534,7 @@ _docker_network_ls() {
esac esac
} }
_docker_network_rm() { function _docker_network_rm {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
@ -1544,7 +1544,7 @@ _docker_network_rm() {
esac esac
} }
_docker_network() { function _docker_network {
local subcommands=" local subcommands="
connect connect
create create
@ -1565,7 +1565,7 @@ _docker_network() {
esac esac
} }
_docker_service() { function _docker_service {
local subcommands=" local subcommands="
create create
inspect inspect
@ -1587,11 +1587,11 @@ _docker_service() {
esac esac
} }
_docker_service_create() { function _docker_service_create {
_docker_service_update _docker_service_update
} }
_docker_service_inspect() { function _docker_service_inspect {
case "$prev" in case "$prev" in
--format|-f) --format|-f)
return return
@ -1607,11 +1607,11 @@ _docker_service_inspect() {
esac esac
} }
_docker_service_list() { function _docker_service_list {
_docker_service_ls _docker_service_ls
} }
_docker_service_ls() { function _docker_service_ls {
local key=$(__docker_map_key_of_current_option '--filter|-f') local key=$(__docker_map_key_of_current_option '--filter|-f')
case "$key" in case "$key" in
id) id)
@ -1639,11 +1639,11 @@ _docker_service_ls() {
esac esac
} }
_docker_service_remove() { function _docker_service_remove {
_docker_service_rm _docker_service_rm
} }
_docker_service_rm() { function _docker_service_rm {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
@ -1653,7 +1653,7 @@ _docker_service_rm() {
esac esac
} }
_docker_service_scale() { function _docker_service_scale {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
@ -1666,7 +1666,7 @@ _docker_service_scale() {
esac esac
} }
_docker_service_tasks() { function _docker_service_tasks {
local key=$(__docker_map_key_of_current_option '--filter|-f') local key=$(__docker_map_key_of_current_option '--filter|-f')
case "$key" in case "$key" in
desired-state) desired-state)
@ -1700,7 +1700,7 @@ _docker_service_tasks() {
esac esac
} }
_docker_service_update() { function _docker_service_update {
local $subcommand="${words[$subcommand_pos]}" local $subcommand="${words[$subcommand_pos]}"
local options_with_args=" local options_with_args="
@ -1790,7 +1790,7 @@ _docker_service_update() {
esac esac
} }
_docker_swarm() { function _docker_swarm {
local subcommands=" local subcommands="
init init
inspect inspect
@ -1810,7 +1810,7 @@ _docker_swarm() {
esac esac
} }
_docker_swarm_init() { function _docker_swarm_init {
case "$prev" in case "$prev" in
--auto-accept) --auto-accept)
COMPREPLY=( $( compgen -W "manager none worker" -- "$cur" ) ) COMPREPLY=( $( compgen -W "manager none worker" -- "$cur" ) )
@ -1834,7 +1834,7 @@ _docker_swarm_init() {
esac esac
} }
_docker_swarm_inspect() { function _docker_swarm_inspect {
case "$prev" in case "$prev" in
--format|-f) --format|-f)
return return
@ -1848,7 +1848,7 @@ _docker_swarm_inspect() {
esac esac
} }
_docker_swarm_join() { function _docker_swarm_join {
case "$prev" in case "$prev" in
--ca-hash|--secret) --ca-hash|--secret)
return return
@ -1871,7 +1871,7 @@ _docker_swarm_join() {
esac esac
} }
_docker_swarm_leave() { function _docker_swarm_leave {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--force --help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--force --help" -- "$cur" ) )
@ -1879,7 +1879,7 @@ _docker_swarm_leave() {
esac esac
} }
_docker_swarm_update() { function _docker_swarm_update {
case "$prev" in case "$prev" in
--auto-accept) --auto-accept)
COMPREPLY=( $( compgen -W "manager none worker" -- "$cur" ) ) COMPREPLY=( $( compgen -W "manager none worker" -- "$cur" ) )
@ -1897,7 +1897,7 @@ _docker_swarm_update() {
esac esac
} }
_docker_node() { function _docker_node {
local subcommands=" local subcommands="
accept accept
demote demote
@ -1920,7 +1920,7 @@ _docker_node() {
esac esac
} }
_docker_node_accept() { function _docker_node_accept {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
@ -1930,7 +1930,7 @@ _docker_node_accept() {
esac esac
} }
_docker_node_demote() { function _docker_node_demote {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
@ -1940,7 +1940,7 @@ _docker_node_demote() {
esac esac
} }
_docker_node_inspect() { function _docker_node_inspect {
case "$prev" in case "$prev" in
--format|-f) --format|-f)
return return
@ -1956,11 +1956,11 @@ _docker_node_inspect() {
esac esac
} }
_docker_node_list() { function _docker_node_list {
_docker_node_ls _docker_node_ls
} }
_docker_node_ls() { function _docker_node_ls {
local key=$(__docker_map_key_of_current_option '--filter|-f') local key=$(__docker_map_key_of_current_option '--filter|-f')
case "$key" in case "$key" in
id) id)
@ -1988,7 +1988,7 @@ _docker_node_ls() {
esac esac
} }
_docker_node_promote() { function _docker_node_promote {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
@ -1998,11 +1998,11 @@ _docker_node_promote() {
esac esac
} }
_docker_node_remove() { function _docker_node_remove {
_docker_node_rm _docker_node_rm
} }
_docker_node_rm() { function _docker_node_rm {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
@ -2012,7 +2012,7 @@ _docker_node_rm() {
esac esac
} }
_docker_node_tasks() { function _docker_node_tasks {
local key=$(__docker_map_key_of_current_option '--filter|-f') local key=$(__docker_map_key_of_current_option '--filter|-f')
case "$key" in case "$key" in
desired-state) desired-state)
@ -2046,7 +2046,7 @@ _docker_node_tasks() {
esac esac
} }
_docker_node_update() { function _docker_node_update {
case "$prev" in case "$prev" in
--availability) --availability)
COMPREPLY=( $( compgen -W "active drain pause" -- "$cur" ) ) COMPREPLY=( $( compgen -W "active drain pause" -- "$cur" ) )
@ -2071,7 +2071,7 @@ _docker_node_update() {
esac esac
} }
_docker_pause() { function _docker_pause {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
@ -2085,7 +2085,7 @@ _docker_pause() {
esac esac
} }
_docker_port() { function _docker_port {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
@ -2099,7 +2099,7 @@ _docker_port() {
esac esac
} }
_docker_ps() { function _docker_ps {
local key=$(__docker_map_key_of_current_option '--filter|-f') local key=$(__docker_map_key_of_current_option '--filter|-f')
case "$key" in case "$key" in
ancestor) ancestor)
@ -2161,7 +2161,7 @@ _docker_ps() {
esac esac
} }
_docker_pull() { function _docker_pull {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--all-tags -a --disable-content-trust=false --help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--all-tags -a --disable-content-trust=false --help" -- "$cur" ) )
@ -2183,7 +2183,7 @@ _docker_pull() {
esac esac
} }
_docker_push() { function _docker_push {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--disable-content-trust=false --help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--disable-content-trust=false --help" -- "$cur" ) )
@ -2197,7 +2197,7 @@ _docker_push() {
esac esac
} }
_docker_rename() { function _docker_rename {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
@ -2211,7 +2211,7 @@ _docker_rename() {
esac esac
} }
_docker_restart() { function _docker_restart {
case "$prev" in case "$prev" in
--time|-t) --time|-t)
return return
@ -2228,7 +2228,7 @@ _docker_restart() {
esac esac
} }
_docker_rm() { function _docker_rm {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--force -f --help --link -l --volumes -v" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--force -f --help --link -l --volumes -v" -- "$cur" ) )
@ -2247,7 +2247,7 @@ _docker_rm() {
esac esac
} }
_docker_rmi() { function _docker_rmi {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--force -f --help --no-prune" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--force -f --help --no-prune" -- "$cur" ) )
@ -2258,7 +2258,7 @@ _docker_rmi() {
esac esac
} }
_docker_run() { function _docker_run {
local options_with_args=" local options_with_args="
--add-host --add-host
--attach -a --attach -a
@ -2541,7 +2541,7 @@ _docker_run() {
esac esac
} }
_docker_save() { function _docker_save {
case "$prev" in case "$prev" in
--output|-o) --output|-o)
_filedir _filedir
@ -2559,7 +2559,7 @@ _docker_save() {
esac esac
} }
_docker_search() { function _docker_search {
local key=$(__docker_map_key_of_current_option '--filter|-f') local key=$(__docker_map_key_of_current_option '--filter|-f')
case "$key" in case "$key" in
is-automated) is-automated)
@ -2590,7 +2590,7 @@ _docker_search() {
esac esac
} }
_docker_start() { function _docker_start {
__docker_complete_detach-keys && return __docker_complete_detach-keys && return
case "$cur" in case "$cur" in
@ -2603,7 +2603,7 @@ _docker_start() {
esac esac
} }
_docker_stats() { function _docker_stats {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--all -a --help --no-stream" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--all -a --help --no-stream" -- "$cur" ) )
@ -2614,7 +2614,7 @@ _docker_stats() {
esac esac
} }
_docker_stop() { function _docker_stop {
case "$prev" in case "$prev" in
--time|-t) --time|-t)
return return
@ -2631,7 +2631,7 @@ _docker_stop() {
esac esac
} }
_docker_tag() { function _docker_tag {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
@ -2653,7 +2653,7 @@ _docker_tag() {
esac esac
} }
_docker_unpause() { function _docker_unpause {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
@ -2667,7 +2667,7 @@ _docker_unpause() {
esac esac
} }
_docker_update() { function _docker_update {
local options_with_args=" local options_with_args="
--blkio-weight --blkio-weight
--cpu-period --cpu-period
@ -2706,7 +2706,7 @@ _docker_update() {
esac esac
} }
_docker_top() { function _docker_top {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
@ -2720,7 +2720,7 @@ _docker_top() {
esac esac
} }
_docker_version() { function _docker_version {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
@ -2728,7 +2728,7 @@ _docker_version() {
esac esac
} }
_docker_volume_create() { function _docker_volume_create {
case "$prev" in case "$prev" in
--driver|-d) --driver|-d)
__docker_complete_plugins Volume __docker_complete_plugins Volume
@ -2746,7 +2746,7 @@ _docker_volume_create() {
esac esac
} }
_docker_volume_inspect() { function _docker_volume_inspect {
case "$prev" in case "$prev" in
--format|-f) --format|-f)
return return
@ -2763,7 +2763,7 @@ _docker_volume_inspect() {
esac esac
} }
_docker_volume_ls() { function _docker_volume_ls {
local key=$(__docker_map_key_of_current_option '--filter|-f') local key=$(__docker_map_key_of_current_option '--filter|-f')
case "$key" in case "$key" in
dangling) dangling)
@ -2797,7 +2797,7 @@ _docker_volume_ls() {
esac esac
} }
_docker_volume_rm() { function _docker_volume_rm {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
@ -2808,7 +2808,7 @@ _docker_volume_rm() {
esac esac
} }
_docker_volume() { function _docker_volume {
local subcommands=" local subcommands="
create create
inspect inspect
@ -2827,7 +2827,7 @@ _docker_volume() {
esac esac
} }
_docker_wait() { function _docker_wait {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
@ -2838,7 +2838,7 @@ _docker_wait() {
esac esac
} }
_docker() { function _docker {
local previous_extglob_setting=$(shopt -p extglob) local previous_extglob_setting=$(shopt -p extglob)
shopt -s extglob shopt -s extglob

@ -9,7 +9,7 @@
# Ensure drush is available. # Ensure drush is available.
_omb_util_command_exists drush || return _omb_util_command_exists drush || return
__drush_ps1() { function __drush_ps1 {
f="${TMPDIR:-/tmp/}/drush-env/drush-drupal-site-$$" f="${TMPDIR:-/tmp/}/drush-env/drush-drupal-site-$$"
if [ -f $f ] if [ -f $f ]
then then
@ -23,7 +23,7 @@ __drush_ps1() {
# Completion function, uses the "drush complete" command to retrieve # Completion function, uses the "drush complete" command to retrieve
# completions for a specific command line COMP_WORDS. # completions for a specific command line COMP_WORDS.
_drush_completion() { function _drush_completion {
# Set IFS to newline (locally), since we only use newline separators, and # Set IFS to newline (locally), since we only use newline separators, and
# need to retain spaces (or not) after completions. # need to retain spaces (or not) after completions.
local IFS=$'\n' local IFS=$'\n'

@ -1,7 +1,7 @@
#! bash oh-my-bash.module #! bash oh-my-bash.module
# Completion for gem # Completion for gem
_installcomp() { function _installcomp {
if [ -z "$REMOTE_GEMS" ] if [ -z "$REMOTE_GEMS" ]
then then
REMOTE_GEMS=( $(gem list --remote --no-versions | tr '\n' ' ') ) REMOTE_GEMS=( $(gem list --remote --no-versions | tr '\n' ' ') )
@ -11,7 +11,7 @@ _installcomp() {
COMPREPLY=( $(compgen -W "${REMOTE_GEMS[*]}" -- $cur) ) COMPREPLY=( $(compgen -W "${REMOTE_GEMS[*]}" -- $cur) )
} }
_uninstallcomp() { function _uninstallcomp {
if [ -z "$LOCAL_GEMS" ] if [ -z "$LOCAL_GEMS" ]
then then
LOCAL_GEMS=( $(gem list --no-versions | sed 's/\*\*\* LOCAL GEMS \*\*\*//' | tr '\n' ' ') ) LOCAL_GEMS=( $(gem list --no-versions | sed 's/\*\*\* LOCAL GEMS \*\*\*//' | tr '\n' ' ') )
@ -21,7 +21,7 @@ _uninstallcomp() {
COMPREPLY=( $(compgen -W "${LOCAL_GEMS[*]}" -- $cur) ) COMPREPLY=( $(compgen -W "${LOCAL_GEMS[*]}" -- $cur) )
} }
_gem() { function _gem {
local cur=${COMP_WORDS[COMP_CWORD]} local cur=${COMP_WORDS[COMP_CWORD]}
local prev=${COMP_WORDS[COMP_CWORD-1]} local prev=${COMP_WORDS[COMP_CWORD-1]}
case $prev in case $prev in

@ -9,7 +9,7 @@ if _omb_util_function_exists _git; then
sed 's/__git_list_all_commands/__git_list_all_commands_without_hub/')" sed 's/__git_list_all_commands/__git_list_all_commands_without_hub/')"
# Wrap the 'list_all_commands' function with extra hub commands # Wrap the 'list_all_commands' function with extra hub commands
__git_list_all_commands() { function __git_list_all_commands {
cat <<-EOF cat <<-EOF
alias alias
pull-request pull-request
@ -33,7 +33,7 @@ EOF
########################## ##########################
# hub alias [-s] [SHELL] # hub alias [-s] [SHELL]
_git_alias() { function _git_alias {
local i c=2 s=-s sh shells="bash zsh sh ksh csh fish" local i c=2 s=-s sh shells="bash zsh sh ksh csh fish"
while [ $c -lt $cword ]; do while [ $c -lt $cword ]; do
i="${words[c]}" i="${words[c]}"
@ -56,7 +56,7 @@ EOF
} }
# hub browse [-u] [--|[USER/]REPOSITORY] [SUBPAGE] # hub browse [-u] [--|[USER/]REPOSITORY] [SUBPAGE]
_git_browse() { function _git_browse {
local i c=2 u=-u repo subpage local i c=2 u=-u repo subpage
local subpages_="commits issues tree wiki pulls branches stargazers local subpages_="commits issues tree wiki pulls branches stargazers
contributors network network/ graphs graphs/" contributors network network/ graphs graphs/"
@ -97,7 +97,7 @@ EOF
} }
# hub compare [-u] [USER[/REPOSITORY]] [[START...]END] # hub compare [-u] [USER[/REPOSITORY]] [[START...]END]
_git_compare() { function _git_compare {
local i c=$((cword - 1)) u=-u user remote owner repo arg_repo rev local i c=$((cword - 1)) u=-u user remote owner repo arg_repo rev
while [ $c -gt 1 ]; do while [ $c -gt 1 ]; do
i="${words[c]}" i="${words[c]}"
@ -181,7 +181,7 @@ EOF
} }
# hub create [NAME] [-p] [-d DESCRIPTION] [-h HOMEPAGE] # hub create [NAME] [-p] [-d DESCRIPTION] [-h HOMEPAGE]
_git_create() { function _git_create {
local i c=2 name repo flags="-p -d -h" local i c=2 name repo flags="-p -d -h"
while [ $c -lt $cword ]; do while [ $c -lt $cword ]; do
i="${words[c]}" i="${words[c]}"
@ -213,7 +213,7 @@ EOF
} }
# hub fork [--no-remote] # hub fork [--no-remote]
_git_fork() { function _git_fork {
local i c=2 remote=yes local i c=2 remote=yes
while [ $c -lt $cword ]; do while [ $c -lt $cword ]; do
i="${words[c]}" i="${words[c]}"
@ -230,7 +230,7 @@ EOF
} }
# hub pull-request [-f] [-m <MESSAGE>|-F <FILE>|-i <ISSUE>|<ISSUE-URL>] [-b <BASE>] [-h <HEAD>] # hub pull-request [-f] [-m <MESSAGE>|-F <FILE>|-i <ISSUE>|<ISSUE-URL>] [-b <BASE>] [-h <HEAD>]
_git_pull_request() { function _git_pull_request {
local i c=2 flags="-f -m -F -i -b -h" local i c=2 flags="-f -m -F -i -b -h"
while [ $c -lt $cword ]; do while [ $c -lt $cword ]; do
i="${words[c]}" i="${words[c]}"
@ -272,7 +272,7 @@ EOF
# __hub_github_user [HOST] # __hub_github_user [HOST]
# Return $GITHUB_USER or the default github user defined in hub config # Return $GITHUB_USER or the default github user defined in hub config
# 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"
__hub_github_user() { function __hub_github_user {
if [ -n "$GITHUB_USER" ]; then if [ -n "$GITHUB_USER" ]; then
echo $GITHUB_USER echo $GITHUB_USER
return return
@ -310,7 +310,7 @@ EOF
# \o owner # \o owner
# escaped characters (\n, \t ...etc) work # escaped characters (\n, \t ...etc) work
# If omitted, prints all github repos in the format of "remote:owner/repo" # If omitted, prints all github repos in the format of "remote:owner/repo"
__hub_github_repos() { function __hub_github_repos {
local f format=$1 local f format=$1
if [ -z "$(__gitdir)" ]; then if [ -z "$(__gitdir)" ]; then
return return
@ -329,7 +329,7 @@ EOF
# __hub_heads # __hub_heads
# List all local "branch", and remote "owner/repo:branch" # List all local "branch", and remote "owner/repo:branch"
__hub_heads() { function __hub_heads {
local i remote repo branch dir=$(__gitdir) local i remote repo branch dir=$(__gitdir)
if [ -d "$dir" ]; then if [ -d "$dir" ]; then
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
@ -348,7 +348,7 @@ EOF
# __hub_revlist [REMOTE] # __hub_revlist [REMOTE]
# List all tags, and branches under REMOTE, without the "remote/" prefix # List all tags, and branches under REMOTE, without the "remote/" prefix
# REMOTE - Remote name to search branches from. Default is "origin" # REMOTE - Remote name to search branches from. Default is "origin"
__hub_revlist() { function __hub_revlist {
local i remote=${1:-origin} dir=$(__gitdir) local i remote=${1:-origin} dir=$(__gitdir)
if [ -d "$dir" ]; then if [ -d "$dir" ]; then
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \

@ -1,6 +1,6 @@
#! bash oh-my-bash.module #! bash oh-my-bash.module
# bash completion support for Git. # bash completion support for Git.
_omb_completion_git_initialize() { function _omb_completion_git_initialize {
if ! _omb_util_function_exists __gitdir; then if ! _omb_util_function_exists __gitdir; then
local git_paths path local git_paths path
IFS=$'\n' read -r -d '' -a git_paths <<< "$(type -aP git)" IFS=$'\n' read -r -d '' -a git_paths <<< "$(type -aP git)"

@ -10,10 +10,10 @@ complete -f -X '!*.6' 6l
complete -f -X '!*.5' 5l complete -f -X '!*.5' 5l
complete -f -X '!*.go' 8g 6g 5g gofmt gccgo complete -f -X '!*.go' 8g 6g 5g gofmt gccgo
_go_clear_cache() { function _go_clear_cache {
unset _go_imports unset _go_imports
} }
_go_importpath_cache() { function _go_importpath_cache {
if [ -z "$_go_imports" ]; then if [ -z "$_go_imports" ]; then
_go_imports=$(go list all 2>/dev/null) _go_imports=$(go list all 2>/dev/null)
export _go_imports export _go_imports

@ -14,7 +14,7 @@ if _omb_util_function_exists _git; then
sed 's/__git_list_all_commands/__git_list_all_commands_without_hub/')" sed 's/__git_list_all_commands/__git_list_all_commands_without_hub/')"
# Wrap the 'list_all_commands' function with extra hub commands # Wrap the 'list_all_commands' function with extra hub commands
__git_list_all_commands() { function __git_list_all_commands {
cat <<-EOF cat <<-EOF
alias alias
pull-request pull-request
@ -35,7 +35,7 @@ EOF
########################## ##########################
# hub alias [-s] [SHELL] # hub alias [-s] [SHELL]
_git_alias() { function _git_alias {
local i c=2 s=-s sh shells="bash zsh sh ksh csh fish" local i c=2 s=-s sh shells="bash zsh sh ksh csh fish"
while [ $c -lt $cword ]; do while [ $c -lt $cword ]; do
i="${words[c]}" i="${words[c]}"
@ -58,7 +58,7 @@ EOF
} }
# hub browse [-u] [--|[USER/]REPOSITORY] [SUBPAGE] # hub browse [-u] [--|[USER/]REPOSITORY] [SUBPAGE]
_git_browse() { function _git_browse {
local i c=2 u=-u repo subpage local i c=2 u=-u repo subpage
local subpages_="commits issues tree wiki pulls branches stargazers local subpages_="commits issues tree wiki pulls branches stargazers
contributors network network/ graphs graphs/" contributors network network/ graphs graphs/"
@ -99,7 +99,7 @@ EOF
} }
# hub compare [-u] [USER[/REPOSITORY]] [[START...]END] # hub compare [-u] [USER[/REPOSITORY]] [[START...]END]
_git_compare() { function _git_compare {
local i c=$((cword - 1)) u=-u user remote owner repo arg_repo rev local i c=$((cword - 1)) u=-u user remote owner repo arg_repo rev
while [ $c -gt 1 ]; do while [ $c -gt 1 ]; do
i="${words[c]}" i="${words[c]}"
@ -183,7 +183,7 @@ EOF
} }
# hub create [NAME] [-p] [-d DESCRIPTION] [-h HOMEPAGE] # hub create [NAME] [-p] [-d DESCRIPTION] [-h HOMEPAGE]
_git_create() { function _git_create {
local i c=2 name repo flags="-p -d -h" local i c=2 name repo flags="-p -d -h"
while [ $c -lt $cword ]; do while [ $c -lt $cword ]; do
i="${words[c]}" i="${words[c]}"
@ -215,7 +215,7 @@ EOF
} }
# hub fork [--no-remote] # hub fork [--no-remote]
_git_fork() { function _git_fork {
local i c=2 remote=yes local i c=2 remote=yes
while [ $c -lt $cword ]; do while [ $c -lt $cword ]; do
i="${words[c]}" i="${words[c]}"
@ -232,7 +232,7 @@ EOF
} }
# hub pull-request [-f] [-m <MESSAGE>|-F <FILE>|-i <ISSUE>|<ISSUE-URL>] [-b <BASE>] [-h <HEAD>] [-a <USER>] [-M <MILESTONE>] [-l <LABELS>] # hub pull-request [-f] [-m <MESSAGE>|-F <FILE>|-i <ISSUE>|<ISSUE-URL>] [-b <BASE>] [-h <HEAD>] [-a <USER>] [-M <MILESTONE>] [-l <LABELS>]
_git_pull_request() { function _git_pull_request {
local i c=2 flags="-f -m -F -i -b -h -a -M -l" local i c=2 flags="-f -m -F -i -b -h -a -M -l"
while [ $c -lt $cword ]; do while [ $c -lt $cword ]; do
i="${words[c]}" i="${words[c]}"
@ -274,7 +274,7 @@ EOF
# __hub_github_user [HOST] # __hub_github_user [HOST]
# Return $GITHUB_USER or the default github user defined in hub config # Return $GITHUB_USER or the default github user defined in hub config
# 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"
__hub_github_user() { function __hub_github_user {
if [ -n "$GITHUB_USER" ]; then if [ -n "$GITHUB_USER" ]; then
echo $GITHUB_USER echo $GITHUB_USER
return return
@ -312,7 +312,7 @@ EOF
# \o owner # \o owner
# escaped characters (\n, \t ...etc) work # escaped characters (\n, \t ...etc) work
# If omitted, prints all github repos in the format of "remote:owner/repo" # If omitted, prints all github repos in the format of "remote:owner/repo"
__hub_github_repos() { function __hub_github_repos {
local f format=$1 local f format=$1
if [ -z "$(__gitdir)" ]; then if [ -z "$(__gitdir)" ]; then
return return
@ -331,7 +331,7 @@ EOF
# __hub_heads # __hub_heads
# List all local "branch", and remote "owner/repo:branch" # List all local "branch", and remote "owner/repo:branch"
__hub_heads() { function __hub_heads {
local i remote repo branch dir=$(__gitdir) local i remote repo branch dir=$(__gitdir)
if [ -d "$dir" ]; then if [ -d "$dir" ]; then
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
@ -350,7 +350,7 @@ EOF
# __hub_revlist [REMOTE] # __hub_revlist [REMOTE]
# List all tags, and branches under REMOTE, without the "remote/" prefix # List all tags, and branches under REMOTE, without the "remote/" prefix
# REMOTE - Remote name to search branches from. Default is "origin" # REMOTE - Remote name to search branches from. Default is "origin"
__hub_revlist() { function __hub_revlist {
local i remote=${1:-origin} dir=$(__gitdir) local i remote=${1:-origin} dir=$(__gitdir)
if [ -d "$dir" ]; then if [ -d "$dir" ]; then
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \

@ -7,7 +7,7 @@
_serverProfiles(){ function _serverProfiles {
if [[ $COMP_WORDS == *standalone.sh* ]] if [[ $COMP_WORDS == *standalone.sh* ]]
then then
serverdir="../standalone/configuration/" serverdir="../standalone/configuration/"
@ -33,7 +33,7 @@ _serverProfiles(){
fi fi
} }
_bindingAddress(){ function _bindingAddress {
# from /etc/bash_completion.d/ssh # from /etc/bash_completion.d/ssh
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \ COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \
"0.0.0.0 $( PATH="$PATH:/sbin" ifconfig -a | \ "0.0.0.0 $( PATH="$PATH:/sbin" ifconfig -a | \
@ -42,7 +42,7 @@ _bindingAddress(){
-- "$cur" ) ) -- "$cur" ) )
} }
_jboss(){ function _jboss {
local cur prev words cword local cur prev words cword
COMPREPLY=() COMPREPLY=()

@ -1,5 +1,5 @@
#! bash oh-my-bash.module #! bash oh-my-bash.module
_pj() { function _pj {
[ -z "$PROJECT_PATHS" ] && return [ -z "$PROJECT_PATHS" ] && return
shift shift
[ "$1" == "open" ] && shift [ "$1" == "open" ] && shift

@ -3,7 +3,7 @@
export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/} export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/}
_rakecomplete() { function _rakecomplete {
if [ -f Rakefile ]; then if [ -f Rakefile ]; then
recent=`ls -t .rake_tasks~ Rakefile **/*.rake 2> /dev/null | head -n 1` recent=`ls -t .rake_tasks~ Rakefile **/*.rake 2> /dev/null | head -n 1`
if [[ $recent != '.rake_tasks~' ]]; then if [[ $recent != '.rake_tasks~' ]]; then

@ -13,7 +13,7 @@
# TODO: is it ok to use '--timeout 2' ? # TODO: is it ok to use '--timeout 2' ?
_salt_get_grains(){ function _salt_get_grains {
if [ "$1" = 'local' ] ; then if [ "$1" = 'local' ] ; then
salt-call --out=txt -- grains.ls | sed 's/^.*\[//' | tr -d ",']" |sed 's:\([a-z0-9]\) :\1\: :g' salt-call --out=txt -- grains.ls | sed 's/^.*\[//' | tr -d ",']" |sed 's:\([a-z0-9]\) :\1\: :g'
else else
@ -21,7 +21,7 @@ _salt_get_grains(){
fi fi
} }
_salt_get_grain_values(){ function _salt_get_grain_values {
if [ "$1" = 'local' ] ; then if [ "$1" = 'local' ] ; then
salt-call --out=txt -- grains.item $1 |sed 's/^\S*:\s//' |grep -v '^\s*$' salt-call --out=txt -- grains.item $1 |sed 's/^\S*:\s//' |grep -v '^\s*$'
else else
@ -30,7 +30,7 @@ _salt_get_grain_values(){
} }
_salt(){ function _salt {
local cur prev opts pprev ppprev local cur prev opts pprev ppprev
COMPREPLY=() COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
@ -128,7 +128,7 @@ _salt(){
complete -F _salt salt complete -F _salt salt
_saltkey(){ function _saltkey {
local cur prev opts prev pprev local cur prev opts prev pprev
COMPREPLY=() COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
@ -204,7 +204,7 @@ _saltkey(){
complete -F _saltkey salt-key complete -F _saltkey salt-key
_saltcall(){ function _saltcall {
local cur prev opts pprev ppprev local cur prev opts pprev ppprev
COMPREPLY=() COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
@ -257,7 +257,7 @@ _saltcall(){
complete -F _saltcall salt-call complete -F _saltcall salt-call
_saltcp(){ function _saltcp {
local cur prev opts target prefpart postpart helper filt pprev ppprev local cur prev opts target prefpart postpart helper filt pprev ppprev
COMPREPLY=() COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"

@ -40,7 +40,7 @@ _sdkman_complete()
return 0 return 0
} }
_sdkman_candidate_versions(){ function _sdkman_candidate_versions {
CANDIDATE_LOCAL_VERSIONS=$(__sdkman_cleanup_local_versions $1) CANDIDATE_LOCAL_VERSIONS=$(__sdkman_cleanup_local_versions $1)
if [ "$SDKMAN_OFFLINE_MODE" = "true" ]; then if [ "$SDKMAN_OFFLINE_MODE" = "true" ]; then
@ -52,7 +52,7 @@ _sdkman_candidate_versions(){
} }
__sdkman_cleanup_local_versions(){ function __sdkman_cleanup_local_versions {
__sdkman_build_version_csv $1 __sdkman_build_version_csv $1
echo $CSV | tr ',' ' ' echo $CSV | tr ',' ' '

@ -3,7 +3,7 @@
export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/} export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/}
_sshcomplete() { function _sshcomplete {
local CURRENT_PROMPT="${COMP_WORDS[COMP_CWORD]}" local CURRENT_PROMPT="${COMP_WORDS[COMP_CWORD]}"
if [[ ${CURRENT_PROMPT} == *@* ]] ; then if [[ ${CURRENT_PROMPT} == *@* ]] ; then
local OPTIONS="-P ${CURRENT_PROMPT/@*/}@ -- ${CURRENT_PROMPT/*@/}" local OPTIONS="-P ${CURRENT_PROMPT/@*/}@ -- ${CURRENT_PROMPT/*@/}"

@ -1,5 +1,5 @@
#! bash oh-my-bash.module #! bash oh-my-bash.module
__kitchen_instance_list () { function __kitchen_instance_list {
# cache to .kitchen.list.yml # cache to .kitchen.list.yml
if [[ .kitchen.yml -nt .kitchen.list.yml || .kitchen.local.yml -nt .kitchen.list.yml ]]; then if [[ .kitchen.yml -nt .kitchen.list.yml || .kitchen.local.yml -nt .kitchen.list.yml ]]; then
# update list if config has updated # update list if config has updated
@ -8,7 +8,7 @@ __kitchen_instance_list () {
cat .kitchen.list.yml cat .kitchen.list.yml
} }
__kitchen_options () { function __kitchen_options {
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
COMPREPLY=() COMPREPLY=()

@ -57,7 +57,7 @@ function _tmux_complete_window() {
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "${sessions}" -- "${cur}") ) COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "${sessions}" -- "${cur}") )
} }
_tmux() { function _tmux {
local cur prev local cur prev
local i cmd cmd_index option option_index local i cmd cmd_index option option_index
local opts="" local opts=""

@ -23,7 +23,7 @@
# SOFTWARE. # SOFTWARE.
__pwdln() { function __pwdln {
pwdmod="${PWD}/" pwdmod="${PWD}/"
itr=0 itr=0
until [[ -z "$pwdmod" ]];do until [[ -z "$pwdmod" ]];do
@ -33,7 +33,7 @@ __pwdln() {
echo -n $(($itr-1)) echo -n $(($itr-1))
} }
__vagrantinvestigate() { function __vagrantinvestigate {
if [ -f "${PWD}/.vagrant" -o -d "${PWD}/.vagrant" ];then if [ -f "${PWD}/.vagrant" -o -d "${PWD}/.vagrant" ];then
echo "${PWD}/.vagrant" echo "${PWD}/.vagrant"
return 0 return 0
@ -50,7 +50,7 @@ __vagrantinvestigate() {
return 1 return 1
} }
_vagrant() { function _vagrant {
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
commands="snapshot box connect destroy docker-logs docker-run global-status halt help init list-commands login package plugin provision rdp reload resume rsync rsync-auto share ssh ssh-config status suspend up version" commands="snapshot box connect destroy docker-logs docker-run global-status halt help init list-commands login package plugin provision rdp reload resume rsync rsync-auto share ssh ssh-config status suspend up version"

@ -1,10 +1,10 @@
#! bash oh-my-bash.module #! bash oh-my-bash.module
_vboxmanage_realopts() { function _vboxmanage_realopts {
echo $(vboxmanage|grep -i vboxmanage|cut -d' ' -f2|grep '\['|tr -s '[\[\|\]\n' ' ') echo $(vboxmanage|grep -i vboxmanage|cut -d' ' -f2|grep '\['|tr -s '[\[\|\]\n' ' ')
echo " " echo " "
} }
__vboxmanage_startvm() { function __vboxmanage_startvm {
RUNNING=$(vboxmanage list runningvms | cut -d' ' -f1 | tr -d '"') RUNNING=$(vboxmanage list runningvms | cut -d' ' -f1 | tr -d '"')
TOTAL=$(vboxmanage list vms | cut -d' ' -f1 | tr -d '"') TOTAL=$(vboxmanage list vms | cut -d' ' -f1 | tr -d '"')
@ -21,7 +21,7 @@ __vboxmanage_startvm() {
echo $AVAILABLE echo $AVAILABLE
} }
__vboxmanage_list() { function __vboxmanage_list {
INPUT=$(vboxmanage list | tr -s '[\[\]\|\n]' ' ' | cut -d' ' -f4-) INPUT=$(vboxmanage list | tr -s '[\[\]\|\n]' ' ' | cut -d' ' -f4-)
PRUNED="" PRUNED=""
@ -40,7 +40,7 @@ __vboxmanage_list() {
} }
__vboxmanage_list_vms() { function __vboxmanage_list_vms {
VMS="" VMS=""
if [ "x$1" == "x" ]; then if [ "x$1" == "x" ]; then
SEPARATOR=" " SEPARATOR=" "
@ -56,7 +56,7 @@ __vboxmanage_list_vms() {
echo $VMS echo $VMS
} }
__vboxmanage_list_runningvms() { function __vboxmanage_list_runningvms {
VMS="" VMS=""
if [ "$1" == "" ]; then if [ "$1" == "" ]; then
SEPARATOR=" " SEPARATOR=" "
@ -73,7 +73,7 @@ __vboxmanage_list_runningvms() {
} }
__vboxmanage_controlvm() { function __vboxmanage_controlvm {
echo "pause resume reset poweroff savestate acpipowerbutton" echo "pause resume reset poweroff savestate acpipowerbutton"
echo "acpisleepbutton keyboardputscancode guestmemoryballoon" echo "acpisleepbutton keyboardputscancode guestmemoryballoon"
echo "gueststatisticsinterval usbattach usbdetach vrde vrdeport" echo "gueststatisticsinterval usbattach usbdetach vrde vrdeport"
@ -93,7 +93,7 @@ __vboxmanage_controlvm() {
} }
__vboxmanage_default() { function __vboxmanage_default {
realopts=$(_vboxmanage_realopts) realopts=$(_vboxmanage_realopts)
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=""
@ -144,7 +144,7 @@ __vboxmanage_default() {
return 0 return 0
} }
_vboxmanage() { function _vboxmanage {
# vboxmanage | grep -i vboxmanage | cut -d' ' -f2 | sort | uniq # vboxmanage | grep -i vboxmanage | cut -d' ' -f2 | sort | uniq
local cur p1 p2 p3 p4 opts local cur p1 p2 p3 p4 opts
COMPREPLY=() COMPREPLY=()

@ -34,32 +34,32 @@
# mcd: Makes new Dir and jumps inside # mcd: Makes new Dir and jumps inside
# -------------------------------------------------------------------- # --------------------------------------------------------------------
mcd () { mkdir -p -- "$*" ; cd -- "$*" || exit ; } function mcd { mkdir -p -- "$*" ; cd -- "$*" || exit ; }
# mans: Search manpage given in agument '1' for term given in argument '2' (case insensitive) # mans: Search manpage given in agument '1' for term given in argument '2' (case insensitive)
# displays paginated result with colored search terms and two lines surrounding each hit. # displays paginated result with colored search terms and two lines surrounding each hit.
# Example: mans mplayer codec # Example: mans mplayer codec
# -------------------------------------------------------------------- # --------------------------------------------------------------------
mans () { man "$1" | grep -iC2 --color=always "$2" | less ; } function mans { man "$1" | grep -iC2 --color=always "$2" | less ; }
# showa: to remind yourself of an alias (given some part of it) # showa: to remind yourself of an alias (given some part of it)
# ------------------------------------------------------------ # ------------------------------------------------------------
showa () { /usr/bin/grep --color=always -i -a1 "$@" ~/Library/init/bash/aliases.bash | grep -v '^\s*$' | less -FSRXc ; } function showa { /usr/bin/grep --color=always -i -a1 "$@" ~/Library/init/bash/aliases.bash | grep -v '^\s*$' | less -FSRXc ; }
# quiet: mute output of a command # quiet: mute output of a command
# ------------------------------------------------------------ # ------------------------------------------------------------
quiet () { function quiet {
"$*" &> /dev/null & "$*" &> /dev/null &
} }
# lsgrep: search through directory contents with grep # lsgrep: search through directory contents with grep
# ------------------------------------------------------------ # ------------------------------------------------------------
# shellcheck disable=SC2010 # shellcheck disable=SC2010
lsgrep () { ls | grep "$*" ; } function lsgrep { ls | grep "$*" ; }
# banish-cookies: redirect .adobe and .macromedia files to /dev/null # banish-cookies: redirect .adobe and .macromedia files to /dev/null
# ------------------------------------------------------------ # ------------------------------------------------------------
banish-cookies () { function banish-cookies {
rm -r ~/.macromedia ~/.adobe rm -r ~/.macromedia ~/.adobe
ln -s /dev/null ~/.adobe ln -s /dev/null ~/.adobe
ln -s /dev/null ~/.macromedia ln -s /dev/null ~/.macromedia
@ -67,7 +67,7 @@ banish-cookies () {
# show the n most used commands. defaults to 10 # show the n most used commands. defaults to 10
# ------------------------------------------------------------ # ------------------------------------------------------------
hstats() { function hstats {
if [[ $# -lt 1 ]]; then if [[ $# -lt 1 ]]; then
NUM=10 NUM=10
else else
@ -81,11 +81,11 @@ hstats() {
# 2. FILE AND FOLDER MANAGEMENT # 2. FILE AND FOLDER MANAGEMENT
# ------------------------------- # -------------------------------
zipf () { zip -r "$1".zip "$1" ; } # zipf: To create a ZIP archive of a folder function zipf { zip -r "$1".zip "$1" ; } # zipf: To create a ZIP archive of a folder
# extract: Extract most know archives with one command # extract: Extract most know archives with one command
# --------------------------------------------------------- # ---------------------------------------------------------
extract () { function extract {
if [ -f "$1" ] ; then if [ -f "$1" ] ; then
case "$1" in case "$1" in
*.tar.bz2) tar xjf "$1" ;; *.tar.bz2) tar xjf "$1" ;;
@ -108,7 +108,7 @@ extract () {
# buf: back up file with timestamp # buf: back up file with timestamp
# --------------------------------------------------------- # ---------------------------------------------------------
buf () { function buf {
local filename filetime local filename filetime
filename=$1 filename=$1
filetime=$(date +%Y%m%d_%H%M%S) filetime=$(date +%Y%m%d_%H%M%S)
@ -117,13 +117,13 @@ buf () {
# del: move files to hidden folder in tmp, that gets cleared on each reboot # del: move files to hidden folder in tmp, that gets cleared on each reboot
# --------------------------------------------------------- # ---------------------------------------------------------
del() { function del {
mkdir -p /tmp/.trash && mv "$@" /tmp/.trash; mkdir -p /tmp/.trash && mv "$@" /tmp/.trash;
} }
# mkiso: creates iso from current dir in the parent dir (unless defined) # mkiso: creates iso from current dir in the parent dir (unless defined)
# --------------------------------------------------------- # ---------------------------------------------------------
mkiso () { function mkiso {
if _omb_util_command_exists mkisofs; then if _omb_util_command_exists mkisofs; then
if [ -z ${1+x} ]; then if [ -z ${1+x} ]; then
local isoname=${PWD##*/} local isoname=${PWD##*/}
@ -159,12 +159,12 @@ mkiso () {
# 3. SEARCHING # 3. SEARCHING
# --------------------------- # ---------------------------
ff () { /usr/bin/find . -name "$@" ; } # ff: Find file under the current directory function ff { /usr/bin/find . -name "$@" ; } # ff: Find file under the current directory
# shellcheck disable=SC2145 # shellcheck disable=SC2145
ffs () { /usr/bin/find . -name "$@"'*' ; } # ffs: Find file whose name starts with a given string function ffs { /usr/bin/find . -name "$@"'*' ; } # ffs: Find file whose name starts with a given string
# shellcheck disable=SC2145 # shellcheck disable=SC2145
ffe () { /usr/bin/find . -name '*'"$@" ; } # ffe: Find file whose name ends with a given string function ffe { /usr/bin/find . -name '*'"$@" ; } # ffe: Find file whose name ends with a given string
bigfind() { function bigfind {
if [[ $# -lt 1 ]]; then if [[ $# -lt 1 ]]; then
echo_warn "Usage: bigfind DIRECTORY" echo_warn "Usage: bigfind DIRECTORY"
return return
@ -183,11 +183,11 @@ bigfind() {
# E.g. findPid '/d$/' finds pids of all processes with names ending in 'd' # E.g. findPid '/d$/' finds pids of all processes with names ending in 'd'
# Without the 'sudo' it will only find processes of the current user # Without the 'sudo' it will only find processes of the current user
# ----------------------------------------------------- # -----------------------------------------------------
findPid () { lsof -t -c "$@" ; } function findPid { lsof -t -c "$@" ; }
# my_ps: List processes owned by my user: # my_ps: List processes owned by my user:
# ------------------------------------------------------------ # ------------------------------------------------------------
my_ps() { ps "$@" -u "$USER" -o pid,%cpu,%mem,start,time,bsdtime,command ; } function my_ps { ps "$@" -u "$USER" -o pid,%cpu,%mem,start,time,bsdtime,command ; }
# --------------------------- # ---------------------------
@ -196,7 +196,7 @@ my_ps() { ps "$@" -u "$USER" -o pid,%cpu,%mem,start,time,bsdtime,command ; }
# ips: display all ip addresses for this host # ips: display all ip addresses for this host
# ------------------------------------------------------------------- # -------------------------------------------------------------------
ips () { function ips {
if _omb_util_command_exists ifconfig if _omb_util_command_exists ifconfig
then then
ifconfig | awk '/inet /{ print $2 }' ifconfig | awk '/inet /{ print $2 }'
@ -210,20 +210,20 @@ ips () {
# down4me: checks whether a website is down for you, or everybody # down4me: checks whether a website is down for you, or everybody
# ------------------------------------------------------------------- # -------------------------------------------------------------------
down4me () { function down4me {
curl -s "http://www.downforeveryoneorjustme.com/$1" | sed '/just you/!d;s/<[^>]*>//g' curl -s "http://www.downforeveryoneorjustme.com/$1" | sed '/just you/!d;s/<[^>]*>//g'
} }
# myip: displays your ip address, as seen by the Internet # myip: displays your ip address, as seen by the Internet
# ------------------------------------------------------------------- # -------------------------------------------------------------------
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}" echo -e "Your public IP is: ${_omb_term_bold_green} $res ${_omb_term_normal}"
} }
# ii: display useful host related informaton # ii: display useful host related informaton
# ------------------------------------------------------------------- # -------------------------------------------------------------------
ii() { function ii {
echo -e "\\nYou are logged on ${_omb_term_brown}$HOST" echo -e "\\nYou are logged on ${_omb_term_brown}$HOST"
echo -e "\\nAdditionnal information:$NC " ; uname -a echo -e "\\nAdditionnal information:$NC " ; uname -a
echo -e "\\n${_omb_term_brown}Users logged on:$NC " ; w -h echo -e "\\n${_omb_term_brown}Users logged on:$NC " ; w -h
@ -242,7 +242,7 @@ 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
# ------------------------------------------------------------------- # -------------------------------------------------------------------
batch_chmod() { function batch_chmod {
echo -ne "${_omb_term_bold_navy}Applying 0755 permission for all directories..." echo -ne "${_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
@ -256,7 +256,7 @@ batch_chmod() {
# usage: disk usage per directory, in Mac OS X and Linux # usage: disk usage per directory, in Mac OS X and Linux
# ------------------------------------------------------------------- # -------------------------------------------------------------------
usage () { function usage {
if [ "$(uname)" = "Darwin" ]; then if [ "$(uname)" = "Darwin" ]; then
if [ -n "$1" ]; then if [ -n "$1" ]; then
du -hd 1 "$1" du -hd 1 "$1"
@ -274,7 +274,7 @@ usage () {
# pickfrom: picks random line from file # pickfrom: picks random line from file
# ------------------------------------------------------------------- # -------------------------------------------------------------------
pickfrom () { function pickfrom {
local file=$1 local file=$1
[ -z "$file" ] && reference "$FUNCNAME" && return [ -z "$file" ] && reference "$FUNCNAME" && return
length=$(wc -l < "$file") length=$(wc -l < "$file")
@ -290,7 +290,7 @@ pickfrom () {
# shellcheck disable=SC2005 # shellcheck disable=SC2005
# shellcheck disable=SC2034 # shellcheck disable=SC2034
# shellcheck disable=SC2086 # shellcheck disable=SC2086
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=$(echo $(for i in $(eval echo "{1..$length}"); do pickfrom /usr/share/dict/words; done))
echo "With spaces (easier to memorize): $pass" echo "With spaces (easier to memorize): $pass"
@ -307,11 +307,11 @@ passgen () {
# 8. WEB DEVELOPMENT # 8. WEB DEVELOPMENT
# --------------------------------------- # ---------------------------------------
httpHeaders () { /usr/bin/curl -I -L "$@" ; } # httpHeaders: Grabs headers from web page function httpHeaders { /usr/bin/curl -I -L "$@" ; } # httpHeaders: Grabs headers from web page
# httpDebug: Download a web page and show info on what took time # httpDebug: Download a web page and show info on what took time
# ------------------------------------------------------------------- # -------------------------------------------------------------------
httpDebug () { /usr/bin/curl "$@" -o /dev/null -w "dns: %{time_namelookup} connect: %{time_connect} pretransfer: %{time_pretransfer} starttransfer: %{time_starttransfer} total: %{time_total}\\n" ; } function httpDebug { /usr/bin/curl "$@" -o /dev/null -w "dns: %{time_namelookup} connect: %{time_connect} pretransfer: %{time_pretransfer} starttransfer: %{time_starttransfer} total: %{time_total}\\n" ; }

@ -1,7 +1,7 @@
#! bash oh-my-bash.module #! bash oh-my-bash.module
# is x grep argument available? # is x grep argument available?
_omb_grep_flag_available() { function _omb_grep_flag_available {
echo | grep $1 "" >/dev/null 2>&1 echo | grep $1 "" >/dev/null 2>&1
} }

@ -47,7 +47,7 @@
# a help message. # a help message.
# #
# Returns nothing. # Returns nothing.
mo() { function mo {
# This function executes in a subshell so IFS is reset. # This function executes in a subshell so IFS is reset.
# Namespace this variable so we don't conflict with desired values. # Namespace this variable so we don't conflict with desired values.
local moContent f2source files doubleHyphens local moContent f2source files doubleHyphens
@ -120,7 +120,7 @@ mo() {
# $4 - If -z, do standalone tag processing before finishing # $4 - If -z, do standalone tag processing before finishing
# #
# Returns nothing. # Returns nothing.
_moFindEndTag() { function _moFindEndTag {
local content remaining scanned standaloneBytes tag local content remaining scanned standaloneBytes tag
#: Find open tags #: Find open tags
@ -191,7 +191,7 @@ _moFindEndTag() {
# $3 - Needle # $3 - Needle
# #
# Returns nothing. # Returns nothing.
_moFindString() { function _moFindString {
local pos string local pos string
string=${2%%$3*} string=${2%%$3*}
@ -207,7 +207,7 @@ _moFindString() {
# $3 - Desired variable name # $3 - Desired variable name
# #
# Returns nothing. # Returns nothing.
_moFullTagName() { function _moFullTagName {
if [[ -z "${2-}" ]] || [[ "$2" == *.* ]]; then if [[ -z "${2-}" ]] || [[ "$2" == *.* ]]; then
local "$1" && _moIndirect "$1" "$3" local "$1" && _moIndirect "$1" "$3"
else else
@ -223,7 +223,7 @@ _moFullTagName() {
# $2-@ - File names (optional) # $2-@ - File names (optional)
# #
# Returns nothing. # Returns nothing.
_moGetContent() { function _moGetContent {
local content filename target local content filename target
target=$1 target=$1
@ -251,7 +251,7 @@ _moGetContent() {
# $3 - The string to reindent # $3 - The string to reindent
# #
# Returns nothing. # Returns nothing.
_moIndentLines() { function _moIndentLines {
local content fragment len posN posR result trimmed local content fragment len posN posR result trimmed
result="" result=""
@ -315,7 +315,7 @@ _moIndentLines() {
# echo "$dest" # writes "the value" # echo "$dest" # writes "the value"
# #
# Returns nothing. # Returns nothing.
_moIndirect() { function _moIndirect {
unset -v "$1" unset -v "$1"
printf -v "$1" '%s' "$2" printf -v "$1" '%s' "$2"
} }
@ -336,7 +336,7 @@ _moIndirect() {
# echo "${dest[@]}" # writes "one two three" # echo "${dest[@]}" # writes "one two three"
# #
# Returns nothing. # Returns nothing.
_moIndirectArray() { function _moIndirectArray {
unset -v "$1" unset -v "$1"
# IFS must be set to a string containing space or unset in order for # IFS must be set to a string containing space or unset in order for
@ -365,7 +365,7 @@ _moIndirectArray() {
# fi # fi
# #
# Returns 0 if the name is not empty, 1 otherwise. # Returns 0 if the name is not empty, 1 otherwise.
_moIsArray() { function _moIsArray {
# Namespace this variable so we don't conflict with what we're testing. # Namespace this variable so we don't conflict with what we're testing.
local moTestResult local moTestResult
@ -395,7 +395,7 @@ _moIsArray() {
# fi # fi
# #
# Returns 0 if the name is a function, 1 otherwise. # Returns 0 if the name is a function, 1 otherwise.
_moIsFunction() { function _moIsFunction {
local functionList functionName local functionList functionName
functionList=$(declare -F) functionList=$(declare -F)
@ -431,7 +431,7 @@ _moIsFunction() {
# echo "${before:0:${RESULT_ARRAY[0]}}...${after:${RESULT_ARRAY[1]}}" # echo "${before:0:${RESULT_ARRAY[0]}}...${after:${RESULT_ARRAY[1]}}"
# #
# Returns nothing. # Returns nothing.
_moIsStandalone() { function _moIsStandalone {
local afterTrimmed beforeTrimmed char local afterTrimmed beforeTrimmed char
_moTrimChars beforeTrimmed "$2" false true " " $'\t' _moTrimChars beforeTrimmed "$2" false true " " $'\t'
@ -466,7 +466,7 @@ _moIsStandalone() {
# $3-$* - Elements to join # $3-$* - Elements to join
# #
# Returns nothing. # Returns nothing.
_moJoin() { function _moJoin {
local joiner part result target local joiner part result target
target=$1 target=$1
@ -488,7 +488,7 @@ _moJoin() {
# $2 - Filename to load # $2 - Filename to load
# #
# Returns nothing. # Returns nothing.
_moLoadFile() { function _moLoadFile {
local content len local content len
# The subshell removes any trailing newlines. We forcibly add # The subshell removes any trailing newlines. We forcibly add
@ -511,7 +511,7 @@ _moLoadFile() {
# $3-@ - Names to insert into the parsed content # $3-@ - Names to insert into the parsed content
# #
# Returns nothing. # Returns nothing.
_moLoop() { function _moLoop {
local content context contextBase local content context contextBase
content=$1 content=$1
@ -533,7 +533,7 @@ _moLoop() {
# $3 - true when no content before this, false otherwise # $3 - true when no content before this, false otherwise
# #
# Returns nothing. # Returns nothing.
_moParse() { function _moParse {
# Keep naming variables mo* here to not overwrite needed variables # Keep naming variables mo* here to not overwrite needed variables
# used in the string replacements # used in the string replacements
local moBlock moContent moCurrent moIsBeginning moTag local moBlock moContent moCurrent moIsBeginning moTag
@ -669,7 +669,7 @@ _moParse() {
# $6 - Current context name # $6 - Current context name
# #
# Returns nothing. # Returns nothing.
_moPartial() { function _moPartial {
# Namespace variables here to prevent conflicts. # Namespace variables here to prevent conflicts.
local moContent moFilename moIndent moPartial moStandalone local moContent moFilename moIndent moPartial moStandalone
@ -713,7 +713,7 @@ _moPartial() {
# $2 - Current context # $2 - Current context
# #
# Returns nothing. # Returns nothing.
_moShow() { function _moShow {
# Namespace these variables # Namespace these variables
local moJoined moNameParts local moJoined moNameParts
@ -747,7 +747,7 @@ _moShow() {
# $4 - Ending delimiter (optional) # $4 - Ending delimiter (optional)
# #
# Returns nothing. # Returns nothing.
_moSplit() { function _moSplit {
local pos result local pos result
result=( "$2" ) result=( "$2" )
@ -784,7 +784,7 @@ _moSplit() {
# $5 - true/false: is this the beginning of the content? # $5 - true/false: is this the beginning of the content?
# #
# Returns nothing. # Returns nothing.
_moStandaloneAllowed() { function _moStandaloneAllowed {
local bytes local bytes
if _moIsStandalone bytes "$2" "$4" "$5"; then if _moIsStandalone bytes "$2" "$4" "$5"; then
@ -807,7 +807,7 @@ _moStandaloneAllowed() {
# $4 - Content after the tag # $4 - Content after the tag
# #
# Returns nothing. # Returns nothing.
_moStandaloneDenied() { function _moStandaloneDenied {
echo -n "$2" echo -n "$2"
local "$1" && _moIndirect "$1" "$4" local "$1" && _moIndirect "$1" "$4"
} }
@ -827,7 +827,7 @@ _moStandaloneDenied() {
# #
# Returns 0 if the name is not empty, 1 otherwise. When MO_FALSE_IS_EMPTY # Returns 0 if the name is not empty, 1 otherwise. When MO_FALSE_IS_EMPTY
# is set, this returns 1 if the name is "false". # is set, this returns 1 if the name is "false".
_moTest() { function _moTest {
# Test for functions # Test for functions
_moIsFunction "$1" && return 0 _moIsFunction "$1" && return 0
@ -857,7 +857,7 @@ _moTest() {
# $5-@ - Characters to trim # $5-@ - Characters to trim
# #
# Returns nothing. # Returns nothing.
_moTrimChars() { function _moTrimChars {
local back current front last target varName local back current front last target varName
target=$1 target=$1
@ -886,7 +886,7 @@ _moTrimChars() {
# $2 - The string # $2 - The string
# #
# Returns nothing. # Returns nothing.
_moTrimWhitespace() { function _moTrimWhitespace {
local result local result
_moTrimChars result "$2" true true $'\r' $'\n' $'\t' " " _moTrimChars result "$2" true true $'\r' $'\n' $'\t' " "
@ -902,7 +902,7 @@ _moTrimWhitespace() {
# $1 - Filename that has the help message # $1 - Filename that has the help message
# #
# Returns nothing. # Returns nothing.
_moUsage() { function _moUsage {
grep '^#/' "${MO_ORIGINAL_COMMAND}" | cut -c 4- grep '^#/' "${MO_ORIGINAL_COMMAND}" | cut -c 4-
} }

@ -252,17 +252,17 @@ _omb_deprecate_msg_please_use="Please use '$_omb_term_bold_navy%s$_omb_term_rese
# oh-my-bash.sh -- These functions were originally used to find # oh-my-bash.sh -- These functions were originally used to find
# "fpath" directories, which are not supported by Bash. # "fpath" directories, which are not supported by Bash.
is_plugin() { function is_plugin {
local base_dir=$1 name=$2 local base_dir=$1 name=$2
[[ -f $base_dir/plugins/$name/$name.plugin.sh || -f $base_dir/plugins/$name/_$name ]] [[ -f $base_dir/plugins/$name/$name.plugin.sh || -f $base_dir/plugins/$name/_$name ]]
} }
is_completion() { function is_completion {
local base_dir=$1 name=$2 local base_dir=$1 name=$2
[[ -f $base_dir/completions/$name/$name.completion.sh ]] [[ -f $base_dir/completions/$name/$name.completion.sh ]]
} }
is_alias() { function is_alias {
local base_dir=$1 name=$2 local base_dir=$1 name=$2
[[ -f $base_dir/aliases/$name/$name.aliases.sh ]] [[ -f $base_dir/aliases/$name/$name.aliases.sh ]]
} }

@ -12,7 +12,7 @@
# #
# This spinner is used when there is a terminal. # This spinner is used when there is a terminal.
term_spinner() { function term_spinner {
local pid=$! local pid=$!
local delay=0.1 local delay=0.1
local spinstr='|/-\' local spinstr='|/-\'
@ -26,7 +26,7 @@ term_spinner() {
printf " \b\b\b\b" printf " \b\b\b\b"
} }
no_term_spinner() { function no_term_spinner {
local pid=$! local pid=$!
local delay=0.1 local delay=0.1
local spinstr='|/-\' local spinstr='|/-\'
@ -37,7 +37,7 @@ no_term_spinner() {
echo " ✓ " echo " ✓ "
} }
spinner() { function spinner {
if [[ -z "$TERM" ]]; then if [[ -z "$TERM" ]]; then
no_term_spinner no_term_spinner
else else

@ -96,27 +96,27 @@ function _omb_util_defun_print {
# #
if ((_omb_bash_version >= 40000)); then if ((_omb_bash_version >= 40000)); then
_omb_util_command_exists() { function _omb_util_command_exists {
type -t -- "$@" &>/dev/null # bash-4.0 type -t -- "$@" &>/dev/null # bash-4.0
} }
_omb_util_binary_exists() { function _omb_util_binary_exists {
type -P -- "$@" &>/dev/null # bash-4.0 type -P -- "$@" &>/dev/null # bash-4.0
} }
else else
_omb_util_command_exists() { function _omb_util_command_exists {
while (($#)); do while (($#)); do
type -t -- "$1" &>/dev/null || return 1 type -t -- "$1" &>/dev/null || return 1
shift shift
done done
} }
_omb_util_binary_exists() { function _omb_util_binary_exists {
while (($#)); do while (($#)); do
type -P -- "$1" &>/dev/null || return 1 type -P -- "$1" &>/dev/null || return 1
shift shift
done done
} }
fi fi
_omb_util_function_exists() { function _omb_util_function_exists {
declare -F "$@" &>/dev/null # bash-3.2 declare -F "$@" &>/dev/null # bash-3.2
} }
@ -126,7 +126,7 @@ _omb_util_function_exists() {
# Use colors, but only if connected to a terminal, and that terminal # Use colors, but only if connected to a terminal, and that terminal
# supports them. These colors are intended to be used with `echo` # supports them. These colors are intended to be used with `echo`
# #
_omb_term_color_initialize() { function _omb_term_color_initialize {
local name local name
local -a normal_colors=(black brown green olive navy purple teal silver) local -a normal_colors=(black brown green olive navy purple teal silver)
local -a bright_colors=(gray red lime yellow blue magenta cyan white) local -a bright_colors=(gray red lime yellow blue magenta cyan white)
@ -221,14 +221,14 @@ _omb_term_color_initialize
# #
# Headers and Logging # Headers and Logging
# #
_omb_log_header() { printf "\n${_omb_term_bold}${_omb_term_violet}========== %s ==========${_omb_term_reset}\n" "$@"; } function _omb_log_header { printf "\n${_omb_term_bold}${_omb_term_violet}========== %s ==========${_omb_term_reset}\n" "$@"; }
_omb_log_arrow() { printf "➜ %s\n" "$@"; } function _omb_log_arrow { printf "➜ %s\n" "$@"; }
_omb_log_success() { printf "${_omb_term_green}✔ %s${_omb_term_reset}\n" "$@"; } function _omb_log_success { printf "${_omb_term_green}✔ %s${_omb_term_reset}\n" "$@"; }
_omb_log_error() { printf "${_omb_term_brown}✖ %s${_omb_term_reset}\n" "$@"; } function _omb_log_error { printf "${_omb_term_brown}✖ %s${_omb_term_reset}\n" "$@"; }
_omb_log_warning() { printf "${_omb_term_olive}➜ %s${_omb_term_reset}\n" "$@"; } function _omb_log_warning { printf "${_omb_term_olive}➜ %s${_omb_term_reset}\n" "$@"; }
_omb_log_underline() { printf "${_omb_term_underline}${_omb_term_bold}%s${_omb_term_reset}\n" "$@"; } function _omb_log_underline { printf "${_omb_term_underline}${_omb_term_bold}%s${_omb_term_reset}\n" "$@"; }
_omb_log_bold() { printf "${_omb_term_bold}%s${_omb_term_reset}\n" "$@"; } function _omb_log_bold { printf "${_omb_term_bold}%s${_omb_term_reset}\n" "$@"; }
_omb_log_note() { printf "${_omb_term_underline}${_omb_term_bold}${_omb_term_navy}Note:${_omb_term_reset} ${_omb_term_olive}%s${_omb_term_reset}\n" "$@"; } function _omb_log_note { printf "${_omb_term_underline}${_omb_term_bold}${_omb_term_navy}Note:${_omb_term_reset} ${_omb_term_olive}%s${_omb_term_reset}\n" "$@"; }
# #
# USAGE FOR SEEKING CONFIRMATION # USAGE FOR SEEKING CONFIRMATION
@ -241,14 +241,14 @@ _omb_log_note() { printf "${_omb_term_underline}${_omb_term_bold}${_omb_ter
# some other action # some other action
# fi # fi
# #
seek_confirmation() { function seek_confirmation {
printf "\\n${_omb_term_bold}%s${_omb_term_reset}" "$@" printf "\\n${_omb_term_bold}%s${_omb_term_reset}" "$@"
read -p " (y/n) " -n 1 read -p " (y/n) " -n 1
printf "\\n" printf "\\n"
} }
# Test whether the result of an 'ask' is a confirmation # Test whether the result of an 'ask' is a confirmation
is_confirmed() { function is_confirmed {
[[ $REPLY =~ ^[Yy]$ ]] [[ $REPLY =~ ^[Yy]$ ]]
} }
@ -257,7 +257,7 @@ is_confirmed() {
# $1 = OS to test # $1 = OS to test
# Usage: if is_os 'darwin'; then # Usage: if is_os 'darwin'; then
# #
is_os() { function is_os {
[[ $OSTYPE == $1* ]] [[ $OSTYPE == $1* ]]
} }
@ -266,7 +266,7 @@ is_os() {
# Usage: pushover "Title Goes Here" "Message Goes Here" # Usage: pushover "Title Goes Here" "Message Goes Here"
# Credit: http://ryonsherman.blogspot.com/2012/10/shell-script-to-send-pushover.html # Credit: http://ryonsherman.blogspot.com/2012/10/shell-script-to-send-pushover.html
# #
pushover () { function pushover {
PUSHOVERURL="https://api.pushover.net/1/messages.json" PUSHOVERURL="https://api.pushover.net/1/messages.json"
API_KEY=$PUSHOVER_API_KEY API_KEY=$PUSHOVER_API_KEY
USER_KEY=$PUSHOVER_USER_KEY USER_KEY=$PUSHOVER_USER_KEY
@ -286,9 +286,9 @@ pushover () {
## @fn _omb_util_get_shopt optnames... ## @fn _omb_util_get_shopt optnames...
if ((_omb_bash_version >= 40100)); then if ((_omb_bash_version >= 40100)); then
_omb_util_get_shopt() { shopt=$BASHOPTS; } function _omb_util_get_shopt { shopt=$BASHOPTS; }
else else
_omb_util_get_shopt() { function _omb_util_get_shopt {
shopt= shopt=
local opt local opt
for opt; do for opt; do
@ -300,7 +300,7 @@ else
fi fi
_omb_util_unload_hook=() _omb_util_unload_hook=()
_omb_util_unload() { function _omb_util_unload {
local hook local hook
for hook in "${_omb_util_unload_hook[@]}"; do for hook in "${_omb_util_unload_hook[@]}"; do
eval -- "$hook" eval -- "$hook"
@ -311,7 +311,7 @@ _omb_util_original_PS1=$PS1
_omb_util_unload_hook+=('PS1=$_omb_util_original_PS1') _omb_util_unload_hook+=('PS1=$_omb_util_original_PS1')
_omb_util_prompt_command=() _omb_util_prompt_command=()
_omb_util_prompt_command_hook() { function _omb_util_prompt_command_hook {
local status=$? lastarg=$_ hook local status=$? lastarg=$_ hook
for hook in "${_omb_util_prompt_command[@]}"; do for hook in "${_omb_util_prompt_command[@]}"; do
_omb_util_setexit "$status" "$lastarg" _omb_util_setexit "$status" "$lastarg"
@ -323,7 +323,7 @@ _omb_util_prompt_command_hook() {
_omb_util_unload_hook+=('_omb_util_prompt_command=()') _omb_util_unload_hook+=('_omb_util_prompt_command=()')
: "${_omb_util_prompt_command_setup=}" : "${_omb_util_prompt_command_setup=}"
_omb_util_add_prompt_command() { function _omb_util_add_prompt_command {
local other local other
for other in "${_omb_util_prompt_command[@]}"; do for other in "${_omb_util_prompt_command[@]}"; do
[[ $1 == "$other" ]] && return 0 [[ $1 == "$other" ]] && return 0
@ -363,7 +363,7 @@ _omb_util_add_prompt_command() {
fi fi
} }
_omb_util_glob_expand() { function _omb_util_glob_expand {
local set=$- shopt gignore=$GLOBIGNORE local set=$- shopt gignore=$GLOBIGNORE
_omb_util_get_shopt failglob nullglob extglob _omb_util_get_shopt failglob nullglob extglob
@ -389,7 +389,7 @@ _omb_util_glob_expand() {
return 0 return 0
} }
_omb_util_alias() { function _omb_util_alias {
case ${OMB_DEFAULT_ALIASES:-enable} in case ${OMB_DEFAULT_ALIASES:-enable} in
(disable) return 0 ;; (disable) return 0 ;;
(check) alias -- "${1%%=*}" &>/dev/null && return 0 ;; (check) alias -- "${1%%=*}" &>/dev/null && return 0 ;;

@ -49,7 +49,7 @@ if [[ ! ${OSH_CACHE_DIR-} ]]; then
fi fi
_omb_module_loaded= _omb_module_loaded=
_omb_module_require() { function _omb_module_require {
local status=0 local status=0
local -a files=() local -a files=()
while (($#)); do while (($#)); do
@ -95,11 +95,11 @@ _omb_module_require() {
return "$status" return "$status"
} }
_omb_module_require_lib() { _omb_module_require "${@/#/lib:}"; } function _omb_module_require_lib { _omb_module_require "${@/#/lib:}"; }
_omb_module_require_plugin() { _omb_module_require "${@/#/plugin:}"; } function _omb_module_require_plugin { _omb_module_require "${@/#/plugin:}"; }
_omb_module_require_alias() { _omb_module_require "${@/#/alias:}"; } function _omb_module_require_alias { _omb_module_require "${@/#/alias:}"; }
_omb_module_require_completion() { _omb_module_require "${@/#/completion:}"; } function _omb_module_require_completion { _omb_module_require "${@/#/completion:}"; }
_omb_module_require_theme() { _omb_module_require "${@/#/theme:}"; } 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

@ -1,10 +1,10 @@
#! bash oh-my-bash.module #! bash oh-my-bash.module
_omb_plugin_battery__upower_print_info() { function _omb_plugin_battery__upower_print_info {
upower -i "$(upower -e | sed -n '/BAT/{p;q;}')" upower -i "$(upower -e | sed -n '/BAT/{p;q;}')"
} }
ac_adapter_connected(){ function ac_adapter_connected {
if _omb_util_command_exists upower; if _omb_util_command_exists upower;
then then
_omb_plugin_battery__upower_print_info | grep -qE 'state[:[:blank:]]*(charging|fully-charged)' _omb_plugin_battery__upower_print_info | grep -qE 'state[:[:blank:]]*(charging|fully-charged)'
@ -28,7 +28,7 @@ ac_adapter_connected(){
fi fi
} }
ac_adapter_disconnected(){ function ac_adapter_disconnected {
if _omb_util_command_exists upower; if _omb_util_command_exists upower;
then then
_omb_plugin_battery__upower_print_info | grep -qE 'state[:[:blank:]]*discharging' _omb_plugin_battery__upower_print_info | grep -qE 'state[:[:blank:]]*discharging'
@ -55,7 +55,7 @@ ac_adapter_disconnected(){
## @fn battery_percentage ## @fn battery_percentage
## @about 'displays battery charge as a percentage of full (100%)' ## @about 'displays battery charge as a percentage of full (100%)'
## @group 'battery' ## @group 'battery'
battery_percentage(){ function battery_percentage {
if _omb_util_command_exists upower; if _omb_util_command_exists upower;
then 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')
@ -129,7 +129,7 @@ battery_percentage(){
## @fn battery_charge ## @fn battery_charge
## @about 'graphical display of your battery charge' ## @about 'graphical display of your battery charge'
## @group 'battery' ## @group 'battery'
battery_charge(){ function battery_charge {
# Full char # Full char
local F_C='▸' local F_C='▸'
# Depleted char # Depleted char

@ -3,13 +3,13 @@
# Initialize fasd, without setting up the prompt hook, which # Initialize fasd, without setting up the prompt hook, which
# we want to be handled by oh-my-bash. # we want to be handled by oh-my-bash.
_omb_plugin_fasd_prompt_func() { function _omb_plugin_fasd_prompt_func {
local sink=${OMB_PLUGIN_FASD_SINK:-/dev/null} local sink=${OMB_PLUGIN_FASD_SINK:-/dev/null}
[[ $sink == /dev/null ]] && return 0 [[ $sink == /dev/null ]] && return 0
fasd --proc "$(fasd --sanitize "$(history 1 | command sed 's/^[ ]*[0-9]*[ ]*//')")" >> "$sink" 2>&1 fasd --proc "$(fasd --sanitize "$(history 1 | command sed 's/^[ ]*[0-9]*[ ]*//')")" >> "$sink" 2>&1
} }
_omb_plugin_fasd_initialize() { function _omb_plugin_fasd_initialize {
if _omb_util_command_exists fasd; then if _omb_util_command_exists fasd; then
eval -- "$(fasd --init posix-alias bash-ccomp bash-ccomp-install)" eval -- "$(fasd --init posix-alias bash-ccomp bash-ccomp-install)"
_omb_util_add_prompt_command _omb_plugin_fasd_prompt_func _omb_util_add_prompt_command _omb_plugin_fasd_prompt_func

@ -87,7 +87,7 @@ alias gdct='git describe --tags `git rev-list --tags --max-count=1`'
alias gdt='git diff-tree --no-commit-id --name-only -r' alias gdt='git diff-tree --no-commit-id --name-only -r'
alias gdw='git diff --word-diff' alias gdw='git diff --word-diff'
gdv() { function gdv {
git diff -w "$@" | view - git diff -w "$@" | view -
} }
#compdef _git gdv=git-diff #compdef _git gdv=git-diff
@ -96,7 +96,7 @@ alias gf='git fetch'
alias gfa='git fetch --all --prune' alias gfa='git fetch --all --prune'
alias gfo='git fetch origin' alias gfo='git fetch origin'
gfg() { function gfg {
git ls-files | grep "$@" git ls-files | grep "$@"
} }
#compdef _grep gfg #compdef _grep gfg
@ -104,13 +104,13 @@ gfg() {
alias gg='git gui citool' alias gg='git gui citool'
alias gga='git gui citool --amend' alias gga='git gui citool --amend'
ggf() { function ggf {
[[ "$#" != 1 ]] && local b="$(git_current_branch)" [[ "$#" != 1 ]] && local b="$(git_current_branch)"
git push --force origin "${b:=$1}" git push --force origin "${b:=$1}"
} }
#compdef _git ggf=git-checkout #compdef _git ggf=git-checkout
ggl() { function ggl {
if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
git pull origin "${*}" git pull origin "${*}"
else else
@ -120,7 +120,7 @@ ggl() {
} }
#compdef _git ggl=git-checkout #compdef _git ggl=git-checkout
ggp() { function ggp {
if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
git push origin "${*}" git push origin "${*}"
else else
@ -130,7 +130,7 @@ ggp() {
} }
#compdef _git ggp=git-checkout #compdef _git ggp=git-checkout
ggpnp() { function ggpnp {
if [[ "$#" == 0 ]]; then if [[ "$#" == 0 ]]; then
ggl && ggp ggl && ggp
else else
@ -139,7 +139,7 @@ ggpnp() {
} }
#compdef _git ggpnp=git-checkout #compdef _git ggpnp=git-checkout
ggu() { function ggu {
[[ "$#" != 1 ]] && local b="$(git_current_branch)" [[ "$#" != 1 ]] && local b="$(git_current_branch)"
git pull --rebase origin "${b:=$1}" git pull --rebase origin "${b:=$1}"
} }

@ -76,7 +76,7 @@ alias kdd='kubectl describe deployment'
alias kdeld='kubectl delete deployment' alias kdeld='kubectl delete deployment'
alias ksd='kubectl scale deployment' alias ksd='kubectl scale deployment'
alias krsd='kubectl rollout status deployment' alias krsd='kubectl rollout status deployment'
kres(){ function kres {
kubectl set env $@ REFRESHED_AT=$(date +%Y%m%d%H%M%S) kubectl set env $@ REFRESHED_AT=$(date +%Y%m%d%H%M%S)
} }

@ -45,7 +45,7 @@ fi
# SOFTWARE. # SOFTWARE.
# #
if _omb_util_command_exists nvm && [[ ${OMB_PLUGIN_NVM_AUTO_USE-} == true ]]; then if _omb_util_command_exists nvm && [[ ${OMB_PLUGIN_NVM_AUTO_USE-} == true ]]; then
_omb_plugin_nvm_find_up() { function _omb_plugin_nvm_find_up {
local path=$PWD local path=$PWD
while [[ $path && ! -e $path/$1 ]]; do while [[ $path && ! -e $path/$1 ]]; do
path=${path%/*} path=${path%/*}
@ -53,7 +53,7 @@ if _omb_util_command_exists nvm && [[ ${OMB_PLUGIN_NVM_AUTO_USE-} == true ]]; th
echo "$path" echo "$path"
} }
_omb_plugin_nvm_cd(){ function _omb_plugin_nvm_cd {
cd "$@" || return "$?" cd "$@" || return "$?"
local nvm_path=$(_omb_plugin_nvm_find_up .nvmrc) local nvm_path=$(_omb_plugin_nvm_find_up .nvmrc)

@ -15,11 +15,11 @@
# #
# [1] https://github.com/ohmybash/oh-my-bash/pull/332 # [1] https://github.com/ohmybash/oh-my-bash/pull/332
_osh_plugin_tmux_autoattach_exit() { function _osh_plugin_tmux_autoattach_exit {
[ -z "$TMUX" ] && tmux -2u new -As0 && exit [ -z "$TMUX" ] && tmux -2u new -As0 && exit
} }
_osh_plugin_tmux_autoattach_detach() { function _osh_plugin_tmux_autoattach_detach {
[ -z "$TMUX" ] && tmux -2u new -As0 [ -z "$TMUX" ] && tmux -2u new -As0
} }

@ -16,7 +16,7 @@ PROMPT_DIRTRIM=2 # bash4 and above
###################################################################### ######################################################################
DEBUG=0 DEBUG=0
debug() { function debug {
if [[ ${DEBUG} -ne 0 ]]; then if [[ ${DEBUG} -ne 0 ]]; then
>&2 echo -e $* >&2 echo -e $*
fi fi
@ -33,7 +33,7 @@ RIGHT_SEPARATOR=''
LEFT_SUBSEG='' LEFT_SUBSEG=''
RIGHT_SUBSEG='' RIGHT_SUBSEG=''
text_effect() { function text_effect {
case "$1" in case "$1" in
reset) echo 0;; reset) echo 0;;
bold) echo 1;; bold) echo 1;;
@ -44,7 +44,7 @@ text_effect() {
# to add colors, see # to add colors, see
# http://bitmote.com/index.php?post/2012/11/19/Using-ANSI-Color-Codes-to-Colorize-Your-Bash-Prompt-on-Linux # http://bitmote.com/index.php?post/2012/11/19/Using-ANSI-Color-Codes-to-Colorize-Your-Bash-Prompt-on-Linux
# under the "256 (8-bit) Colors" section, and follow the example for orange below # under the "256 (8-bit) Colors" section, and follow the example for orange below
fg_color() { function fg_color {
case "$1" in case "$1" in
black) echo 30;; black) echo 30;;
red) echo 31;; red) echo 31;;
@ -58,7 +58,7 @@ fg_color() {
esac esac
} }
bg_color() { function bg_color {
case "$1" in case "$1" in
black) echo 40;; black) echo 40;;
red) echo 41;; red) echo 41;;
@ -72,7 +72,7 @@ bg_color() {
esac; esac;
} }
ansi() { function ansi {
local seq local seq
local -a mycodes=("${!1}") local -a mycodes=("${!1}")
@ -91,14 +91,14 @@ ansi() {
# PR="$PR\[\033[${seq}m\]" # PR="$PR\[\033[${seq}m\]"
} }
ansi_single() { function ansi_single {
echo -ne '\[\033['$1'm\]' echo -ne '\[\033['$1'm\]'
} }
# Begin a segment # Begin a segment
# Takes two arguments, background and foreground. Both can be omitted, # Takes two arguments, background and foreground. Both can be omitted,
# rendering default background/foreground. # rendering default background/foreground.
prompt_segment() { function prompt_segment {
local bg fg local bg fg
local -a codes local -a codes
@ -140,7 +140,7 @@ prompt_segment() {
} }
# End the prompt, closing any open segments # End the prompt, closing any open segments
prompt_end() { function prompt_end {
if [[ -n $CURRENT_BG ]]; then if [[ -n $CURRENT_BG ]]; then
local -a codes=($(text_effect reset) $(fg_color $CURRENT_BG)) local -a codes=($(text_effect reset) $(fg_color $CURRENT_BG))
PR="$PR $(ansi codes[@])$SEGMENT_SEPARATOR" PR="$PR $(ansi codes[@])$SEGMENT_SEPARATOR"
@ -151,7 +151,7 @@ prompt_end() {
} }
### virtualenv prompt ### virtualenv prompt
prompt_virtualenv() { function prompt_virtualenv {
if [[ -n $VIRTUAL_ENV ]]; then if [[ -n $VIRTUAL_ENV ]]; then
# Python could output the version information in both stdout and # Python could output the version information in both stdout and
# stderr (e.g. if using pyenv, the output goes to stderr). # stderr (e.g. if using pyenv, the output goes to stderr).
@ -171,7 +171,7 @@ prompt_virtualenv() {
# Each component will draw itself, and hide itself if no information needs to be shown # Each component will draw itself, and hide itself if no information needs to be shown
# Context: user@hostname (who am I and where am I) # Context: user@hostname (who am I and where am I)
prompt_context() { function prompt_context {
local user=`whoami` local user=`whoami`
if [[ $user != $DEFAULT_USER || -n $SSH_CLIENT ]]; then if [[ $user != $DEFAULT_USER || -n $SSH_CLIENT ]]; then
@ -181,18 +181,18 @@ prompt_context() {
# prints history followed by HH:MM, useful for remembering what # prints history followed by HH:MM, useful for remembering what
# we did previously # we did previously
prompt_histdt() { function prompt_histdt {
prompt_segment black default "\!" # \A" prompt_segment black default "\!" # \A"
} }
git_status_dirty() { function git_status_dirty {
dirty=$(git status -s 2> /dev/null | tail -n 1) dirty=$(git status -s 2> /dev/null | tail -n 1)
[[ -n $dirty ]] && echo " ●" [[ -n $dirty ]] && echo " ●"
} }
# Git: branch/detached head, dirty status # Git: branch/detached head, dirty status
prompt_git() { function prompt_git {
local ref dirty local ref dirty
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
ZSH_THEME_GIT_PROMPT_DIRTY='±' ZSH_THEME_GIT_PROMPT_DIRTY='±'
@ -208,7 +208,7 @@ prompt_git() {
} }
# Dir: current working directory # Dir: current working directory
prompt_dir() { function prompt_dir {
prompt_segment blue black '\W' prompt_segment blue black '\W'
} }
@ -216,7 +216,7 @@ prompt_dir() {
# - was there an error # - was there an error
# - am I root # - am I root
# - are there background jobs? # - are there background jobs?
prompt_status() { function prompt_status {
local symbols local symbols
symbols=() symbols=()
[[ $RETVAL -ne 0 ]] && symbols+="$(ansi_single $(fg_color red))" [[ $RETVAL -ne 0 ]] && symbols+="$(ansi_single $(fg_color red))"
@ -232,12 +232,12 @@ prompt_status() {
# requires setting prompt_foo to use PRIGHT vs PR # requires setting prompt_foo to use PRIGHT vs PR
# doesn't quite work per above # doesn't quite work per above
rightprompt() { function rightprompt {
printf "%*s" $COLUMNS "$PRIGHT" printf "%*s" $COLUMNS "$PRIGHT"
} }
# quick right prompt I grabbed to test things. # quick right prompt I grabbed to test things.
__command_rprompt() { function __command_rprompt {
local times= n=$COLUMNS tz local times= n=$COLUMNS tz
for tz in ZRH:Europe/Zurich PIT:US/Eastern \ for tz in ZRH:Europe/Zurich PIT:US/Eastern \
MTV:US/Pacific TOK:Asia/Tokyo; do MTV:US/Pacific TOK:Asia/Tokyo; do
@ -251,7 +251,7 @@ __command_rprompt() {
# PROMPT_COMMAND=__command_rprompt # PROMPT_COMMAND=__command_rprompt
# this doens't wrap code in \[ \] # this doens't wrap code in \[ \]
ansi_r() { function ansi_r {
local seq local seq
local -a mycodes2=("${!1}") local -a mycodes2=("${!1}")
@ -273,7 +273,7 @@ ansi_r() {
# Begin a segment on the right # Begin a segment on the right
# Takes two arguments, background and foreground. Both can be omitted, # Takes two arguments, background and foreground. Both can be omitted,
# rendering default background/foreground. # rendering default background/foreground.
prompt_right_segment() { function prompt_right_segment {
local bg fg local bg fg
local -a codes local -a codes
@ -336,7 +336,7 @@ prompt_right_segment() {
# (add-hook 'comint-preoutput-filter-functions # (add-hook 'comint-preoutput-filter-functions
# 'dirtrack-filter-out-pwd-prompt t t))) # 'dirtrack-filter-out-pwd-prompt t t)))
prompt_emacsdir() { function prompt_emacsdir {
# no color or other setting... this will be deleted per above # no color or other setting... this will be deleted per above
PR="DIR \w DIR$PR" PR="DIR \w DIR$PR"
} }
@ -344,7 +344,7 @@ prompt_emacsdir() {
###################################################################### ######################################################################
## Main prompt ## Main prompt
build_prompt() { function build_prompt {
[[ ! -z ${AG_EMACS_DIR+x} ]] && prompt_emacsdir [[ ! -z ${AG_EMACS_DIR+x} ]] && prompt_emacsdir
prompt_status prompt_status
[[ -z ${AG_NO_HIST+x} ]] && prompt_histdt [[ -z ${AG_NO_HIST+x} ]] && prompt_histdt
@ -360,7 +360,7 @@ build_prompt() {
# this doesn't work... new model: create a prompt via a PR variable and # this doesn't work... new model: create a prompt via a PR variable and
# use that. # use that.
_omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND {
local RETVAL=$? local RETVAL=$?
local PR="" local PR=""
local PRIGHT="" local PRIGHT=""

@ -69,7 +69,7 @@ PROMPT_DIRTRIM=2 # bash4 and above
###################################################################### ######################################################################
DEBUG=0 DEBUG=0
debug() { function debug {
if [[ ${DEBUG} -ne 0 ]]; then if [[ ${DEBUG} -ne 0 ]]; then
>&2 echo -e $* >&2 echo -e $*
fi fi
@ -86,7 +86,7 @@ RIGHT_SEPARATOR=''
LEFT_SUBSEG='' LEFT_SUBSEG=''
RIGHT_SUBSEG='' RIGHT_SUBSEG=''
text_effect() { function text_effect {
case "$1" in case "$1" in
reset) echo 0;; reset) echo 0;;
bold) echo 1;; bold) echo 1;;
@ -97,7 +97,7 @@ text_effect() {
# to add colors, see # to add colors, see
# http://bitmote.com/index.php?post/2012/11/19/Using-ANSI-Color-Codes-to-Colorize-Your-Bash-Prompt-on-Linux # http://bitmote.com/index.php?post/2012/11/19/Using-ANSI-Color-Codes-to-Colorize-Your-Bash-Prompt-on-Linux
# under the "256 (8-bit) Colors" section, and follow the example for orange below # under the "256 (8-bit) Colors" section, and follow the example for orange below
fg_color() { function fg_color {
case "$1" in case "$1" in
black) echo 30;; black) echo 30;;
red) echo 31;; red) echo 31;;
@ -111,7 +111,7 @@ fg_color() {
esac esac
} }
bg_color() { function bg_color {
case "$1" in case "$1" in
black) echo 40;; black) echo 40;;
red) echo 41;; red) echo 41;;
@ -128,7 +128,7 @@ bg_color() {
# TIL: declare is global not local, so best use a different name # TIL: declare is global not local, so best use a different name
# for codes (mycodes) as otherwise it'll clobber the original. # for codes (mycodes) as otherwise it'll clobber the original.
# this changes from BASH v3 to BASH v4. # this changes from BASH v3 to BASH v4.
ansi() { function ansi {
local seq local seq
declare -a mycodes=("${!1}") declare -a mycodes=("${!1}")
@ -146,14 +146,14 @@ ansi() {
# PR="$PR\[\033[${seq}m\]" # PR="$PR\[\033[${seq}m\]"
} }
ansi_single() { function ansi_single {
echo -ne '\[\033['$1'm\]' echo -ne '\[\033['$1'm\]'
} }
# Begin a segment # Begin a segment
# Takes two arguments, background and foreground. Both can be omitted, # Takes two arguments, background and foreground. Both can be omitted,
# rendering default background/foreground. # rendering default background/foreground.
prompt_segment() { function prompt_segment {
local bg fg local bg fg
declare -a codes declare -a codes
@ -195,7 +195,7 @@ prompt_segment() {
} }
# End the prompt, closing any open segments # End the prompt, closing any open segments
prompt_end() { function prompt_end {
if [[ -n $CURRENT_BG ]]; then if [[ -n $CURRENT_BG ]]; then
declare -a codes=($(text_effect reset) $(fg_color $CURRENT_BG)) declare -a codes=($(text_effect reset) $(fg_color $CURRENT_BG))
PR="$PR $(ansi codes[@])$SEGMENT_SEPARATOR" PR="$PR $(ansi codes[@])$SEGMENT_SEPARATOR"
@ -206,7 +206,7 @@ prompt_end() {
} }
### virtualenv prompt ### virtualenv prompt
prompt_virtualenv() { function prompt_virtualenv {
if [[ -n $VIRTUAL_ENV ]]; then if [[ -n $VIRTUAL_ENV ]]; then
# Python could output the version information in both stdout and # Python could output the version information in both stdout and
# stderr (e.g. if using pyenv, the output goes to stderr). # stderr (e.g. if using pyenv, the output goes to stderr).
@ -226,7 +226,7 @@ prompt_virtualenv() {
# Each component will draw itself, and hide itself if no information needs to be shown # Each component will draw itself, and hide itself if no information needs to be shown
# Context: user@hostname (who am I and where am I) # Context: user@hostname (who am I and where am I)
prompt_context() { function prompt_context {
local user=$(whoami) local user=$(whoami)
if [[ $user != $DEFAULT_USER || -n $SSH_CLIENT ]]; then if [[ $user != $DEFAULT_USER || -n $SSH_CLIENT ]]; then
@ -236,18 +236,18 @@ prompt_context() {
# prints history followed by HH:MM, useful for remembering what # prints history followed by HH:MM, useful for remembering what
# we did previously # we did previously
prompt_histdt() { function prompt_histdt {
prompt_segment black default "\! [\A]" prompt_segment black default "\! [\A]"
} }
git_status_dirty() { function git_status_dirty {
dirty=$(git status -s 2> /dev/null | tail -n 1) dirty=$(git status -s 2> /dev/null | tail -n 1)
[[ -n $dirty ]] && echo " ●" [[ -n $dirty ]] && echo " ●"
} }
# Git: branch/detached head, dirty status # Git: branch/detached head, dirty status
prompt_git() { function prompt_git {
local ref dirty local ref dirty
if git rev-parse --is-inside-work-tree &>/dev/null; then if git rev-parse --is-inside-work-tree &>/dev/null; then
ZSH_THEME_GIT_PROMPT_DIRTY='±' ZSH_THEME_GIT_PROMPT_DIRTY='±'
@ -263,7 +263,7 @@ prompt_git() {
} }
# Dir: current working directory # Dir: current working directory
prompt_dir() { function prompt_dir {
prompt_segment blue black '\w' prompt_segment blue black '\w'
} }
@ -271,7 +271,7 @@ prompt_dir() {
# - was there an error # - was there an error
# - am I root # - am I root
# - are there background jobs? # - are there background jobs?
prompt_status() { function prompt_status {
local symbols local symbols
symbols=() symbols=()
[[ $RETVAL -ne 0 ]] && symbols+="$(ansi_single $(fg_color red))" [[ $RETVAL -ne 0 ]] && symbols+="$(ansi_single $(fg_color red))"
@ -287,12 +287,12 @@ prompt_status() {
# requires setting prompt_foo to use PRIGHT vs PR # requires setting prompt_foo to use PRIGHT vs PR
# doesn't quite work per above # doesn't quite work per above
rightprompt() { function rightprompt {
printf "%*s" $COLUMNS "$PRIGHT" printf "%*s" $COLUMNS "$PRIGHT"
} }
# quick right prompt I grabbed to test things. # quick right prompt I grabbed to test things.
__command_rprompt() { function __command_rprompt {
local times= n=$COLUMNS tz local times= n=$COLUMNS tz
for tz in ZRH:Europe/Zurich PIT:US/Eastern \ for tz in ZRH:Europe/Zurich PIT:US/Eastern \
MTV:US/Pacific TOK:Asia/Tokyo; do MTV:US/Pacific TOK:Asia/Tokyo; do
@ -306,7 +306,7 @@ __command_rprompt() {
# _omb_util_add_prompt_command __command_rprompt # _omb_util_add_prompt_command __command_rprompt
# this doens't wrap code in \[ \] # this doens't wrap code in \[ \]
ansi_r() { function ansi_r {
local seq local seq
declare -a mycodes2=("${!1}") declare -a mycodes2=("${!1}")
@ -327,7 +327,7 @@ ansi_r() {
# Begin a segment on the right # Begin a segment on the right
# Takes two arguments, background and foreground. Both can be omitted, # Takes two arguments, background and foreground. Both can be omitted,
# rendering default background/foreground. # rendering default background/foreground.
prompt_right_segment() { function prompt_right_segment {
local bg fg local bg fg
declare -a codes declare -a codes
@ -390,7 +390,7 @@ prompt_right_segment() {
# (add-hook 'comint-preoutput-filter-functions # (add-hook 'comint-preoutput-filter-functions
# 'dirtrack-filter-out-pwd-prompt t t))) # 'dirtrack-filter-out-pwd-prompt t t)))
prompt_emacsdir() { function prompt_emacsdir {
# no color or other setting... this will be deleted per above # no color or other setting... this will be deleted per above
PR="DIR \w DIR$PR" PR="DIR \w DIR$PR"
} }
@ -398,7 +398,7 @@ prompt_emacsdir() {
###################################################################### ######################################################################
## Main prompt ## Main prompt
build_prompt() { function build_prompt {
[[ ! -z ${AG_EMACS_DIR+x} ]] && prompt_emacsdir [[ ! -z ${AG_EMACS_DIR+x} ]] && prompt_emacsdir
prompt_status prompt_status
#[[ -z ${AG_NO_HIST+x} ]] && prompt_histdt #[[ -z ${AG_NO_HIST+x} ]] && prompt_histdt
@ -414,7 +414,7 @@ build_prompt() {
# this doesn't work... new model: create a prompt via a PR variable and # this doesn't work... new model: create a prompt via a PR variable and
# use that. # use that.
_omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND {
RETVAL=$? RETVAL=$?
PR="" PR=""
PRIGHT="" PRIGHT=""

@ -38,7 +38,7 @@ function set_user_color() {
esac esac
} }
scm_prompt() { function scm_prompt {
CHAR=$(scm_char) CHAR=$(scm_char)
if [ $CHAR = $SCM_NONE_CHAR ] if [ $CHAR = $SCM_NONE_CHAR ]
then then
@ -62,7 +62,7 @@ function set_custom_colors() {
powder_blue="\[$(tput setaf 153)\]" powder_blue="\[$(tput setaf 153)\]"
} }
__ps_time() { function __ps_time {
echo "$(clock_prompt)${_omb_prompt_normal}\n" echo "$(clock_prompt)${_omb_prompt_normal}\n"
} }

@ -13,7 +13,7 @@ GIT_THEME_PROMPT_SUFFIX="${_omb_prompt_green}|"
RVM_THEME_PROMPT_PREFIX="|" RVM_THEME_PROMPT_PREFIX="|"
RVM_THEME_PROMPT_SUFFIX="|" RVM_THEME_PROMPT_SUFFIX="|"
__bobby_clock() { function __bobby_clock {
printf "$(clock_prompt) " printf "$(clock_prompt) "
if [ "${THEME_SHOW_CLOCK_CHAR}" == "true" ]; then if [ "${THEME_SHOW_CLOCK_CHAR}" == "true" ]; then

@ -7,7 +7,7 @@
## Parsers ## ## Parsers ##
############# #############
____brainy_top_left_parse() { function ____brainy_top_left_parse {
ifs_old="${IFS}" ifs_old="${IFS}"
IFS="|" IFS="|"
args=( $1 ) args=( $1 )
@ -22,7 +22,7 @@ ____brainy_top_left_parse() {
_TOP_LEFT+=" " _TOP_LEFT+=" "
} }
____brainy_top_right_parse() { function ____brainy_top_right_parse {
ifs_old="${IFS}" ifs_old="${IFS}"
IFS="|" IFS="|"
args=( $1 ) args=( $1 )
@ -39,7 +39,7 @@ ____brainy_top_right_parse() {
(( __SEG_AT_RIGHT += 1 )) (( __SEG_AT_RIGHT += 1 ))
} }
____brainy_bottom_parse() { function ____brainy_bottom_parse {
ifs_old="${IFS}" ifs_old="${IFS}"
IFS="|" IFS="|"
args=( $1 ) args=( $1 )
@ -48,7 +48,7 @@ ____brainy_bottom_parse() {
[ ${#args[1]} -gt 0 ] && _BOTTOM+=" " [ ${#args[1]} -gt 0 ] && _BOTTOM+=" "
} }
____brainy_top() { function ____brainy_top {
_TOP_LEFT="" _TOP_LEFT=""
_TOP_RIGHT="" _TOP_RIGHT=""
__TOP_RIGHT_LEN=0 __TOP_RIGHT_LEN=0
@ -74,7 +74,7 @@ ____brainy_top() {
printf "%s%s" "${_TOP_LEFT}" "${_TOP_RIGHT}" printf "%s%s" "${_TOP_LEFT}" "${_TOP_RIGHT}"
} }
____brainy_bottom() { function ____brainy_bottom {
_BOTTOM="" _BOTTOM=""
for seg in $___BRAINY_BOTTOM; do for seg in $___BRAINY_BOTTOM; do
info="$(___brainy_prompt_"${seg}")" info="$(___brainy_prompt_"${seg}")"
@ -87,7 +87,7 @@ ____brainy_bottom() {
## Segments ## ## Segments ##
############## ##############
___brainy_prompt_user_info() { function ___brainy_prompt_user_info {
color=$_omb_prompt_bold_navy color=$_omb_prompt_bold_navy
if [ "${THEME_SHOW_SUDO}" == "true" ]; then if [ "${THEME_SHOW_SUDO}" == "true" ]; then
if [ $(sudo -n id -u 2>&1 | grep 0) ]; then if [ $(sudo -n id -u 2>&1 | grep 0) ]; then
@ -103,14 +103,14 @@ ___brainy_prompt_user_info() {
fi fi
} }
___brainy_prompt_dir() { function ___brainy_prompt_dir {
color=$_omb_prompt_bold_olive color=$_omb_prompt_bold_olive
box="[|]" box="[|]"
info="\w" info="\w"
printf "%s|%s|%s|%s" "${color}" "${info}" "${_omb_prompt_bold_white}" "${box}" printf "%s|%s|%s|%s" "${color}" "${info}" "${_omb_prompt_bold_white}" "${box}"
} }
___brainy_prompt_scm() { function ___brainy_prompt_scm {
[ "${THEME_SHOW_SCM}" != "true" ] && return [ "${THEME_SHOW_SCM}" != "true" ] && return
color=$_omb_prompt_bold_green color=$_omb_prompt_bold_green
box="$(scm_char) " box="$(scm_char) "
@ -118,7 +118,7 @@ ___brainy_prompt_scm() {
printf "%s|%s|%s|%s" "${color}" "${info}" "${_omb_prompt_bold_white}" "${box}" printf "%s|%s|%s|%s" "${color}" "${info}" "${_omb_prompt_bold_white}" "${box}"
} }
___brainy_prompt_python() { function ___brainy_prompt_python {
[ "${THEME_SHOW_PYTHON}" != "true" ] && return [ "${THEME_SHOW_PYTHON}" != "true" ] && return
color=$_omb_prompt_bold_olive color=$_omb_prompt_bold_olive
box="[|]" box="[|]"
@ -126,7 +126,7 @@ ___brainy_prompt_python() {
printf "%s|%s|%s|%s" "${color}" "${info}" "${_omb_prompt_bold_navy}" "${box}" printf "%s|%s|%s|%s" "${color}" "${info}" "${_omb_prompt_bold_navy}" "${box}"
} }
___brainy_prompt_ruby() { function ___brainy_prompt_ruby {
[ "${THEME_SHOW_RUBY}" != "true" ] && return [ "${THEME_SHOW_RUBY}" != "true" ] && return
color=$_omb_prompt_bold_white color=$_omb_prompt_bold_white
box="[|]" box="[|]"
@ -134,7 +134,7 @@ ___brainy_prompt_ruby() {
printf "%s|%s|%s|%s" "${color}" "${info}" "${_omb_prompt_bold_brown}" "${box}" printf "%s|%s|%s|%s" "${color}" "${info}" "${_omb_prompt_bold_brown}" "${box}"
} }
___brainy_prompt_todo() { function ___brainy_prompt_todo {
[ "${THEME_SHOW_TODO}" != "true" ] && return [ "${THEME_SHOW_TODO}" != "true" ] && return
_omb_util_binary_exists todo.sh || return _omb_util_binary_exists todo.sh || return
color=$_omb_prompt_bold_white color=$_omb_prompt_bold_white
@ -143,7 +143,7 @@ ___brainy_prompt_todo() {
printf "%s|%s|%s|%s" "${color}" "${info}" "${_omb_prompt_bold_green}" "${box}" printf "%s|%s|%s|%s" "${color}" "${info}" "${_omb_prompt_bold_green}" "${box}"
} }
___brainy_prompt_clock() { function ___brainy_prompt_clock {
[ "${THEME_SHOW_CLOCK}" != "true" ] && return [ "${THEME_SHOW_CLOCK}" != "true" ] && return
color=$THEME_CLOCK_COLOR color=$THEME_CLOCK_COLOR
box="[|]" box="[|]"
@ -151,7 +151,7 @@ ___brainy_prompt_clock() {
printf "%s|%s|%s|%s" "${color}" "${info}" "${_omb_prompt_bold_purple}" "${box}" printf "%s|%s|%s|%s" "${color}" "${info}" "${_omb_prompt_bold_purple}" "${box}"
} }
___brainy_prompt_battery() { function ___brainy_prompt_battery {
[ ! -e "$OSH/plugins/battery/battery.plugin.sh" ] || [ ! -e "$OSH/plugins/battery/battery.plugin.sh" ] ||
[ "${THEME_SHOW_BATTERY}" != "true" ] && return [ "${THEME_SHOW_BATTERY}" != "true" ] && return
info=$(battery_percentage) info=$(battery_percentage)
@ -167,13 +167,13 @@ ___brainy_prompt_battery() {
printf "%s|%s|%s|%s" "${color}" "${info}" "${_omb_prompt_bold_white}" "${box}" printf "%s|%s|%s|%s" "${color}" "${info}" "${_omb_prompt_bold_white}" "${box}"
} }
___brainy_prompt_exitcode() { function ___brainy_prompt_exitcode {
[ "${THEME_SHOW_EXITCODE}" != "true" ] && return [ "${THEME_SHOW_EXITCODE}" != "true" ] && return
color=$_omb_prompt_bold_purple color=$_omb_prompt_bold_purple
[ "$exitcode" -ne 0 ] && printf "%s|%s" "${color}" "${exitcode}" [ "$exitcode" -ne 0 ] && printf "%s|%s" "${color}" "${exitcode}"
} }
___brainy_prompt_char() { function ___brainy_prompt_char {
color=$_omb_prompt_bold_white color=$_omb_prompt_bold_white
prompt_char="${__BRAINY_PROMPT_CHAR_PS1}" prompt_char="${__BRAINY_PROMPT_CHAR_PS1}"
printf "%s|%s" "${color}" "${prompt_char}" printf "%s|%s" "${color}" "${prompt_char}"
@ -183,19 +183,19 @@ ___brainy_prompt_char() {
## cli ## ## cli ##
######### #########
__brainy_show() { function __brainy_show {
typeset _seg=${1:-} typeset _seg=${1:-}
shift shift
export THEME_SHOW_${_seg}=true export THEME_SHOW_${_seg}=true
} }
__brainy_hide() { function __brainy_hide {
typeset _seg=${1:-} typeset _seg=${1:-}
shift shift
export THEME_SHOW_${_seg}=false export THEME_SHOW_${_seg}=false
} }
_brainy_completion() { function _brainy_completion {
local cur _action actions segments local cur _action actions segments
COMPREPLY=() COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
@ -217,7 +217,7 @@ _brainy_completion() {
return 0 return 0
} }
brainy() { function brainy {
typeset action=${1:-} typeset action=${1:-}
shift shift
typeset segs=${*:-} typeset segs=${*:-}
@ -276,16 +276,16 @@ ___BRAINY_BOTTOM=${___BRAINY_BOTTOM:-"exitcode char"}
## Prompt ## ## Prompt ##
############ ############
__brainy_ps1() { function __brainy_ps1 {
printf "%s%s%s" "$(____brainy_top)" "$(____brainy_bottom)" "${_omb_prompt_normal}" printf "%s%s%s" "$(____brainy_top)" "$(____brainy_bottom)" "${_omb_prompt_normal}"
} }
__brainy_ps2() { function __brainy_ps2 {
color=$_omb_prompt_bold_white color=$_omb_prompt_bold_white
printf "%s%s%s" "${color}" "${__BRAINY_PROMPT_CHAR_PS2} " "${_omb_prompt_normal}" printf "%s%s%s" "${color}" "${__BRAINY_PROMPT_CHAR_PS2} " "${_omb_prompt_normal}"
} }
_omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND {
exitcode="$?" exitcode="$?"
PS1="$(__brainy_ps1)" PS1="$(__brainy_ps1)"

@ -9,14 +9,14 @@ SCM_GIT_CHAR="${_omb_prompt_bold_green}±${_omb_prompt_normal}"
SCM_SVN_CHAR="${_omb_prompt_bold_teal}${_omb_prompt_normal}" SCM_SVN_CHAR="${_omb_prompt_bold_teal}${_omb_prompt_normal}"
SCM_HG_CHAR="${_omb_prompt_bold_brown}${_omb_prompt_normal}" SCM_HG_CHAR="${_omb_prompt_bold_brown}${_omb_prompt_normal}"
is_vim_shell() { function is_vim_shell {
if [ ! -z "$VIMRUNTIME" ] if [ ! -z "$VIMRUNTIME" ]
then then
echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]" echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]"
fi fi
} }
scm_prompt() { function scm_prompt {
CHAR=$(scm_char) CHAR=$(scm_char)
if [ $CHAR = $SCM_NONE_CHAR ] if [ $CHAR = $SCM_NONE_CHAR ]
then then
@ -26,7 +26,7 @@ scm_prompt() {
fi fi
} }
_omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND {
PS1="${_omb_prompt_white}${_omb_prompt_background_navy} \u${_omb_prompt_normal}" PS1="${_omb_prompt_white}${_omb_prompt_background_navy} \u${_omb_prompt_normal}"
PS1+="${_omb_prompt_background_navy}@${_omb_prompt_brown}${_omb_prompt_background_navy}\h $(clock_prompt) ${_omb_prompt_reset_color}" PS1+="${_omb_prompt_background_navy}@${_omb_prompt_brown}${_omb_prompt_background_navy}\h $(clock_prompt) ${_omb_prompt_reset_color}"
PS1+="${_omb_prompt_normal} $(battery_charge)\n" PS1+="${_omb_prompt_normal} $(battery_charge)\n"

@ -55,7 +55,7 @@ case $TERM in
;; ;;
esac esac
is_vim_shell() { function is_vim_shell {
if [ ! -z "$VIMRUNTIME" ]; if [ ! -z "$VIMRUNTIME" ];
then then
echo "${D_INTERMEDIATE_COLOR}on ${D_VIMSHELL_COLOR}\ echo "${D_INTERMEDIATE_COLOR}on ${D_VIMSHELL_COLOR}\
@ -63,7 +63,7 @@ vim shell${D_DEFAULT_COLOR} "
fi fi
} }
mitsuhikos_lastcommandfailed() { function mitsuhikos_lastcommandfailed {
code=$? code=$?
if [ $code != 0 ]; if [ $code != 0 ];
then then
@ -73,7 +73,7 @@ $code ${D_DEFAULT_COLOR}"
} }
# vcprompt for scm instead of oh-my-bash default # vcprompt for scm instead of oh-my-bash default
demula_vcprompt() { function demula_vcprompt {
if [ ! -z "$VCPROMPT_EXECUTABLE" ]; if [ ! -z "$VCPROMPT_EXECUTABLE" ];
then then
local D_VCPROMPT_FORMAT="on ${D_SCM_COLOR}%s${D_INTERMEDIATE_COLOR}:\ local D_VCPROMPT_FORMAT="on ${D_SCM_COLOR}%s${D_INTERMEDIATE_COLOR}:\
@ -83,7 +83,7 @@ ${D_BRANCH_COLOR}%b %r ${D_CHANGES_COLOR}%m%u ${D_DEFAULT_COLOR}"
} }
# checks if the plugin is installed before calling battery_charge # checks if the plugin is installed before calling battery_charge
safe_battery_charge() { function safe_battery_charge {
if [ -e "${OSH}/plugins/battery/battery.plugin.sh" ]; if [ -e "${OSH}/plugins/battery/battery.plugin.sh" ];
then then
battery_charge battery_charge
@ -91,7 +91,7 @@ safe_battery_charge() {
} }
# -------------------------------------------------------------- PROMPT OUTPUT # -------------------------------------------------------------- PROMPT OUTPUT
_omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND {
local LAST_COMMAND_FAILED=$(mitsuhikos_lastcommandfailed) local LAST_COMMAND_FAILED=$(mitsuhikos_lastcommandfailed)
local SAVE_CURSOR='\033[s' local SAVE_CURSOR='\033[s'
local RESTORE_CURSOR='\033[u' local RESTORE_CURSOR='\033[u'

@ -28,7 +28,7 @@ else
THEME_PROMPT_HOST_COLOR="$_omb_prompt_navy" THEME_PROMPT_HOST_COLOR="$_omb_prompt_navy"
fi fi
doubletime_scm_prompt() { function doubletime_scm_prompt {
CHAR=$(scm_char) CHAR=$(scm_char)
if [ $CHAR = $SCM_NONE_CHAR ]; then if [ $CHAR = $SCM_NONE_CHAR ]; then
return return
@ -53,7 +53,7 @@ $(doubletime_scm_prompt)$_omb_prompt_reset_color $ "
_omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND
git_prompt_status() { function git_prompt_status {
local git_status_output local git_status_output
git_status_output=$(git status 2> /dev/null ) git_status_output=$(git status 2> /dev/null )
if [ -n "$(echo $git_status_output | grep 'Changes not staged')" ]; then if [ -n "$(echo $git_status_output | grep 'Changes not staged')" ]; then

@ -15,15 +15,15 @@
DULCIE_COLOR=${DULCIE_COLOR:=1} # 0 = monochrome, 1 = colorful DULCIE_COLOR=${DULCIE_COLOR:=1} # 0 = monochrome, 1 = colorful
DULCIE_MULTILINE=${DULCIE_MULTILINE:=1} # 0 = Single line, 1 = SCM in separate line DULCIE_MULTILINE=${DULCIE_MULTILINE:=1} # 0 = Single line, 1 = SCM in separate line
dulcie_color() { function dulcie_color {
echo -en "\[\e[38;5;${1}m\]" echo -en "\[\e[38;5;${1}m\]"
} }
dulcie_background() { function dulcie_background {
echo -en "\[\e[48;5;${1}m\]" echo -en "\[\e[48;5;${1}m\]"
} }
_omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND {
color_user_root=$(dulcie_color 169) color_user_root=$(dulcie_color 169)
color_user_nonroot="${_omb_prompt_green}" color_user_nonroot="${_omb_prompt_green}"
color_host_local=$(dulcie_color 230) color_host_local=$(dulcie_color 230)

@ -5,7 +5,7 @@ SCM_THEME_PROMPT_SUFFIX=""
SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}with changes" SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}with changes"
SCM_THEME_PROMPT_CLEAN="" SCM_THEME_PROMPT_CLEAN=""
venv() { function venv {
if [ ! -z "$VIRTUAL_ENV" ] if [ ! -z "$VIRTUAL_ENV" ]
then then
local env=$VIRTUAL_ENV local env=$VIRTUAL_ENV
@ -13,11 +13,11 @@ venv() {
fi fi
} }
last_two_dirs() { function last_two_dirs {
pwd|rev|awk -F / '{print $1,$2}'|rev|sed s_\ _/_|sed "s|$(sed 's,\/,,'<<<$HOME)|~|g" pwd|rev|awk -F / '{print $1,$2}'|rev|sed s_\ _/_|sed "s|$(sed 's,\/,,'<<<$HOME)|~|g"
} }
_omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND {
PS1="${_omb_prompt_olive}# ${_omb_prompt_reset_color}$(last_two_dirs)$(scm_prompt_info)${_omb_prompt_reset_color}$(venv)${_omb_prompt_reset_color} ${_omb_prompt_teal}\n> ${_omb_prompt_reset_color}" PS1="${_omb_prompt_olive}# ${_omb_prompt_reset_color}$(last_two_dirs)$(scm_prompt_info)${_omb_prompt_reset_color}$(venv)${_omb_prompt_reset_color} ${_omb_prompt_teal}\n> ${_omb_prompt_reset_color}"
} }

@ -28,7 +28,7 @@ function get_hour_color {
echo "$hour_color" echo "$hour_color"
} }
__emperor_clock() { function __emperor_clock {
THEME_CLOCK_COLOR=$(get_hour_color) THEME_CLOCK_COLOR=$(get_hour_color)
clock_prompt clock_prompt
} }

@ -14,7 +14,7 @@ SCM_HG_CHAR="h"
# export LSCOLORS="Gxfxcxdxbxegedabagacad" # export LSCOLORS="Gxfxcxdxbxegedabagacad"
# export LS_COLORS='no=00:fi=00:di=01;34:ln=00;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=41;33;01:ex=00;32:*.cmd=00;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.btm=01;32:*.dll=01;32:*.tar=00;31:*.tbz=00;31:*.tgz=00;31:*.rpm=00;31:*.deb=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.zip=00;31:*.zoo=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.tb2=00;31:*.tz2=00;31:*.tbz2=00;31:*.avi=01;35:*.bmp=01;35:*.fli=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mng=01;35:*.mov=01;35:*.mpg=01;35:*.pcx=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.ppm=01;35:*.tga=01;35:*.tif=01;35:*.xbm=01;35:*.xpm=01;35:*.dl=01;35:*.gl=01;35:*.wmv=01;35:*.aiff=00;32:*.au=00;32:*.mid=00;32:*.mp3=00;32:*.ogg=00;32:*.voc=00;32:*.wav=00;32:' # export LS_COLORS='no=00:fi=00:di=01;34:ln=00;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=41;33;01:ex=00;32:*.cmd=00;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.btm=01;32:*.dll=01;32:*.tar=00;31:*.tbz=00;31:*.tgz=00;31:*.rpm=00;31:*.deb=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.zip=00;31:*.zoo=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.tb2=00;31:*.tz2=00;31:*.tbz2=00;31:*.avi=01;35:*.bmp=01;35:*.fli=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mng=01;35:*.mov=01;35:*.mpg=01;35:*.pcx=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.ppm=01;35:*.tga=01;35:*.tif=01;35:*.xbm=01;35:*.xpm=01;35:*.dl=01;35:*.gl=01;35:*.wmv=01;35:*.aiff=00;32:*.au=00;32:*.mid=00;32:*.mp3=00;32:*.ogg=00;32:*.voc=00;32:*.wav=00;32:'
scm_prompt() { function scm_prompt {
CHAR=$(scm_char) CHAR=$(scm_char)
if [ $CHAR = $SCM_NONE_CHAR ] if [ $CHAR = $SCM_NONE_CHAR ]
then then
@ -24,7 +24,7 @@ scm_prompt() {
fi fi
} }
_omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND {
ps_host="${_omb_prompt_green}\h${_omb_prompt_normal}"; ps_host="${_omb_prompt_green}\h${_omb_prompt_normal}";
ps_user_mark="${_omb_prompt_bold}\$${_omb_prompt_normal}"; ps_user_mark="${_omb_prompt_bold}\$${_omb_prompt_normal}";
ps_root_mark="${_omb_prompt_normal}§" ps_root_mark="${_omb_prompt_normal}§"

@ -4,14 +4,14 @@ OSH_THEME_GIT_PROMPT_DIRTY="✗"
OSH_THEME_GIT_PROMPT_CLEAN="✓" OSH_THEME_GIT_PROMPT_CLEAN="✓"
# Nicely formatted terminal prompt # Nicely formatted terminal prompt
_omb_theme_half_way_prompt_scm() { function _omb_theme_half_way_prompt_scm {
local CHAR=$(scm_char) local CHAR=$(scm_char)
if [[ $CHAR != "$SCM_NONE_CHAR" ]]; then if [[ $CHAR != "$SCM_NONE_CHAR" ]]; then
printf '%s' " on ${_omb_prompt_navy}$(git_current_branch)$(parse_git_dirty)${_omb_prompt_normal} " printf '%s' " on ${_omb_prompt_navy}$(git_current_branch)$(parse_git_dirty)${_omb_prompt_normal} "
fi fi
} }
_omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND {
local ps_username="${_omb_prompt_purple}\u${_omb_prompt_normal}" local ps_username="${_omb_prompt_purple}\u${_omb_prompt_normal}"
local ps_path="${_omb_prompt_green}\w${_omb_prompt_normal}" local ps_path="${_omb_prompt_green}\w${_omb_prompt_normal}"
local ps_user_mark="${_omb_prompt_red}λ${_omb_prompt_normal}" local ps_user_mark="${_omb_prompt_red}λ${_omb_prompt_normal}"

@ -55,7 +55,7 @@ esac
PS3=">> " PS3=">> "
__my_rvm_ruby_version() { function __my_rvm_ruby_version {
local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}') local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}')
[ "$gemset" != "" ] && gemset="@$gemset" [ "$gemset" != "" ] && gemset="@$gemset"
local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}') local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}')
@ -63,14 +63,14 @@ __my_rvm_ruby_version() {
[ "$full" != "" ] && echo "[$full]" [ "$full" != "" ] && echo "[$full]"
} }
is_vim_shell() { function is_vim_shell {
if [ ! -z "$VIMRUNTIME" ] if [ ! -z "$VIMRUNTIME" ]
then then
echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]" echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]"
fi fi
} }
modern_scm_prompt() { function modern_scm_prompt {
CHAR=$(scm_char) CHAR=$(scm_char)
if [ $CHAR = $SCM_NONE_CHAR ] if [ $CHAR = $SCM_NONE_CHAR ]
then then
@ -81,7 +81,7 @@ modern_scm_prompt() {
} }
# show chroot if exist # show chroot if exist
chroot(){ function chroot {
if [ -n "$debian_chroot" ] if [ -n "$debian_chroot" ]
then then
my_ps_chroot="${_omb_prompt_bold_teal}$debian_chroot${_omb_prompt_normal}"; my_ps_chroot="${_omb_prompt_bold_teal}$debian_chroot${_omb_prompt_normal}";
@ -90,7 +90,7 @@ chroot(){
} }
# show virtualenvwrapper # show virtualenvwrapper
my_ve(){ function my_ve {
if [ -n "$VIRTUAL_ENV" ] if [ -n "$VIRTUAL_ENV" ]
then then
my_ps_ve="${_omb_prompt_bold_purple}$ve${_omb_prompt_normal}"; my_ps_ve="${_omb_prompt_bold_purple}$ve${_omb_prompt_normal}";
@ -99,7 +99,7 @@ my_ve(){
echo ""; echo "";
} }
_omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND {
my_ps_host="$BOLD$ORANGE\h${_omb_prompt_normal}"; my_ps_host="$BOLD$ORANGE\h${_omb_prompt_normal}";
# yes, these are the the same for now ... # yes, these are the the same for now ...

@ -5,7 +5,7 @@ SCM_THEME_PROMPT_SUFFIX="${_omb_prompt_teal})"
SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}" SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}"
SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_green}" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_green}"
_omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND {
PS1="$(scm_prompt_info)${_omb_prompt_reset_color} ${_omb_prompt_teal}\W${_omb_prompt_reset_color} " PS1="$(scm_prompt_info)${_omb_prompt_reset_color} ${_omb_prompt_teal}\W${_omb_prompt_reset_color} "
} }

@ -19,14 +19,14 @@ esac
PS3=">> " PS3=">> "
is_vim_shell() { function is_vim_shell {
if [ ! -z "$VIMRUNTIME" ] if [ ! -z "$VIMRUNTIME" ]
then then
echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]" echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]"
fi fi
} }
modern_scm_prompt() { function modern_scm_prompt {
CHAR=$(scm_char) CHAR=$(scm_char)
if [ $CHAR = $SCM_NONE_CHAR ] if [ $CHAR = $SCM_NONE_CHAR ]
then then
@ -36,7 +36,7 @@ modern_scm_prompt() {
fi fi
} }
_omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND {
if (($? != 0)); then if (($? != 0)); then
local border_color=$_omb_prompt_bold_brown local border_color=$_omb_prompt_bold_brown
else else

@ -19,14 +19,14 @@ esac
PS3=">> " PS3=">> "
is_vim_shell() { function is_vim_shell {
if [ ! -z "$VIMRUNTIME" ] if [ ! -z "$VIMRUNTIME" ]
then then
echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]" echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]"
fi fi
} }
modern_scm_prompt() { function modern_scm_prompt {
CHAR=$(scm_char) CHAR=$(scm_char)
if [ $CHAR = $SCM_NONE_CHAR ] if [ $CHAR = $SCM_NONE_CHAR ]
then then
@ -36,7 +36,7 @@ modern_scm_prompt() {
fi fi
} }
_omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND {
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
# Yes, the indenting on these is weird, but it has to be like # Yes, the indenting on these is weird, but it has to be like

@ -23,7 +23,7 @@ function prompt_end() {
echo -e "$PROMPT_END" echo -e "$PROMPT_END"
} }
_omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND {
local exit_status=$? local exit_status=$?
if [[ $exit_status -eq 0 ]]; then PROMPT_END=$PROMPT_END_CLEAN if [[ $exit_status -eq 0 ]]; then PROMPT_END=$PROMPT_END_CLEAN
else PROMPT_END=$PROMPT_END_DIRTY else PROMPT_END=$PROMPT_END_DIRTY

@ -90,7 +90,7 @@ function prompt_end() {
echo -e "$PROMPT_END" echo -e "$PROMPT_END"
} }
_omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND {
local exit_status=$? local exit_status=$?
if [[ $exit_status -eq 0 ]]; then PROMPT_END=$PROMPT_END_CLEAN if [[ $exit_status -eq 0 ]]; then PROMPT_END=$PROMPT_END_CLEAN
else PROMPT_END=$PROMPT_END_DIRTY else PROMPT_END=$PROMPT_END_DIRTY

@ -1,6 +1,6 @@
#! bash oh-my-bash.module #! bash oh-my-bash.module
_omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND {
# Save history # Save history
history -a history -a
history -c history -c

@ -50,5 +50,5 @@ IN_VIM_THEME_PROMPT_TEXT="vim"
POWERLINE_LEFT_PROMPT=${POWERLINE_LEFT_PROMPT:="scm python_venv ruby cwd"} POWERLINE_LEFT_PROMPT=${POWERLINE_LEFT_PROMPT:="scm python_venv ruby cwd"}
POWERLINE_RIGHT_PROMPT=${POWERLINE_RIGHT_PROMPT:="in_vim clock battery user_info"} POWERLINE_RIGHT_PROMPT=${POWERLINE_RIGHT_PROMPT:="in_vim clock battery user_info"}
_omb_theme_PROMPT_COMMAND() { __powerline_prompt_command "$@"; } function _omb_theme_PROMPT_COMMAND { __powerline_prompt_command "$@"; }
_omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND

@ -49,5 +49,5 @@ IN_VIM_THEME_PROMPT_TEXT="vim"
POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"} POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"}
_omb_theme_PROMPT_COMMAND() { __powerline_prompt_command "$@"; } function _omb_theme_PROMPT_COMMAND { __powerline_prompt_command "$@"; }
_omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND

@ -45,5 +45,5 @@ IN_VIM_THEME_PROMPT_TEXT="vim"
POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"} POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"}
_omb_theme_PROMPT_COMMAND() { __powerline_prompt_command "$@"; } function _omb_theme_PROMPT_COMMAND { __powerline_prompt_command "$@"; }
_omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND

@ -48,5 +48,5 @@ IN_VIM_THEME_PROMPT_TEXT="vim"
POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"} POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"}
_omb_theme_PROMPT_COMMAND() { __powerline_prompt_command "$@"; } function _omb_theme_PROMPT_COMMAND { __powerline_prompt_command "$@"; }
_omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND

@ -14,7 +14,7 @@ SCM_HG_CHAR="${_omb_prompt_bold_brown}☿${_omb_prompt_normal}"
# export LSCOLORS="Gxfxcxdxbxegedabagacad" # export LSCOLORS="Gxfxcxdxbxegedabagacad"
# export LS_COLORS='no=00:fi=00:di=01;34:ln=00;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=41;33;01:ex=00;32:*.cmd=00;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.btm=01;32:*.dll=01;32:*.tar=00;31:*.tbz=00;31:*.tgz=00;31:*.rpm=00;31:*.deb=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.zip=00;31:*.zoo=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.tb2=00;31:*.tz2=00;31:*.tbz2=00;31:*.avi=01;35:*.bmp=01;35:*.fli=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mng=01;35:*.mov=01;35:*.mpg=01;35:*.pcx=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.ppm=01;35:*.tga=01;35:*.tif=01;35:*.xbm=01;35:*.xpm=01;35:*.dl=01;35:*.gl=01;35:*.wmv=01;35:*.aiff=00;32:*.au=00;32:*.mid=00;32:*.mp3=00;32:*.ogg=00;32:*.voc=00;32:*.wav=00;32:' # export LS_COLORS='no=00:fi=00:di=01;34:ln=00;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=41;33;01:ex=00;32:*.cmd=00;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.btm=01;32:*.dll=01;32:*.tar=00;31:*.tbz=00;31:*.tgz=00;31:*.rpm=00;31:*.deb=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.zip=00;31:*.zoo=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.tb2=00;31:*.tz2=00;31:*.tbz2=00;31:*.avi=01;35:*.bmp=01;35:*.fli=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mng=01;35:*.mov=01;35:*.mpg=01;35:*.pcx=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.ppm=01;35:*.tga=01;35:*.tif=01;35:*.xbm=01;35:*.xpm=01;35:*.dl=01;35:*.gl=01;35:*.wmv=01;35:*.aiff=00;32:*.au=00;32:*.mid=00;32:*.mp3=00;32:*.ogg=00;32:*.voc=00;32:*.wav=00;32:'
scm_prompt() { function scm_prompt {
CHAR=$(scm_char) CHAR=$(scm_char)
if [ $CHAR = $SCM_NONE_CHAR ] if [ $CHAR = $SCM_NONE_CHAR ]
then then
@ -24,7 +24,7 @@ scm_prompt() {
fi fi
} }
_omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND {
ps_host="${_omb_prompt_bold_navy}\h${_omb_prompt_normal}"; ps_host="${_omb_prompt_bold_navy}\h${_omb_prompt_normal}";
ps_user="${_omb_prompt_green}\u${_omb_prompt_normal}"; ps_user="${_omb_prompt_green}\u${_omb_prompt_normal}";
ps_user_mark="${_omb_prompt_green} $ ${_omb_prompt_normal}"; ps_user_mark="${_omb_prompt_green} $ ${_omb_prompt_normal}";

@ -38,13 +38,13 @@ case $TERM in
;; ;;
esac esac
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} " echo "${D_INTERMEDIATE_COLOR}on ${D_VIMSHELL_COLOR}vim shell${D_DEFAULT_COLOR} "
fi fi
} }
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}" echo " ${D_DEFAULT_COLOR}C:${D_CMDFAIL_COLOR}$code ${D_DEFAULT_COLOR}"
@ -52,7 +52,7 @@ mitsuhikos_lastcommandfailed() {
} }
# vcprompt for scm instead of oh-my-bash default # vcprompt for scm instead of oh-my-bash default
demula_vcprompt() { function demula_vcprompt {
if [[ ${VCPROMPT_EXECUTABLE-} ]]; then if [[ ${VCPROMPT_EXECUTABLE-} ]]; then
local D_VCPROMPT_FORMAT="on ${D_SCM_COLOR}%s${D_INTERMEDIATE_COLOR}:${D_BRANCH_COLOR}%b %r ${D_CHANGES_COLOR}%m%u ${D_DEFAULT_COLOR}" local D_VCPROMPT_FORMAT="on ${D_SCM_COLOR}%s${D_INTERMEDIATE_COLOR}:${D_BRANCH_COLOR}%b %r ${D_CHANGES_COLOR}%m%u ${D_DEFAULT_COLOR}"
$VCPROMPT_EXECUTABLE -f "$D_VCPROMPT_FORMAT" $VCPROMPT_EXECUTABLE -f "$D_VCPROMPT_FORMAT"
@ -60,13 +60,13 @@ demula_vcprompt() {
} }
# checks if the plugin is installed before calling battery_charge # checks if the plugin is installed before calling battery_charge
safe_battery_charge() { function safe_battery_charge {
if _omb_util_function_exists battery_charge; then if _omb_util_function_exists battery_charge; then
battery_charge battery_charge
fi fi
} }
prompt_git() { function prompt_git {
local branchName='' local branchName=''
# Check if the current directory is in a Git repository. # Check if the current directory is in a Git repository.
@ -85,7 +85,7 @@ prompt_git() {
fi fi
} }
limited_pwd() { function limited_pwd {
# Max length of PWD to display # Max length of PWD to display
local MAX_PWD_LENGTH=20 local MAX_PWD_LENGTH=20
@ -104,7 +104,7 @@ limited_pwd() {
} }
# -------------------------------------------------------------- PROMPT OUTPUT # -------------------------------------------------------------- PROMPT OUTPUT
_omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND {
local LAST_COMMAND_FAILED=$(mitsuhikos_lastcommandfailed) local LAST_COMMAND_FAILED=$(mitsuhikos_lastcommandfailed)
local SAVE_CURSOR='\[\e7' local SAVE_CURSOR='\[\e7'
local RESTORE_CURSOR='\e8\]' local RESTORE_CURSOR='\e8\]'

@ -5,7 +5,7 @@
# ± ~/path/to (branch ✓) $ # ± ~/path/to (branch ✓) $
# in glorious red / blue / yellow color scheme # in glorious red / blue / yellow color scheme
_omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND {
# Save history # Save history
history -a history -a
history -c history -c

@ -83,13 +83,13 @@ case $TERM in
;; ;;
esac esac
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} " echo "${D_INTERMEDIATE_COLOR}on ${D_VIMSHELL_COLOR}vim shell${D_DEFAULT_COLOR} "
fi fi
} }
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}" echo "${D_INTERMEDIATE_COLOR}exited ${D_CMDFAIL_COLOR}$status ${D_DEFAULT_COLOR}"
@ -97,7 +97,7 @@ mitsuhikos_lastcommandfailed() {
} }
# vcprompt for scm instead of oh-my-bash default # vcprompt for scm instead of oh-my-bash default
demula_vcprompt() { function demula_vcprompt {
if [[ ${VCPROMPT_EXECUTABLE-} ]]; then if [[ ${VCPROMPT_EXECUTABLE-} ]]; then
local D_VCPROMPT_FORMAT="on ${D_SCM_COLOR}%s${D_INTERMEDIATE_COLOR}:${D_BRANCH_COLOR}%b %r ${D_CHANGES_COLOR}%m%u ${D_DEFAULT_COLOR}" local D_VCPROMPT_FORMAT="on ${D_SCM_COLOR}%s${D_INTERMEDIATE_COLOR}:${D_BRANCH_COLOR}%b %r ${D_CHANGES_COLOR}%m%u ${D_DEFAULT_COLOR}"
$VCPROMPT_EXECUTABLE -f "$D_VCPROMPT_FORMAT" $VCPROMPT_EXECUTABLE -f "$D_VCPROMPT_FORMAT"
@ -105,13 +105,13 @@ demula_vcprompt() {
} }
# checks if the plugin is installed before calling battery_charge # checks if the plugin is installed before calling battery_charge
safe_battery_charge() { function safe_battery_charge {
if _omb_util_function_exists battery_charge; then if _omb_util_function_exists battery_charge; then
battery_charge battery_charge
fi fi
} }
prompt_git() { function prompt_git {
local s='' local s=''
local branchName='' local branchName=''
@ -163,7 +163,7 @@ prompt_git() {
} }
# -------------------------------------------------------------- PROMPT OUTPUT # -------------------------------------------------------------- PROMPT OUTPUT
_omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND {
local LAST_COMMAND_FAILED=$(mitsuhikos_lastcommandfailed) local LAST_COMMAND_FAILED=$(mitsuhikos_lastcommandfailed)
local SAVE_CURSOR='\[\e7' local SAVE_CURSOR='\[\e7'
local RESTORE_CURSOR='\e8\]' local RESTORE_CURSOR='\e8\]'

@ -29,7 +29,7 @@ case $TERM in
esac esac
__my_rvm_ruby_version() { function __my_rvm_ruby_version {
local gemset ; gemset=$(awk -F'@' '{print $2}' <<< "${GEM_HOME}") local gemset ; gemset=$(awk -F'@' '{print $2}' <<< "${GEM_HOME}")
local version ; version=$(awk -F'-' '{print $2}' <<< "${MY_RUBY_HOME}") local version ; version=$(awk -F'-' '{print $2}' <<< "${MY_RUBY_HOME}")
[ "${gemset}" != "" ] && gemset="@${gemset}" [ "${gemset}" != "" ] && gemset="@${gemset}"
@ -38,20 +38,20 @@ __my_rvm_ruby_version() {
&& echo "${OMB_THEME_BRACKET_COLOR}[${OMB_THEME_STRING_COLOR}${full}${OMB_THEME_BRACKET_COLOR}]${_omb_prompt_normal}" && echo "${OMB_THEME_BRACKET_COLOR}[${OMB_THEME_STRING_COLOR}${full}${OMB_THEME_BRACKET_COLOR}]${_omb_prompt_normal}"
} }
is_vim_shell() { function is_vim_shell {
if [ -n "${VIMRUNTIME}" ] ; then if [ -n "${VIMRUNTIME}" ] ; then
echo "${OMB_THEME_BRACKET_COLOR}[${OMB_THEME_STRING_COLOR}vim shell${OMB_THEME_BRACKET_COLOR}]${_omb_prompt_normal}" echo "${OMB_THEME_BRACKET_COLOR}[${OMB_THEME_STRING_COLOR}vim shell${OMB_THEME_BRACKET_COLOR}]${_omb_prompt_normal}"
fi fi
} }
is_integer() { # helper function to make sure input is an integer function is_integer { # helper function to make sure input is an integer
[ "$1" -eq "$1" ] > /dev/null 2>&1 [ "$1" -eq "$1" ] > /dev/null 2>&1
return $? return $?
} }
# XXX do we need/want to integrate with todo.sh? We don't provide it and I # XXX do we need/want to integrate with todo.sh? We don't provide it and I
# can't find a version online that accepts ls as an input # can't find a version online that accepts ls as an input
todo_txt_count() { function todo_txt_count {
if _omb_util_command_exists todo.sh; then # is todo.sh installed if _omb_util_command_exists todo.sh; then # is todo.sh installed
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 }')
@ -61,7 +61,7 @@ todo_txt_count() {
fi fi
} }
modern_scm_prompt() { function modern_scm_prompt {
local CHAR=$(scm_char) local CHAR=$(scm_char)
if [ ! "${CHAR}" = "${SCM_NONE_CHAR}" ] ; then if [ ! "${CHAR}" = "${SCM_NONE_CHAR}" ] ; then
printf "%s" \ printf "%s" \
@ -71,7 +71,7 @@ modern_scm_prompt() {
fi fi
} }
_omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND {
local my_host="${OMB_THEME_STRING_COLOR}\h${_omb_prompt_normal}"; local my_host="${OMB_THEME_STRING_COLOR}\h${_omb_prompt_normal}";
local my_user="${OMB_THEME_STRING_COLOR}\u${_omb_prompt_normal}"; local my_user="${OMB_THEME_STRING_COLOR}\u${_omb_prompt_normal}";
local my_path="${OMB_THEME_STRING_COLOR}\w${_omb_prompt_normal}"; local my_path="${OMB_THEME_STRING_COLOR}\w${_omb_prompt_normal}";

@ -33,10 +33,10 @@ else
RESET="\033[m" RESET="\033[m"
fi fi
parse_git_dirty () { function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1 | cut -c 1-17) != "nothing to commit" ]] && echo "*" [[ $(git status 2> /dev/null | tail -n1 | cut -c 1-17) != "nothing to commit" ]] && echo "*"
} }
parse_git_branch () { function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
} }

@ -22,7 +22,7 @@ esac
PS3=">> " PS3=">> "
__my_rvm_ruby_version() { function __my_rvm_ruby_version {
local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}') local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}')
[ "$gemset" != "" ] && gemset="@$gemset" [ "$gemset" != "" ] && gemset="@$gemset"
local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}') local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}')
@ -30,21 +30,21 @@ __my_rvm_ruby_version() {
[ "$full" != "" ] && echo "[$full]" [ "$full" != "" ] && echo "[$full]"
} }
__my_venv_prompt() { function __my_venv_prompt {
if [ ! -z "$VIRTUAL_ENV" ] if [ ! -z "$VIRTUAL_ENV" ]
then then
echo "[${_omb_prompt_navy}@${_omb_prompt_normal}${VIRTUAL_ENV##*/}]" echo "[${_omb_prompt_navy}@${_omb_prompt_normal}${VIRTUAL_ENV##*/}]"
fi fi
} }
is_vim_shell() { function is_vim_shell {
if [ ! -z "$VIMRUNTIME" ] if [ ! -z "$VIMRUNTIME" ]
then then
echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]" echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]"
fi fi
} }
modern_scm_prompt() { function modern_scm_prompt {
CHAR=$(scm_char) CHAR=$(scm_char)
if [ $CHAR = $SCM_NONE_CHAR ] if [ $CHAR = $SCM_NONE_CHAR ]
then then
@ -54,7 +54,7 @@ modern_scm_prompt() {
fi fi
} }
_omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND {
case $HOSTNAME in case $HOSTNAME in
"clappy"* ) my_ps_host="${_omb_prompt_green}\h${_omb_prompt_normal}"; "clappy"* ) my_ps_host="${_omb_prompt_green}\h${_omb_prompt_normal}";

@ -1,23 +1,23 @@
#! bash oh-my-bash.module #! bash oh-my-bash.module
__tonka_time() { function __tonka_time {
THEME_CLOCK_FORMAT="%H%M" THEME_CLOCK_FORMAT="%H%M"
clock_prompt clock_prompt
} }
__tonka_date() { function __tonka_date {
THEME_CLOCK_FORMAT="%a,%d %b %y" THEME_CLOCK_FORMAT="%a,%d %b %y"
clock_prompt clock_prompt
} }
__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}:" echo "$(__tonka_time)${LIGHT_BLUE}:$(__tonka_date)${LIGHT_BLUE}:"
fi fi
} }
_omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND {
# Named "Tonka" because of the colour scheme # Named "Tonka" because of the colour scheme
local WHITE="\[\033[1;37m\]" local WHITE="\[\033[1;37m\]"

@ -15,7 +15,7 @@
# [3] https://github.com/microsoft/vscode-dev-containers/blob/172a918f40e31bd24da8e64135026ec9f26c91b0/containers/javascript-node/.devcontainer/library-scripts/common-debian.sh#L303-L320 # [3] https://github.com/microsoft/vscode-dev-containers/blob/172a918f40e31bd24da8e64135026ec9f26c91b0/containers/javascript-node/.devcontainer/library-scripts/common-debian.sh#L303-L320
# #
_omb_theme_vscode_initialize() { function _omb_theme_vscode_initialize {
local userpart='`export XIT=$? \ local userpart='`export XIT=$? \
&& [ ! -z "${GITHUB_USER}" ] && echo -n "\[\033[0;32m\]@${GITHUB_USER} " || echo -n "\[\033[0;32m\]\u " \ && [ ! -z "${GITHUB_USER}" ] && echo -n "\[\033[0;32m\]@${GITHUB_USER} " || echo -n "\[\033[0;32m\]\u " \
&& [ "$XIT" -ne "0" ] && echo -n "\[\033[1;31m\]➜" || echo -n "\[\033[0m\]➜"`' && [ "$XIT" -ne "0" ] && echo -n "\[\033[1;31m\]➜" || echo -n "\[\033[0m\]➜"`'
@ -37,5 +37,5 @@ _omb_theme_vscode_initialize() {
} }
_omb_theme_vscode_initialize _omb_theme_vscode_initialize
_omb_theme_PROMPT_COMMAND() { true; } function _omb_theme_PROMPT_COMMAND { true; }
PROMPT_DIRTRIM=4 PROMPT_DIRTRIM=4

@ -22,7 +22,7 @@ esac
PS3=">> " PS3=">> "
__my_rvm_ruby_version() { function __my_rvm_ruby_version {
local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}') local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}')
[ "$gemset" != "" ] && gemset="@$gemset" [ "$gemset" != "" ] && gemset="@$gemset"
local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}') local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}')
@ -30,14 +30,14 @@ __my_rvm_ruby_version() {
[ "$full" != "" ] && echo "[$full]" [ "$full" != "" ] && echo "[$full]"
} }
is_vim_shell() { function is_vim_shell {
if [ ! -z "$VIMRUNTIME" ] if [ ! -z "$VIMRUNTIME" ]
then then
echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]" echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]"
fi fi
} }
modern_scm_prompt() { function modern_scm_prompt {
CHAR=$(scm_char) CHAR=$(scm_char)
if [ $CHAR = $SCM_NONE_CHAR ] if [ $CHAR = $SCM_NONE_CHAR ]
then then
@ -48,7 +48,7 @@ modern_scm_prompt() {
} }
# show chroot if exist # show chroot if exist
chroot(){ function chroot {
if [ -n "$debian_chroot" ] if [ -n "$debian_chroot" ]
then then
my_ps_chroot="${_omb_prompt_bold_teal}$debian_chroot${_omb_prompt_normal}"; my_ps_chroot="${_omb_prompt_bold_teal}$debian_chroot${_omb_prompt_normal}";
@ -57,7 +57,7 @@ chroot(){
} }
# show virtualenvwrapper # show virtualenvwrapper
my_ve(){ function my_ve {
if [ -n "$VIRTUAL_ENV" ] if [ -n "$VIRTUAL_ENV" ]
then then
my_ps_ve="${_omb_prompt_bold_purple}$ve${_omb_prompt_normal}"; my_ps_ve="${_omb_prompt_bold_purple}$ve${_omb_prompt_normal}";
@ -66,7 +66,7 @@ my_ve(){
echo ""; echo "";
} }
_omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND {
my_ps_host="${_omb_prompt_green}\h${_omb_prompt_normal}"; my_ps_host="${_omb_prompt_green}\h${_omb_prompt_normal}";
# yes, these are the the same for now ... # yes, these are the the same for now ...

@ -75,7 +75,7 @@ __bp_install_string=$'__bp_trap_string="$(trap -p DEBUG)"\ntrap - DEBUG\n__bp_in
# Fails if any of the given variables are readonly # Fails if any of the given variables are readonly
# Reference https://stackoverflow.com/a/4441178 # Reference https://stackoverflow.com/a/4441178
__bp_require_not_readonly() { function __bp_require_not_readonly {
local var local var
for var; do for var; do
if ! ( unset "$var" 2> /dev/null ); then if ! ( unset "$var" 2> /dev/null ); then
@ -88,7 +88,7 @@ __bp_require_not_readonly() {
# Remove ignorespace and or replace ignoreboth from HISTCONTROL # Remove ignorespace and or replace ignoreboth from HISTCONTROL
# so we can accurately invoke preexec with a command from our # so we can accurately invoke preexec with a command from our
# history even if it starts with a space. # history even if it starts with a space.
__bp_adjust_histcontrol() { function __bp_adjust_histcontrol {
local histcontrol local histcontrol
histcontrol="${HISTCONTROL:-}" histcontrol="${HISTCONTROL:-}"
histcontrol="${histcontrol//ignorespace}" histcontrol="${histcontrol//ignorespace}"
@ -112,7 +112,7 @@ declare -a preexec_functions
# Trims leading and trailing whitespace from $2 and writes it to the variable # Trims leading and trailing whitespace from $2 and writes it to the variable
# name passed as $1 # name passed as $1
__bp_trim_whitespace() { function __bp_trim_whitespace {
local var=${1:?} text=${2:-} local var=${1:?} text=${2:-}
text="${text#"${text%%[![:space:]]*}"}" # remove leading whitespace characters text="${text#"${text%%[![:space:]]*}"}" # remove leading whitespace characters
text="${text%"${text##*[![:space:]]}"}" # remove trailing whitespace characters text="${text%"${text##*[![:space:]]}"}" # remove trailing whitespace characters
@ -123,7 +123,7 @@ __bp_trim_whitespace() {
# Trims whitespace and removes any leading or trailing semicolons from $2 and # Trims whitespace and removes any leading or trailing semicolons from $2 and
# writes the resulting string to the variable name passed as $1. Used for # writes the resulting string to the variable name passed as $1. Used for
# manipulating substrings in PROMPT_COMMAND # manipulating substrings in PROMPT_COMMAND
__bp_sanitize_string() { function __bp_sanitize_string {
local var=${1:?} text=${2:-} sanitized local var=${1:?} text=${2:-} sanitized
__bp_trim_whitespace sanitized "$text" __bp_trim_whitespace sanitized "$text"
sanitized=${sanitized%;} sanitized=${sanitized%;}
@ -135,14 +135,14 @@ __bp_sanitize_string() {
# This function is installed as part of the PROMPT_COMMAND; # This function is installed as part of the PROMPT_COMMAND;
# It sets a variable to indicate that the prompt was just displayed, # It sets a variable to indicate that the prompt was just displayed,
# to allow the DEBUG trap to know that the next command is likely interactive. # to allow the DEBUG trap to know that the next command is likely interactive.
__bp_interactive_mode() { function __bp_interactive_mode {
__bp_preexec_interactive_mode="on"; __bp_preexec_interactive_mode="on";
} }
# This function is installed as part of the PROMPT_COMMAND. # This function is installed as part of the PROMPT_COMMAND.
# It will invoke any functions defined in the precmd_functions array. # It will invoke any functions defined in the precmd_functions array.
__bp_precmd_invoke_cmd() { function __bp_precmd_invoke_cmd {
# Save the returned value from our last command, and from each process in # Save the returned value from our last command, and from each process in
# its pipeline. Note: this MUST be the first thing done in this function. # its pipeline. Note: this MUST be the first thing done in this function.
# BP_PIPESTATUS may be unused, ignore # BP_PIPESTATUS may be unused, ignore
@ -177,11 +177,11 @@ __bp_precmd_invoke_cmd() {
# Sets a return value in $?. We may want to get access to the $? variable in our # Sets a return value in $?. We may want to get access to the $? variable in our
# precmd functions. This is available for instance in zsh. We can simulate it in bash # precmd functions. This is available for instance in zsh. We can simulate it in bash
# by setting the value here. # by setting the value here.
__bp_set_ret_value() { function __bp_set_ret_value {
return ${1:+"$1"} return ${1:+"$1"}
} }
__bp_in_prompt_command() { function __bp_in_prompt_command {
local prompt_command_array local prompt_command_array
IFS=$'\n;' read -rd '' -a prompt_command_array <<< "${PROMPT_COMMAND:-}" IFS=$'\n;' read -rd '' -a prompt_command_array <<< "${PROMPT_COMMAND:-}"
@ -204,7 +204,7 @@ __bp_in_prompt_command() {
# interactive prompt display. Its purpose is to inspect the current # interactive prompt display. Its purpose is to inspect the current
# environment to attempt to detect if the current command is being invoked # environment to attempt to detect if the current command is being invoked
# interactively, and invoke 'preexec' if so. # interactively, and invoke 'preexec' if so.
__bp_preexec_invoke_exec() { function __bp_preexec_invoke_exec {
# Save the contents of $_ so that it can be restored later on. # Save the contents of $_ so that it can be restored later on.
# https://stackoverflow.com/questions/40944532/bash-preserve-in-a-debug-trap#40944702 # https://stackoverflow.com/questions/40944532/bash-preserve-in-a-debug-trap#40944702
@ -288,7 +288,7 @@ __bp_preexec_invoke_exec() {
__bp_set_ret_value "$preexec_ret_value" "$__bp_last_argument_prev_command" __bp_set_ret_value "$preexec_ret_value" "$__bp_last_argument_prev_command"
} }
__bp_install() { function __bp_install {
# Exit if we already have this installed. # Exit if we already have this installed.
if [[ "${PROMPT_COMMAND:-}" == *"__bp_precmd_invoke_cmd"* ]]; then if [[ "${PROMPT_COMMAND:-}" == *"__bp_precmd_invoke_cmd"* ]]; then
return 1; return 1;
@ -351,7 +351,7 @@ __bp_install() {
# Sets an installation string as part of our PROMPT_COMMAND to install # Sets an installation string as part of our PROMPT_COMMAND to install
# after our session has started. This allows bash-preexec to be included # after our session has started. This allows bash-preexec to be included
# at any point in our bash profile. # at any point in our bash profile.
__bp_install_after_session_init() { function __bp_install_after_session_init {
# bash-preexec needs to modify these variables in order to work correctly # bash-preexec needs to modify these variables in order to work correctly
# if it can't, just stop the installation # if it can't, just stop the installation
__bp_require_not_readonly PROMPT_COMMAND HISTCONTROL HISTTIMEFORMAT || return __bp_require_not_readonly PROMPT_COMMAND HISTCONTROL HISTTIMEFORMAT || return

@ -1854,7 +1854,7 @@ _git_gitk ()
# 2: The tag file to list symbol names from. # 2: The tag file to list symbol names from.
# 3: A prefix to be added to each listed symbol name (optional). # 3: A prefix to be added to each listed symbol name (optional).
# 4: A suffix to be appended to each listed symbol name (optional). # 4: A suffix to be appended to each listed symbol name (optional).
__git_match_ctag () { function __git_match_ctag {
awk -v pfx="${3-}" -v sfx="${4-}" " awk -v pfx="${3-}" -v sfx="${4-}" "
/^${1//\//\\/}/ { print pfx \$1 sfx } /^${1//\//\\/}/ { print pfx \$1 sfx }
" "$2" " "$2"
@ -1869,7 +1869,7 @@ __git_match_ctag () {
# the current word to be completed. # the current word to be completed.
# --sfx=<suffix>: A suffix to be appended to each symbol name instead # --sfx=<suffix>: A suffix to be appended to each symbol name instead
# of the default space. # of the default space.
__git_complete_symbol () { function __git_complete_symbol {
local tags=tags pfx="" cur_="${cur-}" sfx=" " local tags=tags pfx="" cur_="${cur-}" sfx=" "
while test $# != 0; do while test $# != 0; do
@ -3332,7 +3332,7 @@ _git_worktree ()
esac esac
} }
__git_complete_common () { function __git_complete_common {
local command="$1" local command="$1"
case "$cur" in case "$cur" in
@ -3343,7 +3343,7 @@ __git_complete_common () {
} }
__git_cmds_with_parseopt_helper= __git_cmds_with_parseopt_helper=
__git_support_parseopt_helper () { function __git_support_parseopt_helper {
test -n "$__git_cmds_with_parseopt_helper" || test -n "$__git_cmds_with_parseopt_helper" ||
__git_cmds_with_parseopt_helper="$(__git --list-cmds=parseopt)" __git_cmds_with_parseopt_helper="$(__git --list-cmds=parseopt)"
@ -3357,11 +3357,11 @@ __git_support_parseopt_helper () {
esac esac
} }
__git_have_func () { function __git_have_func {
declare -f -- "$1" >/dev/null 2>&1 declare -f -- "$1" >/dev/null 2>&1
} }
__git_complete_command () { function __git_complete_command {
local command="$1" local command="$1"
local completion_func="_git_${command//-/_}" local completion_func="_git_${command//-/_}"
if ! __git_have_func $completion_func && if ! __git_have_func $completion_func &&

@ -20,21 +20,21 @@ elif ((BASH_VERSINFO[0] < 4)); then
printf "Warning: Why don't you upgrade your Bash to 4 or higher?\n" >&2 printf "Warning: Why don't you upgrade your Bash to 4 or higher?\n" >&2
fi fi
_omb_install_print_version() { function _omb_install_print_version {
local OMB_VERSINFO local OMB_VERSINFO
OMB_VERSINFO=(1 0 0 0 master noarch) OMB_VERSINFO=(1 0 0 0 master noarch)
printf '%s\n' 'Install script for Oh-My-Bash (https://github.com/ohmybash/oh-my-bash)' printf '%s\n' 'Install script for Oh-My-Bash (https://github.com/ohmybash/oh-my-bash)'
printf 'oh-my-bash, version %s.%s.%s(%s)-%s (%s)\n' "${OMB_VERSINFO[@]}" printf 'oh-my-bash, version %s.%s.%s(%s)-%s (%s)\n' "${OMB_VERSINFO[@]}"
} }
_omb_install_print_usage() { function _omb_install_print_usage {
printf '%s\n' \ printf '%s\n' \
'usage: ./install.sh [--unattended | --dry-run | --help | --usage | --version]' \ 'usage: ./install.sh [--unattended | --dry-run | --help | --usage | --version]' \
'usage: bash -c "$(< install.sh)" [--unattended | --dry-run | --help | --usage |' \ 'usage: bash -c "$(< install.sh)" [--unattended | --dry-run | --help | --usage |' \
' --version]' ' --version]'
} }
_omb_install_print_help() { function _omb_install_print_help {
_omb_install_print_version _omb_install_print_version
_omb_install_print_usage _omb_install_print_usage
printf '%s\n' \ printf '%s\n' \
@ -52,7 +52,7 @@ _omb_install_print_help() {
## @fn _omb_install_readargs [options...] ## @fn _omb_install_readargs [options...]
## @var[out] install_opts ## @var[out] install_opts
## @var[out] install_prefix ## @var[out] install_prefix
_omb_install_readargs() { function _omb_install_readargs {
install_opts= install_opts=
install_prefix= install_prefix=
while (($#)); do while (($#)); do
@ -101,7 +101,7 @@ _omb_install_readargs() {
done done
} }
_omb_install_run() { function _omb_install_run {
if [[ :$install_opts: == *:dry-run:* ]]; then if [[ :$install_opts: == *:dry-run:* ]]; then
printf '%s\n' "$BOLD$GREEN[dryrun]$NORMAL $BOLD$*$NORMAL" >&5 printf '%s\n' "$BOLD$GREEN[dryrun]$NORMAL $BOLD$*$NORMAL" >&5
else else
@ -110,7 +110,7 @@ _omb_install_run() {
fi fi
} }
_omb_install_banner() { function _omb_install_banner {
# MOTD message :) # MOTD message :)
printf '%s' "$GREEN" printf '%s' "$GREEN"
printf '%s\n' \ printf '%s\n' \
@ -126,7 +126,7 @@ _omb_install_banner() {
## @fn _omb_install_user_bashrc ## @fn _omb_install_user_bashrc
## @var[in] install_opts ## @var[in] install_opts
## @var[in] OSH ## @var[in] OSH
_omb_install_user_bashrc() { function _omb_install_user_bashrc {
printf "${BLUE}Looking for an existing bash config...${NORMAL}\n" printf "${BLUE}Looking for an existing bash config...${NORMAL}\n"
if [[ -f ~/.bashrc || -h ~/.bashrc ]]; then if [[ -f ~/.bashrc || -h ~/.bashrc ]]; then
local bashrc_backup=~/.bashrc.omb-backup-$(date +%Y%m%d%H%M%S) local bashrc_backup=~/.bashrc.omb-backup-$(date +%Y%m%d%H%M%S)
@ -169,7 +169,7 @@ export OSH='${OSH//\'/\'\\\'\'}'
fi fi
} }
_omb_install_system_bashrc() { function _omb_install_system_bashrc {
printf "${BLUE}Creating a bashrc template at '$OSH/bashrc'...${NORMAL}\n" printf "${BLUE}Creating a bashrc template at '$OSH/bashrc'...${NORMAL}\n"
local q=\' Q="'\''" local q=\' Q="'\''"
local osh="'${OSH//$q/$Q}'" local osh="'${OSH//$q/$Q}'"
@ -184,7 +184,7 @@ _omb_install_system_bashrc() {
printf "${BLUE}${BOLD}%s${NORMAL}\n" "To keep up on the latest news and updates, follow us on GitHub: https://github.com/ohmybash/oh-my-bash" printf "${BLUE}${BOLD}%s${NORMAL}\n" "To keep up on the latest news and updates, follow us on GitHub: https://github.com/ohmybash/oh-my-bash"
} }
_omb_install_main() { function _omb_install_main {
# Use colors, but only if connected to a terminal, and that terminal # Use colors, but only if connected to a terminal, and that terminal
# supports them. # supports them.
if type -P tput &>/dev/null; then if type -P tput &>/dev/null; then

@ -3,12 +3,12 @@
# Note: this file is intentionally written in POSIX sh so that oh-my-bash can # Note: this file is intentionally written in POSIX sh so that oh-my-bash can
# be uninstalled without bash. # be uninstalled without bash.
_omb_uninstall_contains_omb() { function _omb_uninstall_contains_omb {
command grep -qE '(source|\.)[[:space:]]+.*[/[:space:]]oh-my-bash\.sh' "$1" 2>/dev/null command grep -qE '(source|\.)[[:space:]]+.*[/[:space:]]oh-my-bash\.sh' "$1" 2>/dev/null
} }
# Find the latest bashrc that do not source oh-my-bash.sh # Find the latest bashrc that do not source oh-my-bash.sh
_omb_uninstall_find_bashrc_original() { function _omb_uninstall_find_bashrc_original {
_omb_uninstall_bashrc_original= _omb_uninstall_bashrc_original=
printf '%s\n' "Looking for original bash config..." printf '%s\n' "Looking for original bash config..."
IFS=' IFS='