diff --git a/completions/apm.completion.sh b/completions/apm.completion.sh index 0f57162..1ea755b 100644 --- a/completions/apm.completion.sh +++ b/completions/apm.completion.sh @@ -3,7 +3,7 @@ # apm-bash-completion is written by Ugur Ozyilmazel # repo: https://github.com/vigo/apm-bash-completion -__apm(){ +function __apm { local cur prev options apm_command COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" @@ -30,7 +30,7 @@ __apm(){ fi COMPREPLY=($(compgen -W "$options" -- "$cur")) } -__apm_get_command() { +function __apm_get_command { local i for ((i=1; i < $COMP_CWORD; ++i)); do local arg=${COMP_WORDS[$i]} diff --git a/completions/bundler.completion.sh b/completions/bundler.completion.sh index 9d12103..ef8ce5e 100644 --- a/completions/bundler.completion.sh +++ b/completions/bundler.completion.sh @@ -8,7 +8,7 @@ # To use, source this file on bash: # . completion-bundle -__bundle() { +function __bundle { local cur=$2 local prev=$3 local bundle_command @@ -30,7 +30,7 @@ __bundle() { COMPREPLY=($(compgen -W "$options" -- "$cur")) } -__bundle_get_command() { +function __bundle_get_command { local i for ((i=1; i < $COMP_CWORD; ++i)); do local arg=${COMP_WORDS[$i]} diff --git a/completions/capistrano.completion.sh b/completions/capistrano.completion.sh index 62de4bd..dd34dd3 100644 --- a/completions/capistrano.completion.sh +++ b/completions/capistrano.completion.sh @@ -3,7 +3,7 @@ export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/} -_capcomplete() { +function _capcomplete { if [ -f Capfile ]; then recent=`ls -t .cap_tasks~ Capfile **/*.cap 2> /dev/null | head -n 1` if [[ $recent != '.cap_tasks~' ]]; then diff --git a/completions/dirs.completion.sh b/completions/dirs.completion.sh index 2c74016..02c2dc0 100644 --- a/completions/dirs.completion.sh +++ b/completions/dirs.completion.sh @@ -1,7 +1,7 @@ #! bash oh-my-bash.module # Bash completion support for the 'dirs' plugin (commands G, R). -_dirs-complete() { +function _dirs-complete { local CURRENT_PROMPT="${COMP_WORDS[COMP_CWORD]}" # parse all defined shortcuts from ~/.dirs diff --git a/completions/docker-compose.completion.sh b/completions/docker-compose.completion.sh index b3fabd8..b612105 100644 --- a/completions/docker-compose.completion.sh +++ b/completions/docker-compose.completion.sh @@ -17,13 +17,13 @@ # . ~/.docker-compose-completion.sh -__docker_compose_q() { +function __docker_compose_q { docker-compose 2>/dev/null $daemon_options "$@" } # Transforms a multiline list of strings into a single line string # with the words separated by "|". -__docker_compose_to_alternatives() { +function __docker_compose_to_alternatives { local parts=( $1 ) local IFS='|' echo "${parts[*]}" @@ -31,29 +31,29 @@ __docker_compose_to_alternatives() { # Transforms a multiline list of options into an extglob pattern # suitable for use in case statements. -__docker_compose_to_extglob() { +function __docker_compose_to_extglob { local extglob=$( __docker_compose_to_alternatives "$1" ) echo "@($extglob)" } # suppress trailing whitespace -__docker_compose_nospace() { +function __docker_compose_nospace { # compopt is not available in ancient bash versions _omb_util_command_exists compopt && compopt -o nospace } # 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 } # 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") ) } # 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 __docker_compose_q config \ | sed -n -e '/^services:/,/^[^ ]/p' \ @@ -63,18 +63,18 @@ ___docker_compose_services_with_key() { } # 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") ) } # 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") ) } # The services for which containers have been created, optionally filtered # by a boolean expression passed in as argument. -__docker_compose_services_with() { +function __docker_compose_services_with { local containers names 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) @@ -82,22 +82,22 @@ __docker_compose_services_with() { } # 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' } # 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' } # 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_build() { +function _docker_compose_build { case "$cur" in -*) 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 --output|-o) _filedir @@ -121,12 +121,12 @@ _docker_compose_bundle() { } -_docker_compose_config() { +function _docker_compose_config { COMPREPLY=( $( compgen -W "--help --quiet -q --services" -- "$cur" ) ) } -_docker_compose_create() { +function _docker_compose_create { case "$cur" in -*) 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 --tlscacert|--tlscert|--tlskey) _filedir @@ -164,7 +164,7 @@ _docker_compose_docker_compose() { } -_docker_compose_down() { +function _docker_compose_down { case "$prev" in --rmi) COMPREPLY=( $( compgen -W "all local" -- "$cur" ) ) @@ -180,7 +180,7 @@ _docker_compose_down() { } -_docker_compose_events() { +function _docker_compose_events { case "$prev" in --json) return @@ -198,7 +198,7 @@ _docker_compose_events() { } -_docker_compose_exec() { +function _docker_compose_exec { case "$prev" in --index|--user) return @@ -216,12 +216,12 @@ _docker_compose_exec() { } -_docker_compose_help() { +function _docker_compose_help { COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) ) } -_docker_compose_kill() { +function _docker_compose_kill { case "$prev" in -s) 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 --tail) return @@ -258,7 +258,7 @@ _docker_compose_logs() { } -_docker_compose_pause() { +function _docker_compose_pause { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -270,7 +270,7 @@ _docker_compose_pause() { } -_docker_compose_port() { +function _docker_compose_port { case "$prev" in --protocol) COMPREPLY=( $( compgen -W "tcp udp" -- "$cur" ) ) @@ -292,7 +292,7 @@ _docker_compose_port() { } -_docker_compose_ps() { +function _docker_compose_ps { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help -q" -- "$cur" ) ) @@ -304,7 +304,7 @@ _docker_compose_ps() { } -_docker_compose_pull() { +function _docker_compose_pull { case "$cur" in -*) 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 -*) 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 --timeout|-t) return @@ -346,7 +346,7 @@ _docker_compose_restart() { } -_docker_compose_rm() { +function _docker_compose_rm { case "$cur" in -*) 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 -e) COMPREPLY=( $( compgen -e -- "$cur" ) ) @@ -381,7 +381,7 @@ _docker_compose_run() { } -_docker_compose_scale() { +function _docker_compose_scale { case "$prev" in =) COMPREPLY=("$cur") @@ -404,7 +404,7 @@ _docker_compose_scale() { } -_docker_compose_start() { +function _docker_compose_start { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -416,7 +416,7 @@ _docker_compose_start() { } -_docker_compose_stop() { +function _docker_compose_stop { case "$prev" in --timeout|-t) return @@ -434,7 +434,7 @@ _docker_compose_stop() { } -_docker_compose_unpause() { +function _docker_compose_unpause { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -446,7 +446,7 @@ _docker_compose_unpause() { } -_docker_compose_up() { +function _docker_compose_up { case "$prev" in --timeout|-t) return @@ -464,7 +464,7 @@ _docker_compose_up() { } -_docker_compose_version() { +function _docker_compose_version { case "$cur" in -*) COMPREPLY=( $( compgen -W "--short" -- "$cur" ) ) @@ -473,7 +473,7 @@ _docker_compose_version() { } -_docker_compose() { +function _docker_compose { local previous_extglob_setting=$(shopt -p extglob) shopt -s extglob diff --git a/completions/docker-machine.completion.sh b/completions/docker-machine.completion.sh index c6d0a39..7db9156 100644 --- a/completions/docker-machine.completion.sh +++ b/completions/docker-machine.completion.sh @@ -15,7 +15,7 @@ # . ~/.docker-machine-completion.sh # -_docker_machine_active() { +function _docker_machine_active { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help" -- "${cur}")) else @@ -23,7 +23,7 @@ _docker_machine_active() { fi } -_docker_machine_config() { +function _docker_machine_config { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--swarm --help" -- "${cur}")) else @@ -31,12 +31,12 @@ _docker_machine_config() { fi } -_docker_machine_create() { +function _docker_machine_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}")) } -_docker_machine_env() { +function _docker_machine_env { case "${prev}" in --shell) # What are the options for --shell? @@ -52,7 +52,7 @@ _docker_machine_env() { } # See docker-machine-wrapper.bash for the use command -_docker_machine_use() { +function _docker_machine_use { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--swarm --unset --help" -- "${cur}")) else @@ -60,7 +60,7 @@ _docker_machine_use() { fi } -_docker_machine_inspect() { +function _docker_machine_inspect { case "${prev}" in -f|--format) COMPREPLY=() @@ -75,7 +75,7 @@ _docker_machine_inspect() { esac } -_docker_machine_ip() { +function _docker_machine_ip { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help" -- "${cur}")) else @@ -83,7 +83,7 @@ _docker_machine_ip() { fi } -_docker_machine_kill() { +function _docker_machine_kill { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help" -- "${cur}")) else @@ -91,7 +91,7 @@ _docker_machine_kill() { fi } -_docker_machine_ls() { +function _docker_machine_ls { case "${prev}" in --filter) COMPREPLY=() @@ -102,7 +102,7 @@ _docker_machine_ls() { esac } -_docker_machine_regenerate_certs() { +function _docker_machine_regenerate_certs { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help --force" -- "${cur}")) else @@ -110,7 +110,7 @@ _docker_machine_regenerate_certs() { fi } -_docker_machine_restart() { +function _docker_machine_restart { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help" -- "${cur}")) else @@ -118,7 +118,7 @@ _docker_machine_restart() { fi } -_docker_machine_rm() { +function _docker_machine_rm { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help --force -y" -- "${cur}")) else @@ -127,7 +127,7 @@ _docker_machine_rm() { fi } -_docker_machine_ssh() { +function _docker_machine_ssh { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help" -- "${cur}")) else @@ -135,7 +135,7 @@ _docker_machine_ssh() { fi } -_docker_machine_scp() { +function _docker_machine_scp { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help --recursive" -- "${cur}")) else @@ -146,7 +146,7 @@ _docker_machine_scp() { fi } -_docker_machine_start() { +function _docker_machine_start { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help" -- "${cur}")) else @@ -154,7 +154,7 @@ _docker_machine_start() { fi } -_docker_machine_status() { +function _docker_machine_status { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help" -- "${cur}")) else @@ -162,7 +162,7 @@ _docker_machine_status() { fi } -_docker_machine_stop() { +function _docker_machine_stop { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help" -- "${cur}")) else @@ -170,7 +170,7 @@ _docker_machine_stop() { fi } -_docker_machine_upgrade() { +function _docker_machine_upgrade { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help" -- "${cur}")) else @@ -178,7 +178,7 @@ _docker_machine_upgrade() { fi } -_docker_machine_url() { +function _docker_machine_url { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help" -- "${cur}")) else @@ -186,7 +186,7 @@ _docker_machine_url() { fi } -_docker_machine_version() { +function _docker_machine_version { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help" -- "${cur}")) else @@ -194,7 +194,7 @@ _docker_machine_version() { fi } -_docker_machine_help() { +function _docker_machine_help { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help" -- "${cur}")) else @@ -202,7 +202,7 @@ _docker_machine_help() { fi } -_docker_machine_docker_machine() { +function _docker_machine_docker_machine { if [[ " ${wants_file[*]} " =~ " ${prev} " ]]; then _filedir elif [[ " ${wants_dir[*]} " =~ " ${prev} " ]]; then @@ -214,7 +214,7 @@ _docker_machine_docker_machine() { fi } -_docker_machine() { +function _docker_machine { COMPREPLY=() local commands=(active config create env inspect ip kill ls regenerate-certs restart rm ssh scp start status stop upgrade url version help) diff --git a/completions/docker.completion.sh b/completions/docker.completion.sh index 6b3d8c1..bac3b7c 100644 --- a/completions/docker.completion.sh +++ b/completions/docker.completion.sh @@ -54,11 +54,11 @@ __docker_previous_extglob_setting=$(shopt -p extglob) shopt -s extglob -__docker_q() { +function __docker_q { docker ${host:+-H "$host"} ${config:+--config "$config"} 2>/dev/null "$@" } -__docker_complete_containers_all() { +function __docker_complete_containers_all { local IFS=$'\n' local containers=( $(__docker_q ps -aq --no-trunc) ) if [ "$1" ]; then @@ -70,35 +70,35 @@ __docker_complete_containers_all() { COMPREPLY=( $(compgen -W "${names[*]} ${containers[*]}" -- "$cur") ) } -__docker_complete_containers_running() { +function __docker_complete_containers_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_pauseable() { +function __docker_complete_containers_pauseable { __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_container_names() { +function __docker_complete_container_names { local containers=( $(__docker_q ps -aq --no-trunc) ) local names=( $(__docker_q inspect --format '{{.Name}}' "${containers[@]}") ) names=( "${names[@]#/}" ) # trim off the leading "/" from the container names COMPREPLY=( $(compgen -W "${names[*]}" -- "$cur") ) } -__docker_complete_container_ids() { +function __docker_complete_container_ids { local containers=( $(__docker_q ps -aq) ) COMPREPLY=( $(compgen -W "${containers[*]}" -- "$cur") ) } -__docker_complete_images() { +function __docker_complete_images { local images_args="" case "$DOCKER_COMPLETION_SHOW_IMAGE_IDS" in @@ -132,18 +132,18 @@ __docker_complete_images() { __ltrim_colon_completions "$cur" } -__docker_complete_image_repos() { +function __docker_complete_image_repos { local repos="$(__docker_q images | awk 'NR>1 && $1 != "" { print $1 }')" 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 != "" { print $1; print $1":"$2 }')" COMPREPLY=( $(compgen -W "$reposAndTags" -- "$cur") ) __ltrim_colon_completions "$cur" } -__docker_complete_containers_and_images() { +function __docker_complete_containers_and_images { __docker_complete_containers_all local containers=( "${COMPREPLY[@]}" ) __docker_complete_images @@ -152,7 +152,7 @@ __docker_complete_containers_and_images() { # Returns the names and optionally IDs of networks. # The selection can be narrowed by an optional filter parameter, e.g. 'type=custom' -__docker_networks() { +function __docker_networks { local filter="$1" # By default, only network names are completed. # 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_complete_networks() { +function __docker_complete_networks { 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") ) } -__docker_complete_network_names() { +function __docker_complete_network_names { 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") COMPREPLY=( $(compgen -W "$containers" -- "$cur") ) } -__docker_complete_volumes() { +function __docker_complete_volumes { COMPREPLY=( $(compgen -W "$(__docker_q volume ls -q)" -- "$cur") ) } -__docker_plugins() { +function __docker_plugins { __docker_q info | sed -n "/^Plugins/,/^[^ ]/s/ $1: //p" } -__docker_complete_plugins() { +function __docker_complete_plugins { COMPREPLY=( $(compgen -W "$(__docker_plugins $1)" -- "$cur") ) } -__docker_runtimes() { +function __docker_runtimes { __docker_q info | sed -n 's/^Runtimes: \(.*\)/\1/p' } -__docker_complete_runtimes() { +function __docker_complete_runtimes { COMPREPLY=( $(compgen -W "$(__docker_runtimes)" -- "$cur") ) } @@ -207,7 +207,7 @@ __docker_complete_runtimes() { # An optional first argument `--id|--name` may be used to limit # the output to the IDs or names of matching nodes. This setting takes # precedence over the environment setting. -__docker_nodes() { +function __docker_nodes { local fields='$2' # default: node name only [ "${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 # the value of the optional first argument `--cur`, if given. # Additional filters may be appended, see `__docker_nodes`. -__docker_complete_nodes() { +function __docker_complete_nodes { local current=$cur if [ "$1" = "--cur" ] ; then current="$2" @@ -233,7 +233,7 @@ __docker_complete_nodes() { COMPREPLY=( $(compgen -W "$(__docker_nodes "$@")" -- "$current") ) } -__docker_complete_nodes_plus_self() { +function __docker_complete_nodes_plus_self { __docker_complete_nodes "$@" COMPREPLY+=( self ) } @@ -246,7 +246,7 @@ __docker_complete_nodes_plus_self() { # An optional first argument `--id|--name` may be used to limit # the output to the IDs or names of matching services. This setting takes # precedence over the environment setting. -__docker_services() { +function __docker_services { local fields='$2' # default: service name only [ "${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 # the value of the optional first argument `--cur`, if given. # Additional filters may be appended, see `__docker_services`. -__docker_complete_services() { +function __docker_complete_services { local current=$cur if [ "$1" = "--cur" ] ; then current="$2" @@ -275,7 +275,7 @@ __docker_complete_services() { # 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 # the __docker_complete_XXX functions in cases where you need a suffix. -__docker_append_to_completions() { +function __docker_append_to_completions { 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 # options, e.g. "--option1|-o|--option2" # 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 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) # which matches the extglob given as an argument, returns key. # 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 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 # globs like '--log-level|-l' # 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 counter=$((command_pos + 1)) @@ -361,7 +361,7 @@ __docker_value_of_option() { # Transforms a multiline list of strings into a single line string # with the words separated by "|". # This is used to prepare arguments to __docker_pos_first_nonflag(). -__docker_to_alternatives() { +function __docker_to_alternatives { local parts=( $1 ) local IFS='|' echo "${parts[*]}" @@ -369,7 +369,7 @@ __docker_to_alternatives() { # Transforms a multiline list of options into an extglob pattern # suitable for use in case statements. -__docker_to_extglob() { +function __docker_to_extglob { local extglob=$( __docker_to_alternatives "$1" ) echo "@($extglob)" } @@ -384,7 +384,7 @@ __docker_to_extglob() { # 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 # a match. -__docker_subcommands() { +function __docker_subcommands { local subcommands="$1" local counter=$(($command_pos + 1)) @@ -404,17 +404,17 @@ __docker_subcommands() { } # suppress trailing whitespace -__docker_nospace() { +function __docker_nospace { # compopt is not available in ancient bash versions _omb_util_command_exists compopt && compopt -o nospace } -__docker_complete_resolved_hostname() { +function __docker_complete_resolved_hostname { _omb_util_command_exists host || return 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. COMPREPLY=( $( compgen -W " ALL @@ -459,7 +459,7 @@ __docker_complete_capabilities() { " -- "$cur" ) ) } -__docker_complete_detach-keys() { +function __docker_complete_detach-keys { case "$prev" in --detach-keys) case "$cur" in @@ -478,11 +478,11 @@ __docker_complete_detach-keys() { return 1 } -__docker_complete_isolation() { +function __docker_complete_isolation { COMPREPLY=( $( compgen -W "default hyperv process" -- "$cur" ) ) } -__docker_complete_log_drivers() { +function __docker_complete_log_drivers { COMPREPLY=( $( compgen -W " awslogs etwlogs @@ -497,7 +497,7 @@ __docker_complete_log_drivers() { " -- "$cur" ) ) } -__docker_complete_log_options() { +function __docker_complete_log_options { # see docs/reference/logging/index.md 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" @@ -546,7 +546,7 @@ __docker_complete_log_options() { __docker_nospace } -__docker_complete_log_driver_options() { +function __docker_complete_log_driver_options { local key=$(__docker_map_key_of_current_option '--log-opt') case "$key" in fluentd-async-connect) @@ -623,11 +623,11 @@ __docker_complete_log_driver_options() { return 1 } -__docker_complete_log_levels() { +function __docker_complete_log_levels { COMPREPLY=( $( compgen -W "debug info warn error fatal" -- "$cur" ) ) } -__docker_complete_restart() { +function __docker_complete_restart { case "$prev" in --restart) case "$cur" in @@ -645,7 +645,7 @@ __docker_complete_restart() { # a selection of the available signals that is most likely of interest in the # context of docker containers. -__docker_complete_signals() { +function __docker_complete_signals { local signals=( SIGCONT SIGHUP @@ -660,7 +660,7 @@ __docker_complete_signals() { COMPREPLY=( $( compgen -W "${signals[*]} ${signals[*]#SIG}" -- "$( echo $cur | tr '[:lower:]' '[:upper:]')" ) ) } -__docker_complete_user_group() { +function __docker_complete_user_group { if [[ $cur == *:* ]] ; then COMPREPLY=( $(compgen -g -- "${cur#*:}") ) else @@ -670,7 +670,7 @@ __docker_complete_user_group() { } # global options that may appear after the docker command -_docker_docker() { +function _docker_docker { local boolean_options=" $global_boolean_options --help @@ -704,7 +704,7 @@ _docker_docker() { esac } -_docker_attach() { +function _docker_attach { __docker_complete_detach-keys && return case "$cur" in @@ -720,7 +720,7 @@ _docker_attach() { esac } -_docker_build() { +function _docker_build { local options_with_args=" --build-arg --cgroup-parent @@ -787,7 +787,7 @@ _docker_build() { esac } -_docker_commit() { +function _docker_commit { case "$prev" in --author|-a|--change|-c|--message|-m) return @@ -815,7 +815,7 @@ _docker_commit() { esac } -_docker_cp() { +function _docker_cp { case "$cur" in -*) COMPREPLY=( $( compgen -W "--follow-link -L --help" -- "$cur" ) ) @@ -860,11 +860,11 @@ _docker_cp() { esac } -_docker_create() { +function _docker_create { _docker_run } -_docker_daemon() { +function _docker_daemon { local boolean_options=" $global_boolean_options --disable-legacy-registry @@ -1041,7 +1041,7 @@ _docker_daemon() { esac } -_docker_diff() { +function _docker_diff { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -1055,7 +1055,7 @@ _docker_diff() { esac } -_docker_events() { +function _docker_events { local key=$(__docker_map_key_of_current_option '-f|--filter') case "$key" in container) @@ -1147,7 +1147,7 @@ _docker_events() { esac } -_docker_exec() { +function _docker_exec { __docker_complete_detach-keys && return case "$prev" in @@ -1167,7 +1167,7 @@ _docker_exec() { esac } -_docker_export() { +function _docker_export { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -1181,14 +1181,14 @@ _docker_export() { esac } -_docker_help() { +function _docker_help { local counter=$(__docker_pos_first_nonflag) if [ $cword -eq $counter ]; then COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) ) fi } -_docker_history() { +function _docker_history { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --human=false -H=false --no-trunc --quiet -q" -- "$cur" ) ) @@ -1202,7 +1202,7 @@ _docker_history() { esac } -_docker_images() { +function _docker_images { local key=$(__docker_map_key_of_current_option '--filter|-f') case "$key" in before) @@ -1248,7 +1248,7 @@ _docker_images() { esac } -_docker_import() { +function _docker_import { case "$prev" in --change|-c|--message|-m) return @@ -1274,7 +1274,7 @@ _docker_import() { esac } -_docker_info() { +function _docker_info { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -1282,7 +1282,7 @@ _docker_info() { esac } -_docker_inspect() { +function _docker_inspect { case "$prev" in --format|-f) return @@ -1313,7 +1313,7 @@ _docker_inspect() { esac } -_docker_kill() { +function _docker_kill { case "$prev" in --signal|-s) __docker_complete_signals @@ -1331,7 +1331,7 @@ _docker_kill() { esac } -_docker_load() { +function _docker_load { case "$prev" in --input|-i) _filedir @@ -1346,7 +1346,7 @@ _docker_load() { esac } -_docker_login() { +function _docker_login { case "$prev" in --password|-p|--username|-u) return @@ -1360,7 +1360,7 @@ _docker_login() { esac } -_docker_logout() { +function _docker_logout { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -1368,7 +1368,7 @@ _docker_logout() { esac } -_docker_logs() { +function _docker_logs { case "$prev" in --since|--tail) return @@ -1388,7 +1388,7 @@ _docker_logs() { esac } -_docker_network_connect() { +function _docker_network_connect { local options_with_args=" --alias --ip @@ -1434,7 +1434,7 @@ _docker_network_connect() { esac } -_docker_network_create() { +function _docker_network_create { case "$prev" in --aux-address|--gateway|--internal|--ip-range|--ipam-opt|--ipv6|--opt|-o|--subnet) return @@ -1463,7 +1463,7 @@ _docker_network_create() { esac } -_docker_network_disconnect() { +function _docker_network_disconnect { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -1479,7 +1479,7 @@ _docker_network_disconnect() { esac } -_docker_network_inspect() { +function _docker_network_inspect { case "$prev" in --format|-f) return @@ -1495,7 +1495,7 @@ _docker_network_inspect() { esac } -_docker_network_ls() { +function _docker_network_ls { local key=$(__docker_map_key_of_current_option '--filter|-f') case "$key" in driver) @@ -1534,7 +1534,7 @@ _docker_network_ls() { esac } -_docker_network_rm() { +function _docker_network_rm { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -1544,7 +1544,7 @@ _docker_network_rm() { esac } -_docker_network() { +function _docker_network { local subcommands=" connect create @@ -1565,7 +1565,7 @@ _docker_network() { esac } -_docker_service() { +function _docker_service { local subcommands=" create inspect @@ -1587,11 +1587,11 @@ _docker_service() { esac } -_docker_service_create() { +function _docker_service_create { _docker_service_update } -_docker_service_inspect() { +function _docker_service_inspect { case "$prev" in --format|-f) return @@ -1607,11 +1607,11 @@ _docker_service_inspect() { esac } -_docker_service_list() { +function _docker_service_list { _docker_service_ls } -_docker_service_ls() { +function _docker_service_ls { local key=$(__docker_map_key_of_current_option '--filter|-f') case "$key" in id) @@ -1639,11 +1639,11 @@ _docker_service_ls() { esac } -_docker_service_remove() { +function _docker_service_remove { _docker_service_rm } -_docker_service_rm() { +function _docker_service_rm { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -1653,7 +1653,7 @@ _docker_service_rm() { esac } -_docker_service_scale() { +function _docker_service_scale { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -1666,7 +1666,7 @@ _docker_service_scale() { esac } -_docker_service_tasks() { +function _docker_service_tasks { local key=$(__docker_map_key_of_current_option '--filter|-f') case "$key" in desired-state) @@ -1700,7 +1700,7 @@ _docker_service_tasks() { esac } -_docker_service_update() { +function _docker_service_update { local $subcommand="${words[$subcommand_pos]}" local options_with_args=" @@ -1790,7 +1790,7 @@ _docker_service_update() { esac } -_docker_swarm() { +function _docker_swarm { local subcommands=" init inspect @@ -1810,7 +1810,7 @@ _docker_swarm() { esac } -_docker_swarm_init() { +function _docker_swarm_init { case "$prev" in --auto-accept) COMPREPLY=( $( compgen -W "manager none worker" -- "$cur" ) ) @@ -1834,7 +1834,7 @@ _docker_swarm_init() { esac } -_docker_swarm_inspect() { +function _docker_swarm_inspect { case "$prev" in --format|-f) return @@ -1848,7 +1848,7 @@ _docker_swarm_inspect() { esac } -_docker_swarm_join() { +function _docker_swarm_join { case "$prev" in --ca-hash|--secret) return @@ -1871,7 +1871,7 @@ _docker_swarm_join() { esac } -_docker_swarm_leave() { +function _docker_swarm_leave { case "$cur" in -*) COMPREPLY=( $( compgen -W "--force --help" -- "$cur" ) ) @@ -1879,7 +1879,7 @@ _docker_swarm_leave() { esac } -_docker_swarm_update() { +function _docker_swarm_update { case "$prev" in --auto-accept) COMPREPLY=( $( compgen -W "manager none worker" -- "$cur" ) ) @@ -1897,7 +1897,7 @@ _docker_swarm_update() { esac } -_docker_node() { +function _docker_node { local subcommands=" accept demote @@ -1920,7 +1920,7 @@ _docker_node() { esac } -_docker_node_accept() { +function _docker_node_accept { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -1930,7 +1930,7 @@ _docker_node_accept() { esac } -_docker_node_demote() { +function _docker_node_demote { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -1940,7 +1940,7 @@ _docker_node_demote() { esac } -_docker_node_inspect() { +function _docker_node_inspect { case "$prev" in --format|-f) return @@ -1956,11 +1956,11 @@ _docker_node_inspect() { esac } -_docker_node_list() { +function _docker_node_list { _docker_node_ls } -_docker_node_ls() { +function _docker_node_ls { local key=$(__docker_map_key_of_current_option '--filter|-f') case "$key" in id) @@ -1988,7 +1988,7 @@ _docker_node_ls() { esac } -_docker_node_promote() { +function _docker_node_promote { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -1998,11 +1998,11 @@ _docker_node_promote() { esac } -_docker_node_remove() { +function _docker_node_remove { _docker_node_rm } -_docker_node_rm() { +function _docker_node_rm { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -2012,7 +2012,7 @@ _docker_node_rm() { esac } -_docker_node_tasks() { +function _docker_node_tasks { local key=$(__docker_map_key_of_current_option '--filter|-f') case "$key" in desired-state) @@ -2046,7 +2046,7 @@ _docker_node_tasks() { esac } -_docker_node_update() { +function _docker_node_update { case "$prev" in --availability) COMPREPLY=( $( compgen -W "active drain pause" -- "$cur" ) ) @@ -2071,7 +2071,7 @@ _docker_node_update() { esac } -_docker_pause() { +function _docker_pause { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -2085,7 +2085,7 @@ _docker_pause() { esac } -_docker_port() { +function _docker_port { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -2099,7 +2099,7 @@ _docker_port() { esac } -_docker_ps() { +function _docker_ps { local key=$(__docker_map_key_of_current_option '--filter|-f') case "$key" in ancestor) @@ -2161,7 +2161,7 @@ _docker_ps() { esac } -_docker_pull() { +function _docker_pull { case "$cur" in -*) COMPREPLY=( $( compgen -W "--all-tags -a --disable-content-trust=false --help" -- "$cur" ) ) @@ -2183,7 +2183,7 @@ _docker_pull() { esac } -_docker_push() { +function _docker_push { case "$cur" in -*) COMPREPLY=( $( compgen -W "--disable-content-trust=false --help" -- "$cur" ) ) @@ -2197,7 +2197,7 @@ _docker_push() { esac } -_docker_rename() { +function _docker_rename { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -2211,7 +2211,7 @@ _docker_rename() { esac } -_docker_restart() { +function _docker_restart { case "$prev" in --time|-t) return @@ -2228,7 +2228,7 @@ _docker_restart() { esac } -_docker_rm() { +function _docker_rm { case "$cur" in -*) COMPREPLY=( $( compgen -W "--force -f --help --link -l --volumes -v" -- "$cur" ) ) @@ -2247,7 +2247,7 @@ _docker_rm() { esac } -_docker_rmi() { +function _docker_rmi { case "$cur" in -*) COMPREPLY=( $( compgen -W "--force -f --help --no-prune" -- "$cur" ) ) @@ -2258,7 +2258,7 @@ _docker_rmi() { esac } -_docker_run() { +function _docker_run { local options_with_args=" --add-host --attach -a @@ -2541,7 +2541,7 @@ _docker_run() { esac } -_docker_save() { +function _docker_save { case "$prev" in --output|-o) _filedir @@ -2559,7 +2559,7 @@ _docker_save() { esac } -_docker_search() { +function _docker_search { local key=$(__docker_map_key_of_current_option '--filter|-f') case "$key" in is-automated) @@ -2590,7 +2590,7 @@ _docker_search() { esac } -_docker_start() { +function _docker_start { __docker_complete_detach-keys && return case "$cur" in @@ -2603,7 +2603,7 @@ _docker_start() { esac } -_docker_stats() { +function _docker_stats { case "$cur" in -*) COMPREPLY=( $( compgen -W "--all -a --help --no-stream" -- "$cur" ) ) @@ -2614,7 +2614,7 @@ _docker_stats() { esac } -_docker_stop() { +function _docker_stop { case "$prev" in --time|-t) return @@ -2631,7 +2631,7 @@ _docker_stop() { esac } -_docker_tag() { +function _docker_tag { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -2653,7 +2653,7 @@ _docker_tag() { esac } -_docker_unpause() { +function _docker_unpause { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -2667,7 +2667,7 @@ _docker_unpause() { esac } -_docker_update() { +function _docker_update { local options_with_args=" --blkio-weight --cpu-period @@ -2706,7 +2706,7 @@ _docker_update() { esac } -_docker_top() { +function _docker_top { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -2720,7 +2720,7 @@ _docker_top() { esac } -_docker_version() { +function _docker_version { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -2728,7 +2728,7 @@ _docker_version() { esac } -_docker_volume_create() { +function _docker_volume_create { case "$prev" in --driver|-d) __docker_complete_plugins Volume @@ -2746,7 +2746,7 @@ _docker_volume_create() { esac } -_docker_volume_inspect() { +function _docker_volume_inspect { case "$prev" in --format|-f) return @@ -2763,7 +2763,7 @@ _docker_volume_inspect() { esac } -_docker_volume_ls() { +function _docker_volume_ls { local key=$(__docker_map_key_of_current_option '--filter|-f') case "$key" in dangling) @@ -2797,7 +2797,7 @@ _docker_volume_ls() { esac } -_docker_volume_rm() { +function _docker_volume_rm { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -2808,7 +2808,7 @@ _docker_volume_rm() { esac } -_docker_volume() { +function _docker_volume { local subcommands=" create inspect @@ -2827,7 +2827,7 @@ _docker_volume() { esac } -_docker_wait() { +function _docker_wait { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -2838,7 +2838,7 @@ _docker_wait() { esac } -_docker() { +function _docker { local previous_extglob_setting=$(shopt -p extglob) shopt -s extglob diff --git a/completions/drush.completion.sh b/completions/drush.completion.sh index b3232e0..8487af5 100644 --- a/completions/drush.completion.sh +++ b/completions/drush.completion.sh @@ -9,7 +9,7 @@ # Ensure drush is available. _omb_util_command_exists drush || return -__drush_ps1() { +function __drush_ps1 { f="${TMPDIR:-/tmp/}/drush-env/drush-drupal-site-$$" if [ -f $f ] then @@ -23,7 +23,7 @@ __drush_ps1() { # Completion function, uses the "drush complete" command to retrieve # 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 # need to retain spaces (or not) after completions. local IFS=$'\n' diff --git a/completions/gem.completion.sh b/completions/gem.completion.sh index ea0973b..8cb8657 100644 --- a/completions/gem.completion.sh +++ b/completions/gem.completion.sh @@ -1,7 +1,7 @@ #! bash oh-my-bash.module # Completion for gem -_installcomp() { +function _installcomp { if [ -z "$REMOTE_GEMS" ] then REMOTE_GEMS=( $(gem list --remote --no-versions | tr '\n' ' ') ) @@ -11,7 +11,7 @@ _installcomp() { COMPREPLY=( $(compgen -W "${REMOTE_GEMS[*]}" -- $cur) ) } -_uninstallcomp() { +function _uninstallcomp { if [ -z "$LOCAL_GEMS" ] then LOCAL_GEMS=( $(gem list --no-versions | sed 's/\*\*\* LOCAL GEMS \*\*\*//' | tr '\n' ' ') ) @@ -21,7 +21,7 @@ _uninstallcomp() { COMPREPLY=( $(compgen -W "${LOCAL_GEMS[*]}" -- $cur) ) } -_gem() { +function _gem { local cur=${COMP_WORDS[COMP_CWORD]} local prev=${COMP_WORDS[COMP_CWORD-1]} case $prev in diff --git a/completions/gh.completion.sh b/completions/gh.completion.sh index 58b902a..175fda4 100644 --- a/completions/gh.completion.sh +++ b/completions/gh.completion.sh @@ -9,7 +9,7 @@ if _omb_util_function_exists _git; then sed 's/__git_list_all_commands/__git_list_all_commands_without_hub/')" # Wrap the 'list_all_commands' function with extra hub commands - __git_list_all_commands() { + function __git_list_all_commands { cat <<-EOF alias pull-request @@ -33,7 +33,7 @@ EOF ########################## # hub alias [-s] [SHELL] - _git_alias() { + function _git_alias { local i c=2 s=-s sh shells="bash zsh sh ksh csh fish" while [ $c -lt $cword ]; do i="${words[c]}" @@ -56,7 +56,7 @@ EOF } # hub browse [-u] [--|[USER/]REPOSITORY] [SUBPAGE] - _git_browse() { + function _git_browse { local i c=2 u=-u repo subpage local subpages_="commits issues tree wiki pulls branches stargazers contributors network network/ graphs graphs/" @@ -97,7 +97,7 @@ EOF } # 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 while [ $c -gt 1 ]; do i="${words[c]}" @@ -181,7 +181,7 @@ EOF } # hub create [NAME] [-p] [-d DESCRIPTION] [-h HOMEPAGE] - _git_create() { + function _git_create { local i c=2 name repo flags="-p -d -h" while [ $c -lt $cword ]; do i="${words[c]}" @@ -213,7 +213,7 @@ EOF } # hub fork [--no-remote] - _git_fork() { + function _git_fork { local i c=2 remote=yes while [ $c -lt $cword ]; do i="${words[c]}" @@ -230,7 +230,7 @@ EOF } # hub pull-request [-f] [-m |-F |-i |] [-b ] [-h ] - _git_pull_request() { + function _git_pull_request { local i c=2 flags="-f -m -F -i -b -h" while [ $c -lt $cword ]; do i="${words[c]}" @@ -272,7 +272,7 @@ EOF # __hub_github_user [HOST] # 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" - __hub_github_user() { + function __hub_github_user { if [ -n "$GITHUB_USER" ]; then echo $GITHUB_USER return @@ -310,7 +310,7 @@ EOF # \o owner # escaped characters (\n, \t ...etc) work # If omitted, prints all github repos in the format of "remote:owner/repo" - __hub_github_repos() { + function __hub_github_repos { local f format=$1 if [ -z "$(__gitdir)" ]; then return @@ -329,7 +329,7 @@ EOF # __hub_heads # List all local "branch", and remote "owner/repo:branch" - __hub_heads() { + function __hub_heads { local i remote repo branch dir=$(__gitdir) if [ -d "$dir" ]; then command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ @@ -348,7 +348,7 @@ EOF # __hub_revlist [REMOTE] # List all tags, and branches under REMOTE, without the "remote/" prefix # REMOTE - Remote name to search branches from. Default is "origin" - __hub_revlist() { + function __hub_revlist { local i remote=${1:-origin} dir=$(__gitdir) if [ -d "$dir" ]; then command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ diff --git a/completions/git.completion.bash b/completions/git.completion.bash index cbde3ee..ca9f9a4 100644 --- a/completions/git.completion.bash +++ b/completions/git.completion.bash @@ -1,6 +1,6 @@ #! bash oh-my-bash.module # bash completion support for Git. -_omb_completion_git_initialize() { +function _omb_completion_git_initialize { if ! _omb_util_function_exists __gitdir; then local git_paths path IFS=$'\n' read -r -d '' -a git_paths <<< "$(type -aP git)" diff --git a/completions/go.completion.sh b/completions/go.completion.sh index fc1e25f..a6cb0f8 100644 --- a/completions/go.completion.sh +++ b/completions/go.completion.sh @@ -10,10 +10,10 @@ complete -f -X '!*.6' 6l complete -f -X '!*.5' 5l complete -f -X '!*.go' 8g 6g 5g gofmt gccgo -_go_clear_cache() { +function _go_clear_cache { unset _go_imports } -_go_importpath_cache() { +function _go_importpath_cache { if [ -z "$_go_imports" ]; then _go_imports=$(go list all 2>/dev/null) export _go_imports diff --git a/completions/hub.completion.sh b/completions/hub.completion.sh index 1393587..7c76bde 100644 --- a/completions/hub.completion.sh +++ b/completions/hub.completion.sh @@ -14,7 +14,7 @@ if _omb_util_function_exists _git; then sed 's/__git_list_all_commands/__git_list_all_commands_without_hub/')" # Wrap the 'list_all_commands' function with extra hub commands - __git_list_all_commands() { + function __git_list_all_commands { cat <<-EOF alias pull-request @@ -35,7 +35,7 @@ EOF ########################## # hub alias [-s] [SHELL] - _git_alias() { + function _git_alias { local i c=2 s=-s sh shells="bash zsh sh ksh csh fish" while [ $c -lt $cword ]; do i="${words[c]}" @@ -58,7 +58,7 @@ EOF } # hub browse [-u] [--|[USER/]REPOSITORY] [SUBPAGE] - _git_browse() { + function _git_browse { local i c=2 u=-u repo subpage local subpages_="commits issues tree wiki pulls branches stargazers contributors network network/ graphs graphs/" @@ -99,7 +99,7 @@ EOF } # 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 while [ $c -gt 1 ]; do i="${words[c]}" @@ -183,7 +183,7 @@ EOF } # hub create [NAME] [-p] [-d DESCRIPTION] [-h HOMEPAGE] - _git_create() { + function _git_create { local i c=2 name repo flags="-p -d -h" while [ $c -lt $cword ]; do i="${words[c]}" @@ -215,7 +215,7 @@ EOF } # hub fork [--no-remote] - _git_fork() { + function _git_fork { local i c=2 remote=yes while [ $c -lt $cword ]; do i="${words[c]}" @@ -232,7 +232,7 @@ EOF } # hub pull-request [-f] [-m |-F |-i |] [-b ] [-h ] [-a ] [-M ] [-l ] - _git_pull_request() { + function _git_pull_request { local i c=2 flags="-f -m -F -i -b -h -a -M -l" while [ $c -lt $cword ]; do i="${words[c]}" @@ -274,7 +274,7 @@ EOF # __hub_github_user [HOST] # 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" - __hub_github_user() { + function __hub_github_user { if [ -n "$GITHUB_USER" ]; then echo $GITHUB_USER return @@ -312,7 +312,7 @@ EOF # \o owner # escaped characters (\n, \t ...etc) work # If omitted, prints all github repos in the format of "remote:owner/repo" - __hub_github_repos() { + function __hub_github_repos { local f format=$1 if [ -z "$(__gitdir)" ]; then return @@ -331,7 +331,7 @@ EOF # __hub_heads # List all local "branch", and remote "owner/repo:branch" - __hub_heads() { + function __hub_heads { local i remote repo branch dir=$(__gitdir) if [ -d "$dir" ]; then command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ @@ -350,7 +350,7 @@ EOF # __hub_revlist [REMOTE] # List all tags, and branches under REMOTE, without the "remote/" prefix # REMOTE - Remote name to search branches from. Default is "origin" - __hub_revlist() { + function __hub_revlist { local i remote=${1:-origin} dir=$(__gitdir) if [ -d "$dir" ]; then command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ diff --git a/completions/jboss7.completion.sh b/completions/jboss7.completion.sh index 943b64b..b6cf44d 100644 --- a/completions/jboss7.completion.sh +++ b/completions/jboss7.completion.sh @@ -7,7 +7,7 @@ -_serverProfiles(){ +function _serverProfiles { if [[ $COMP_WORDS == *standalone.sh* ]] then serverdir="../standalone/configuration/" @@ -33,7 +33,7 @@ _serverProfiles(){ fi } -_bindingAddress(){ +function _bindingAddress { # from /etc/bash_completion.d/ssh COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \ "0.0.0.0 $( PATH="$PATH:/sbin" ifconfig -a | \ @@ -42,7 +42,7 @@ _bindingAddress(){ -- "$cur" ) ) } -_jboss(){ +function _jboss { local cur prev words cword COMPREPLY=() diff --git a/completions/projects.completion.sh b/completions/projects.completion.sh index 7979ea5..aa5b29b 100644 --- a/completions/projects.completion.sh +++ b/completions/projects.completion.sh @@ -1,5 +1,5 @@ #! bash oh-my-bash.module -_pj() { +function _pj { [ -z "$PROJECT_PATHS" ] && return shift [ "$1" == "open" ] && shift diff --git a/completions/rake.completion.sh b/completions/rake.completion.sh index 440028a..04048cc 100644 --- a/completions/rake.completion.sh +++ b/completions/rake.completion.sh @@ -3,7 +3,7 @@ export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/} -_rakecomplete() { +function _rakecomplete { if [ -f Rakefile ]; then recent=`ls -t .rake_tasks~ Rakefile **/*.rake 2> /dev/null | head -n 1` if [[ $recent != '.rake_tasks~' ]]; then diff --git a/completions/salt.completion.sh b/completions/salt.completion.sh index 511b73b..ce94c92 100644 --- a/completions/salt.completion.sh +++ b/completions/salt.completion.sh @@ -13,7 +13,7 @@ # TODO: is it ok to use '--timeout 2' ? -_salt_get_grains(){ +function _salt_get_grains { if [ "$1" = 'local' ] ; then salt-call --out=txt -- grains.ls | sed 's/^.*\[//' | tr -d ",']" |sed 's:\([a-z0-9]\) :\1\: :g' else @@ -21,7 +21,7 @@ _salt_get_grains(){ fi } -_salt_get_grain_values(){ +function _salt_get_grain_values { if [ "$1" = 'local' ] ; then salt-call --out=txt -- grains.item $1 |sed 's/^\S*:\s//' |grep -v '^\s*$' else @@ -30,7 +30,7 @@ _salt_get_grain_values(){ } -_salt(){ +function _salt { local cur prev opts pprev ppprev COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" @@ -128,7 +128,7 @@ _salt(){ complete -F _salt salt -_saltkey(){ +function _saltkey { local cur prev opts prev pprev COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" @@ -204,7 +204,7 @@ _saltkey(){ complete -F _saltkey salt-key -_saltcall(){ +function _saltcall { local cur prev opts pprev ppprev COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" @@ -257,7 +257,7 @@ _saltcall(){ complete -F _saltcall salt-call -_saltcp(){ +function _saltcp { local cur prev opts target prefpart postpart helper filt pprev ppprev COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" diff --git a/completions/sdkman.completion.sh b/completions/sdkman.completion.sh index e7d3a90..60f280a 100644 --- a/completions/sdkman.completion.sh +++ b/completions/sdkman.completion.sh @@ -40,7 +40,7 @@ _sdkman_complete() return 0 } -_sdkman_candidate_versions(){ +function _sdkman_candidate_versions { CANDIDATE_LOCAL_VERSIONS=$(__sdkman_cleanup_local_versions $1) 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 echo $CSV | tr ',' ' ' diff --git a/completions/ssh.completion.sh b/completions/ssh.completion.sh index b83e6e3..6beb554 100644 --- a/completions/ssh.completion.sh +++ b/completions/ssh.completion.sh @@ -3,7 +3,7 @@ export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/} -_sshcomplete() { +function _sshcomplete { local CURRENT_PROMPT="${COMP_WORDS[COMP_CWORD]}" if [[ ${CURRENT_PROMPT} == *@* ]] ; then local OPTIONS="-P ${CURRENT_PROMPT/@*/}@ -- ${CURRENT_PROMPT/*@/}" diff --git a/completions/test_kitchen.completion.sh b/completions/test_kitchen.completion.sh index 83f50bf..a1efe2b 100644 --- a/completions/test_kitchen.completion.sh +++ b/completions/test_kitchen.completion.sh @@ -1,5 +1,5 @@ #! bash oh-my-bash.module -__kitchen_instance_list () { +function __kitchen_instance_list { # cache to .kitchen.list.yml if [[ .kitchen.yml -nt .kitchen.list.yml || .kitchen.local.yml -nt .kitchen.list.yml ]]; then # update list if config has updated @@ -8,7 +8,7 @@ __kitchen_instance_list () { cat .kitchen.list.yml } -__kitchen_options () { +function __kitchen_options { cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" COMPREPLY=() diff --git a/completions/tmux.completion.sh b/completions/tmux.completion.sh index 9b6788f..8031515 100644 --- a/completions/tmux.completion.sh +++ b/completions/tmux.completion.sh @@ -57,7 +57,7 @@ function _tmux_complete_window() { COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "${sessions}" -- "${cur}") ) } -_tmux() { +function _tmux { local cur prev local i cmd cmd_index option option_index local opts="" diff --git a/completions/vagrant.completion.sh b/completions/vagrant.completion.sh index e0d0d9a..9368738 100644 --- a/completions/vagrant.completion.sh +++ b/completions/vagrant.completion.sh @@ -23,7 +23,7 @@ # SOFTWARE. -__pwdln() { +function __pwdln { pwdmod="${PWD}/" itr=0 until [[ -z "$pwdmod" ]];do @@ -33,7 +33,7 @@ __pwdln() { echo -n $(($itr-1)) } -__vagrantinvestigate() { +function __vagrantinvestigate { if [ -f "${PWD}/.vagrant" -o -d "${PWD}/.vagrant" ];then echo "${PWD}/.vagrant" return 0 @@ -50,7 +50,7 @@ __vagrantinvestigate() { return 1 } -_vagrant() { +function _vagrant { cur="${COMP_WORDS[COMP_CWORD]}" 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" diff --git a/completions/virtualbox.completion.sh b/completions/virtualbox.completion.sh index 3ad3377..7a54ebf 100644 --- a/completions/virtualbox.completion.sh +++ b/completions/virtualbox.completion.sh @@ -1,10 +1,10 @@ #! bash oh-my-bash.module -_vboxmanage_realopts() { +function _vboxmanage_realopts { echo $(vboxmanage|grep -i vboxmanage|cut -d' ' -f2|grep '\['|tr -s '[\[\|\]\n' ' ') echo " " } -__vboxmanage_startvm() { +function __vboxmanage_startvm { RUNNING=$(vboxmanage list runningvms | cut -d' ' -f1 | tr -d '"') TOTAL=$(vboxmanage list vms | cut -d' ' -f1 | tr -d '"') @@ -21,7 +21,7 @@ __vboxmanage_startvm() { echo $AVAILABLE } -__vboxmanage_list() { +function __vboxmanage_list { INPUT=$(vboxmanage list | tr -s '[\[\]\|\n]' ' ' | cut -d' ' -f4-) PRUNED="" @@ -40,7 +40,7 @@ __vboxmanage_list() { } -__vboxmanage_list_vms() { +function __vboxmanage_list_vms { VMS="" if [ "x$1" == "x" ]; then SEPARATOR=" " @@ -56,7 +56,7 @@ __vboxmanage_list_vms() { echo $VMS } -__vboxmanage_list_runningvms() { +function __vboxmanage_list_runningvms { VMS="" if [ "$1" == "" ]; then SEPARATOR=" " @@ -73,7 +73,7 @@ __vboxmanage_list_runningvms() { } -__vboxmanage_controlvm() { +function __vboxmanage_controlvm { echo "pause resume reset poweroff savestate acpipowerbutton" echo "acpisleepbutton keyboardputscancode guestmemoryballoon" echo "gueststatisticsinterval usbattach usbdetach vrde vrdeport" @@ -93,7 +93,7 @@ __vboxmanage_controlvm() { } -__vboxmanage_default() { +function __vboxmanage_default { realopts=$(_vboxmanage_realopts) opts=$realopts$(vboxmanage | grep -i vboxmanage | cut -d' ' -f2 | grep -v '\[' | sort | uniq) pruned="" @@ -144,7 +144,7 @@ __vboxmanage_default() { return 0 } -_vboxmanage() { +function _vboxmanage { # vboxmanage | grep -i vboxmanage | cut -d' ' -f2 | sort | uniq local cur p1 p2 p3 p4 opts COMPREPLY=() diff --git a/lib/base.sh b/lib/base.sh index 47f500d..8f43a8b 100644 --- a/lib/base.sh +++ b/lib/base.sh @@ -34,32 +34,32 @@ # 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) # displays paginated result with colored search terms and two lines surrounding each hit. # 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 () { /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 () { +function quiet { "$*" &> /dev/null & } # lsgrep: search through directory contents with grep # ------------------------------------------------------------ # shellcheck disable=SC2010 -lsgrep () { ls | grep "$*" ; } +function lsgrep { ls | grep "$*" ; } # banish-cookies: redirect .adobe and .macromedia files to /dev/null # ------------------------------------------------------------ -banish-cookies () { +function banish-cookies { rm -r ~/.macromedia ~/.adobe ln -s /dev/null ~/.adobe ln -s /dev/null ~/.macromedia @@ -67,7 +67,7 @@ banish-cookies () { # show the n most used commands. defaults to 10 # ------------------------------------------------------------ -hstats() { +function hstats { if [[ $# -lt 1 ]]; then NUM=10 else @@ -81,11 +81,11 @@ hstats() { # 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 () { +function extract { if [ -f "$1" ] ; then case "$1" in *.tar.bz2) tar xjf "$1" ;; @@ -108,7 +108,7 @@ extract () { # buf: back up file with timestamp # --------------------------------------------------------- -buf () { +function buf { local filename filetime filename=$1 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() { +function del { mkdir -p /tmp/.trash && mv "$@" /tmp/.trash; } # mkiso: creates iso from current dir in the parent dir (unless defined) # --------------------------------------------------------- -mkiso () { +function mkiso { if _omb_util_command_exists mkisofs; then if [ -z ${1+x} ]; then local isoname=${PWD##*/} @@ -159,12 +159,12 @@ mkiso () { # 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 -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 -ffe () { /usr/bin/find . -name '*'"$@" ; } # ffe: Find file whose name ends with a given string -bigfind() { +function ffe { /usr/bin/find . -name '*'"$@" ; } # ffe: Find file whose name ends with a given string +function bigfind { if [[ $# -lt 1 ]]; then echo_warn "Usage: bigfind DIRECTORY" return @@ -183,11 +183,11 @@ bigfind() { # 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 # ----------------------------------------------------- -findPid () { lsof -t -c "$@" ; } +function findPid { lsof -t -c "$@" ; } # 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 () { +function ips { if _omb_util_command_exists ifconfig then ifconfig | awk '/inet /{ print $2 }' @@ -210,20 +210,20 @@ ips () { # 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' } # myip: displays your ip address, as seen by the Internet # ------------------------------------------------------------------- -myip () { +function myip { res=$(curl -s checkip.dyndns.org | grep -Eo '[0-9\.]+') echo -e "Your public IP is: ${_omb_term_bold_green} $res ${_omb_term_normal}" } # ii: display useful host related informaton # ------------------------------------------------------------------- -ii() { +function ii { echo -e "\\nYou are logged on ${_omb_term_brown}$HOST" echo -e "\\nAdditionnal information:$NC " ; uname -a 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() { +function batch_chmod { echo -ne "${_omb_term_bold_navy}Applying 0755 permission for all directories..." (find . -type d -print0 | xargs -0 chmod 0755) & spinner @@ -256,7 +256,7 @@ batch_chmod() { # usage: disk usage per directory, in Mac OS X and Linux # ------------------------------------------------------------------- -usage () { +function usage { if [ "$(uname)" = "Darwin" ]; then if [ -n "$1" ]; then du -hd 1 "$1" @@ -274,7 +274,7 @@ usage () { # pickfrom: picks random line from file # ------------------------------------------------------------------- -pickfrom () { +function pickfrom { local file=$1 [ -z "$file" ] && reference "$FUNCNAME" && return length=$(wc -l < "$file") @@ -290,7 +290,7 @@ pickfrom () { # shellcheck disable=SC2005 # shellcheck disable=SC2034 # shellcheck disable=SC2086 -passgen () { +function passgen { local i pass length=${1:-4} pass=$(echo $(for i in $(eval echo "{1..$length}"); do pickfrom /usr/share/dict/words; done)) echo "With spaces (easier to memorize): $pass" @@ -307,11 +307,11 @@ passgen () { # 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 () { /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" ; } diff --git a/lib/grep.sh b/lib/grep.sh index a90f5fe..76d5412 100644 --- a/lib/grep.sh +++ b/lib/grep.sh @@ -1,7 +1,7 @@ #! bash oh-my-bash.module # is x grep argument available? -_omb_grep_flag_available() { +function _omb_grep_flag_available { echo | grep $1 "" >/dev/null 2>&1 } diff --git a/lib/mo.sh b/lib/mo.sh index 3494165..fbaa1b0 100644 --- a/lib/mo.sh +++ b/lib/mo.sh @@ -47,7 +47,7 @@ # a help message. # # Returns nothing. -mo() { +function mo { # This function executes in a subshell so IFS is reset. # Namespace this variable so we don't conflict with desired values. local moContent f2source files doubleHyphens @@ -120,7 +120,7 @@ mo() { # $4 - If -z, do standalone tag processing before finishing # # Returns nothing. -_moFindEndTag() { +function _moFindEndTag { local content remaining scanned standaloneBytes tag #: Find open tags @@ -191,7 +191,7 @@ _moFindEndTag() { # $3 - Needle # # Returns nothing. -_moFindString() { +function _moFindString { local pos string string=${2%%$3*} @@ -207,7 +207,7 @@ _moFindString() { # $3 - Desired variable name # # Returns nothing. -_moFullTagName() { +function _moFullTagName { if [[ -z "${2-}" ]] || [[ "$2" == *.* ]]; then local "$1" && _moIndirect "$1" "$3" else @@ -223,7 +223,7 @@ _moFullTagName() { # $2-@ - File names (optional) # # Returns nothing. -_moGetContent() { +function _moGetContent { local content filename target target=$1 @@ -251,7 +251,7 @@ _moGetContent() { # $3 - The string to reindent # # Returns nothing. -_moIndentLines() { +function _moIndentLines { local content fragment len posN posR result trimmed result="" @@ -315,7 +315,7 @@ _moIndentLines() { # echo "$dest" # writes "the value" # # Returns nothing. -_moIndirect() { +function _moIndirect { unset -v "$1" printf -v "$1" '%s' "$2" } @@ -336,7 +336,7 @@ _moIndirect() { # echo "${dest[@]}" # writes "one two three" # # Returns nothing. -_moIndirectArray() { +function _moIndirectArray { unset -v "$1" # IFS must be set to a string containing space or unset in order for @@ -365,7 +365,7 @@ _moIndirectArray() { # fi # # 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. local moTestResult @@ -395,7 +395,7 @@ _moIsArray() { # fi # # Returns 0 if the name is a function, 1 otherwise. -_moIsFunction() { +function _moIsFunction { local functionList functionName functionList=$(declare -F) @@ -431,7 +431,7 @@ _moIsFunction() { # echo "${before:0:${RESULT_ARRAY[0]}}...${after:${RESULT_ARRAY[1]}}" # # Returns nothing. -_moIsStandalone() { +function _moIsStandalone { local afterTrimmed beforeTrimmed char _moTrimChars beforeTrimmed "$2" false true " " $'\t' @@ -466,7 +466,7 @@ _moIsStandalone() { # $3-$* - Elements to join # # Returns nothing. -_moJoin() { +function _moJoin { local joiner part result target target=$1 @@ -488,7 +488,7 @@ _moJoin() { # $2 - Filename to load # # Returns nothing. -_moLoadFile() { +function _moLoadFile { local content len # The subshell removes any trailing newlines. We forcibly add @@ -511,7 +511,7 @@ _moLoadFile() { # $3-@ - Names to insert into the parsed content # # Returns nothing. -_moLoop() { +function _moLoop { local content context contextBase content=$1 @@ -533,7 +533,7 @@ _moLoop() { # $3 - true when no content before this, false otherwise # # Returns nothing. -_moParse() { +function _moParse { # Keep naming variables mo* here to not overwrite needed variables # used in the string replacements local moBlock moContent moCurrent moIsBeginning moTag @@ -669,7 +669,7 @@ _moParse() { # $6 - Current context name # # Returns nothing. -_moPartial() { +function _moPartial { # Namespace variables here to prevent conflicts. local moContent moFilename moIndent moPartial moStandalone @@ -713,7 +713,7 @@ _moPartial() { # $2 - Current context # # Returns nothing. -_moShow() { +function _moShow { # Namespace these variables local moJoined moNameParts @@ -747,7 +747,7 @@ _moShow() { # $4 - Ending delimiter (optional) # # Returns nothing. -_moSplit() { +function _moSplit { local pos result result=( "$2" ) @@ -784,7 +784,7 @@ _moSplit() { # $5 - true/false: is this the beginning of the content? # # Returns nothing. -_moStandaloneAllowed() { +function _moStandaloneAllowed { local bytes if _moIsStandalone bytes "$2" "$4" "$5"; then @@ -807,7 +807,7 @@ _moStandaloneAllowed() { # $4 - Content after the tag # # Returns nothing. -_moStandaloneDenied() { +function _moStandaloneDenied { echo -n "$2" 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 # is set, this returns 1 if the name is "false". -_moTest() { +function _moTest { # Test for functions _moIsFunction "$1" && return 0 @@ -857,7 +857,7 @@ _moTest() { # $5-@ - Characters to trim # # Returns nothing. -_moTrimChars() { +function _moTrimChars { local back current front last target varName target=$1 @@ -886,7 +886,7 @@ _moTrimChars() { # $2 - The string # # Returns nothing. -_moTrimWhitespace() { +function _moTrimWhitespace { local result _moTrimChars result "$2" true true $'\r' $'\n' $'\t' " " @@ -902,7 +902,7 @@ _moTrimWhitespace() { # $1 - Filename that has the help message # # Returns nothing. -_moUsage() { +function _moUsage { grep '^#/' "${MO_ORIGINAL_COMMAND}" | cut -c 4- } diff --git a/lib/omb-deprecate.sh b/lib/omb-deprecate.sh index d95405f..60f342c 100644 --- a/lib/omb-deprecate.sh +++ b/lib/omb-deprecate.sh @@ -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 # "fpath" directories, which are not supported by Bash. -is_plugin() { +function is_plugin { local base_dir=$1 name=$2 [[ -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 [[ -f $base_dir/completions/$name/$name.completion.sh ]] } -is_alias() { +function is_alias { local base_dir=$1 name=$2 [[ -f $base_dir/aliases/$name/$name.aliases.sh ]] } diff --git a/lib/spinner.sh b/lib/spinner.sh index 92b9a09..54fc87e 100644 --- a/lib/spinner.sh +++ b/lib/spinner.sh @@ -12,7 +12,7 @@ # # This spinner is used when there is a terminal. -term_spinner() { +function term_spinner { local pid=$! local delay=0.1 local spinstr='|/-\' @@ -26,7 +26,7 @@ term_spinner() { printf " \b\b\b\b" } -no_term_spinner() { +function no_term_spinner { local pid=$! local delay=0.1 local spinstr='|/-\' @@ -37,7 +37,7 @@ no_term_spinner() { echo " ✓ " } -spinner() { +function spinner { if [[ -z "$TERM" ]]; then no_term_spinner else diff --git a/lib/utils.sh b/lib/utils.sh index b6e8c77..7c98986 100644 --- a/lib/utils.sh +++ b/lib/utils.sh @@ -96,27 +96,27 @@ function _omb_util_defun_print { # if ((_omb_bash_version >= 40000)); then - _omb_util_command_exists() { + function _omb_util_command_exists { type -t -- "$@" &>/dev/null # bash-4.0 } - _omb_util_binary_exists() { + function _omb_util_binary_exists { type -P -- "$@" &>/dev/null # bash-4.0 } else - _omb_util_command_exists() { + function _omb_util_command_exists { while (($#)); do type -t -- "$1" &>/dev/null || return 1 shift done } - _omb_util_binary_exists() { + function _omb_util_binary_exists { while (($#)); do type -P -- "$1" &>/dev/null || return 1 shift done } fi -_omb_util_function_exists() { +function _omb_util_function_exists { 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 # supports them. These colors are intended to be used with `echo` # -_omb_term_color_initialize() { +function _omb_term_color_initialize { local name local -a normal_colors=(black brown green olive navy purple teal silver) local -a bright_colors=(gray red lime yellow blue magenta cyan white) @@ -221,14 +221,14 @@ _omb_term_color_initialize # # Headers and Logging # -_omb_log_header() { printf "\n${_omb_term_bold}${_omb_term_violet}========== %s ==========${_omb_term_reset}\n" "$@"; } -_omb_log_arrow() { printf "➜ %s\n" "$@"; } -_omb_log_success() { printf "${_omb_term_green}✔ %s${_omb_term_reset}\n" "$@"; } -_omb_log_error() { printf "${_omb_term_brown}✖ %s${_omb_term_reset}\n" "$@"; } -_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" "$@"; } -_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_header { printf "\n${_omb_term_bold}${_omb_term_violet}========== %s ==========${_omb_term_reset}\n" "$@"; } +function _omb_log_arrow { printf "➜ %s\n" "$@"; } +function _omb_log_success { printf "${_omb_term_green}✔ %s${_omb_term_reset}\n" "$@"; } +function _omb_log_error { printf "${_omb_term_brown}✖ %s${_omb_term_reset}\n" "$@"; } +function _omb_log_warning { printf "${_omb_term_olive}➜ %s${_omb_term_reset}\n" "$@"; } +function _omb_log_underline { printf "${_omb_term_underline}${_omb_term_bold}%s${_omb_term_reset}\n" "$@"; } +function _omb_log_bold { printf "${_omb_term_bold}%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 @@ -241,14 +241,14 @@ _omb_log_note() { printf "${_omb_term_underline}${_omb_term_bold}${_omb_ter # some other action # fi # -seek_confirmation() { +function seek_confirmation { printf "\\n${_omb_term_bold}%s${_omb_term_reset}" "$@" read -p " (y/n) " -n 1 printf "\\n" } # Test whether the result of an 'ask' is a confirmation -is_confirmed() { +function is_confirmed { [[ $REPLY =~ ^[Yy]$ ]] } @@ -257,7 +257,7 @@ is_confirmed() { # $1 = OS to test # Usage: if is_os 'darwin'; then # -is_os() { +function is_os { [[ $OSTYPE == $1* ]] } @@ -266,7 +266,7 @@ is_os() { # Usage: pushover "Title Goes Here" "Message Goes Here" # Credit: http://ryonsherman.blogspot.com/2012/10/shell-script-to-send-pushover.html # -pushover () { +function pushover { PUSHOVERURL="https://api.pushover.net/1/messages.json" API_KEY=$PUSHOVER_API_KEY USER_KEY=$PUSHOVER_USER_KEY @@ -286,9 +286,9 @@ pushover () { ## @fn _omb_util_get_shopt optnames... if ((_omb_bash_version >= 40100)); then - _omb_util_get_shopt() { shopt=$BASHOPTS; } + function _omb_util_get_shopt { shopt=$BASHOPTS; } else - _omb_util_get_shopt() { + function _omb_util_get_shopt { shopt= local opt for opt; do @@ -300,7 +300,7 @@ else fi _omb_util_unload_hook=() -_omb_util_unload() { +function _omb_util_unload { local hook for hook in "${_omb_util_unload_hook[@]}"; do eval -- "$hook" @@ -311,7 +311,7 @@ _omb_util_original_PS1=$PS1 _omb_util_unload_hook+=('PS1=$_omb_util_original_PS1') _omb_util_prompt_command=() -_omb_util_prompt_command_hook() { +function _omb_util_prompt_command_hook { local status=$? lastarg=$_ hook for hook in "${_omb_util_prompt_command[@]}"; do _omb_util_setexit "$status" "$lastarg" @@ -323,7 +323,7 @@ _omb_util_prompt_command_hook() { _omb_util_unload_hook+=('_omb_util_prompt_command=()') : "${_omb_util_prompt_command_setup=}" -_omb_util_add_prompt_command() { +function _omb_util_add_prompt_command { local other for other in "${_omb_util_prompt_command[@]}"; do [[ $1 == "$other" ]] && return 0 @@ -363,7 +363,7 @@ _omb_util_add_prompt_command() { fi } -_omb_util_glob_expand() { +function _omb_util_glob_expand { local set=$- shopt gignore=$GLOBIGNORE _omb_util_get_shopt failglob nullglob extglob @@ -389,7 +389,7 @@ _omb_util_glob_expand() { return 0 } -_omb_util_alias() { +function _omb_util_alias { case ${OMB_DEFAULT_ALIASES:-enable} in (disable) return 0 ;; (check) alias -- "${1%%=*}" &>/dev/null && return 0 ;; diff --git a/oh-my-bash.sh b/oh-my-bash.sh index 2068cc1..830e47a 100644 --- a/oh-my-bash.sh +++ b/oh-my-bash.sh @@ -49,7 +49,7 @@ if [[ ! ${OSH_CACHE_DIR-} ]]; then fi _omb_module_loaded= -_omb_module_require() { +function _omb_module_require { local status=0 local -a files=() while (($#)); do @@ -95,11 +95,11 @@ _omb_module_require() { return "$status" } -_omb_module_require_lib() { _omb_module_require "${@/#/lib:}"; } -_omb_module_require_plugin() { _omb_module_require "${@/#/plugin:}"; } -_omb_module_require_alias() { _omb_module_require "${@/#/alias:}"; } -_omb_module_require_completion() { _omb_module_require "${@/#/completion:}"; } -_omb_module_require_theme() { _omb_module_require "${@/#/theme:}"; } +function _omb_module_require_lib { _omb_module_require "${@/#/lib:}"; } +function _omb_module_require_plugin { _omb_module_require "${@/#/plugin:}"; } +function _omb_module_require_alias { _omb_module_require "${@/#/alias:}"; } +function _omb_module_require_completion { _omb_module_require "${@/#/completion:}"; } +function _omb_module_require_theme { _omb_module_require "${@/#/theme:}"; } # 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 diff --git a/plugins/battery/battery.plugin.sh b/plugins/battery/battery.plugin.sh index fde8ee0..b65019b 100644 --- a/plugins/battery/battery.plugin.sh +++ b/plugins/battery/battery.plugin.sh @@ -1,10 +1,10 @@ #! 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;}')" } -ac_adapter_connected(){ +function ac_adapter_connected { if _omb_util_command_exists upower; then _omb_plugin_battery__upower_print_info | grep -qE 'state[:[:blank:]]*(charging|fully-charged)' @@ -28,7 +28,7 @@ ac_adapter_connected(){ fi } -ac_adapter_disconnected(){ +function ac_adapter_disconnected { if _omb_util_command_exists upower; then _omb_plugin_battery__upower_print_info | grep -qE 'state[:[:blank:]]*discharging' @@ -55,7 +55,7 @@ ac_adapter_disconnected(){ ## @fn battery_percentage ## @about 'displays battery charge as a percentage of full (100%)' ## @group 'battery' -battery_percentage(){ +function battery_percentage { if _omb_util_command_exists upower; then local UPOWER_OUTPUT=$(_omb_plugin_battery__upower_print_info | sed -n 's/.*percentage[:[:blank:]]*\([0-9%]\{1,\}\)$/\1/p') @@ -129,7 +129,7 @@ battery_percentage(){ ## @fn battery_charge ## @about 'graphical display of your battery charge' ## @group 'battery' -battery_charge(){ +function battery_charge { # Full char local F_C='▸' # Depleted char diff --git a/plugins/fasd/fasd.plugin.sh b/plugins/fasd/fasd.plugin.sh index 38d8467..25c2ffb 100644 --- a/plugins/fasd/fasd.plugin.sh +++ b/plugins/fasd/fasd.plugin.sh @@ -3,13 +3,13 @@ # Initialize fasd, without setting up the prompt hook, which # 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} [[ $sink == /dev/null ]] && return 0 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 eval -- "$(fasd --init posix-alias bash-ccomp bash-ccomp-install)" _omb_util_add_prompt_command _omb_plugin_fasd_prompt_func diff --git a/plugins/git/git.plugin.sh b/plugins/git/git.plugin.sh index 29be3e6..be2b3ce 100644 --- a/plugins/git/git.plugin.sh +++ b/plugins/git/git.plugin.sh @@ -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 gdw='git diff --word-diff' -gdv() { +function gdv { git diff -w "$@" | view - } #compdef _git gdv=git-diff @@ -96,7 +96,7 @@ alias gf='git fetch' alias gfa='git fetch --all --prune' alias gfo='git fetch origin' -gfg() { +function gfg { git ls-files | grep "$@" } #compdef _grep gfg @@ -104,13 +104,13 @@ gfg() { alias gg='git gui citool' alias gga='git gui citool --amend' -ggf() { +function ggf { [[ "$#" != 1 ]] && local b="$(git_current_branch)" git push --force origin "${b:=$1}" } #compdef _git ggf=git-checkout -ggl() { +function ggl { if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then git pull origin "${*}" else @@ -120,7 +120,7 @@ ggl() { } #compdef _git ggl=git-checkout -ggp() { +function ggp { if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then git push origin "${*}" else @@ -130,7 +130,7 @@ ggp() { } #compdef _git ggp=git-checkout -ggpnp() { +function ggpnp { if [[ "$#" == 0 ]]; then ggl && ggp else @@ -139,7 +139,7 @@ ggpnp() { } #compdef _git ggpnp=git-checkout -ggu() { +function ggu { [[ "$#" != 1 ]] && local b="$(git_current_branch)" git pull --rebase origin "${b:=$1}" } diff --git a/plugins/kubectl/kubectl.plugin.sh b/plugins/kubectl/kubectl.plugin.sh index 3795010..02a08a8 100644 --- a/plugins/kubectl/kubectl.plugin.sh +++ b/plugins/kubectl/kubectl.plugin.sh @@ -76,7 +76,7 @@ alias kdd='kubectl describe deployment' alias kdeld='kubectl delete deployment' alias ksd='kubectl scale deployment' alias krsd='kubectl rollout status deployment' -kres(){ +function kres { kubectl set env $@ REFRESHED_AT=$(date +%Y%m%d%H%M%S) } diff --git a/plugins/nvm/nvm.plugin.sh b/plugins/nvm/nvm.plugin.sh index 81677c2..31f9328 100644 --- a/plugins/nvm/nvm.plugin.sh +++ b/plugins/nvm/nvm.plugin.sh @@ -45,7 +45,7 @@ fi # SOFTWARE. # 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 while [[ $path && ! -e $path/$1 ]]; do path=${path%/*} @@ -53,7 +53,7 @@ if _omb_util_command_exists nvm && [[ ${OMB_PLUGIN_NVM_AUTO_USE-} == true ]]; th echo "$path" } - _omb_plugin_nvm_cd(){ + function _omb_plugin_nvm_cd { cd "$@" || return "$?" local nvm_path=$(_omb_plugin_nvm_find_up .nvmrc) diff --git a/plugins/tmux-autoattach/tmux-autoattach.plugin.sh b/plugins/tmux-autoattach/tmux-autoattach.plugin.sh index 42770ef..c198d52 100644 --- a/plugins/tmux-autoattach/tmux-autoattach.plugin.sh +++ b/plugins/tmux-autoattach/tmux-autoattach.plugin.sh @@ -15,11 +15,11 @@ # # [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 } -_osh_plugin_tmux_autoattach_detach() { +function _osh_plugin_tmux_autoattach_detach { [ -z "$TMUX" ] && tmux -2u new -As0 } diff --git a/themes/absimple/absimple.theme.sh b/themes/absimple/absimple.theme.sh index d74a566..740a1f9 100644 --- a/themes/absimple/absimple.theme.sh +++ b/themes/absimple/absimple.theme.sh @@ -16,7 +16,7 @@ PROMPT_DIRTRIM=2 # bash4 and above ###################################################################### DEBUG=0 -debug() { +function debug { if [[ ${DEBUG} -ne 0 ]]; then >&2 echo -e $* fi @@ -33,7 +33,7 @@ RIGHT_SEPARATOR='' LEFT_SUBSEG='' RIGHT_SUBSEG='' -text_effect() { +function text_effect { case "$1" in reset) echo 0;; bold) echo 1;; @@ -44,7 +44,7 @@ text_effect() { # to add colors, see # 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 -fg_color() { +function fg_color { case "$1" in black) echo 30;; red) echo 31;; @@ -58,7 +58,7 @@ fg_color() { esac } -bg_color() { +function bg_color { case "$1" in black) echo 40;; red) echo 41;; @@ -72,7 +72,7 @@ bg_color() { esac; } -ansi() { +function ansi { local seq local -a mycodes=("${!1}") @@ -91,14 +91,14 @@ ansi() { # PR="$PR\[\033[${seq}m\]" } -ansi_single() { +function ansi_single { echo -ne '\[\033['$1'm\]' } # Begin a segment # Takes two arguments, background and foreground. Both can be omitted, # rendering default background/foreground. -prompt_segment() { +function prompt_segment { local bg fg local -a codes @@ -140,7 +140,7 @@ prompt_segment() { } # End the prompt, closing any open segments -prompt_end() { +function prompt_end { if [[ -n $CURRENT_BG ]]; then local -a codes=($(text_effect reset) $(fg_color $CURRENT_BG)) PR="$PR $(ansi codes[@])$SEGMENT_SEPARATOR" @@ -151,7 +151,7 @@ prompt_end() { } ### virtualenv prompt -prompt_virtualenv() { +function prompt_virtualenv { if [[ -n $VIRTUAL_ENV ]]; then # Python could output the version information in both stdout and # 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 # Context: user@hostname (who am I and where am I) -prompt_context() { +function prompt_context { local user=`whoami` if [[ $user != $DEFAULT_USER || -n $SSH_CLIENT ]]; then @@ -181,18 +181,18 @@ prompt_context() { # prints history followed by HH:MM, useful for remembering what # we did previously -prompt_histdt() { +function prompt_histdt { prompt_segment black default "\!" # \A" } -git_status_dirty() { +function git_status_dirty { dirty=$(git status -s 2> /dev/null | tail -n 1) [[ -n $dirty ]] && echo " ●" } # Git: branch/detached head, dirty status -prompt_git() { +function prompt_git { local ref dirty if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then ZSH_THEME_GIT_PROMPT_DIRTY='±' @@ -208,7 +208,7 @@ prompt_git() { } # Dir: current working directory -prompt_dir() { +function prompt_dir { prompt_segment blue black '\W' } @@ -216,7 +216,7 @@ prompt_dir() { # - was there an error # - am I root # - are there background jobs? -prompt_status() { +function prompt_status { local symbols symbols=() [[ $RETVAL -ne 0 ]] && symbols+="$(ansi_single $(fg_color red))✘" @@ -232,12 +232,12 @@ prompt_status() { # requires setting prompt_foo to use PRIGHT vs PR # doesn't quite work per above -rightprompt() { +function rightprompt { printf "%*s" $COLUMNS "$PRIGHT" } # quick right prompt I grabbed to test things. -__command_rprompt() { +function __command_rprompt { local times= n=$COLUMNS tz for tz in ZRH:Europe/Zurich PIT:US/Eastern \ MTV:US/Pacific TOK:Asia/Tokyo; do @@ -251,7 +251,7 @@ __command_rprompt() { # PROMPT_COMMAND=__command_rprompt # this doens't wrap code in \[ \] -ansi_r() { +function ansi_r { local seq local -a mycodes2=("${!1}") @@ -273,7 +273,7 @@ ansi_r() { # Begin a segment on the right # Takes two arguments, background and foreground. Both can be omitted, # rendering default background/foreground. -prompt_right_segment() { +function prompt_right_segment { local bg fg local -a codes @@ -336,7 +336,7 @@ prompt_right_segment() { # (add-hook 'comint-preoutput-filter-functions # 'dirtrack-filter-out-pwd-prompt t t))) -prompt_emacsdir() { +function prompt_emacsdir { # no color or other setting... this will be deleted per above PR="DIR \w DIR$PR" } @@ -344,7 +344,7 @@ prompt_emacsdir() { ###################################################################### ## Main prompt -build_prompt() { +function build_prompt { [[ ! -z ${AG_EMACS_DIR+x} ]] && prompt_emacsdir prompt_status [[ -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 # use that. -_omb_theme_PROMPT_COMMAND() { +function _omb_theme_PROMPT_COMMAND { local RETVAL=$? local PR="" local PRIGHT="" diff --git a/themes/agnoster/agnoster.theme.sh b/themes/agnoster/agnoster.theme.sh index 10a961c..30ea3b5 100644 --- a/themes/agnoster/agnoster.theme.sh +++ b/themes/agnoster/agnoster.theme.sh @@ -69,7 +69,7 @@ PROMPT_DIRTRIM=2 # bash4 and above ###################################################################### DEBUG=0 -debug() { +function debug { if [[ ${DEBUG} -ne 0 ]]; then >&2 echo -e $* fi @@ -86,7 +86,7 @@ RIGHT_SEPARATOR='' LEFT_SUBSEG='' RIGHT_SUBSEG='' -text_effect() { +function text_effect { case "$1" in reset) echo 0;; bold) echo 1;; @@ -97,7 +97,7 @@ text_effect() { # to add colors, see # 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 -fg_color() { +function fg_color { case "$1" in black) echo 30;; red) echo 31;; @@ -111,7 +111,7 @@ fg_color() { esac } -bg_color() { +function bg_color { case "$1" in black) echo 40;; red) echo 41;; @@ -128,7 +128,7 @@ bg_color() { # TIL: declare is global not local, so best use a different name # for codes (mycodes) as otherwise it'll clobber the original. # this changes from BASH v3 to BASH v4. -ansi() { +function ansi { local seq declare -a mycodes=("${!1}") @@ -146,14 +146,14 @@ ansi() { # PR="$PR\[\033[${seq}m\]" } -ansi_single() { +function ansi_single { echo -ne '\[\033['$1'm\]' } # Begin a segment # Takes two arguments, background and foreground. Both can be omitted, # rendering default background/foreground. -prompt_segment() { +function prompt_segment { local bg fg declare -a codes @@ -195,7 +195,7 @@ prompt_segment() { } # End the prompt, closing any open segments -prompt_end() { +function prompt_end { if [[ -n $CURRENT_BG ]]; then declare -a codes=($(text_effect reset) $(fg_color $CURRENT_BG)) PR="$PR $(ansi codes[@])$SEGMENT_SEPARATOR" @@ -206,7 +206,7 @@ prompt_end() { } ### virtualenv prompt -prompt_virtualenv() { +function prompt_virtualenv { if [[ -n $VIRTUAL_ENV ]]; then # Python could output the version information in both stdout and # 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 # Context: user@hostname (who am I and where am I) -prompt_context() { +function prompt_context { local user=$(whoami) if [[ $user != $DEFAULT_USER || -n $SSH_CLIENT ]]; then @@ -236,18 +236,18 @@ prompt_context() { # prints history followed by HH:MM, useful for remembering what # we did previously -prompt_histdt() { +function prompt_histdt { prompt_segment black default "\! [\A]" } -git_status_dirty() { +function git_status_dirty { dirty=$(git status -s 2> /dev/null | tail -n 1) [[ -n $dirty ]] && echo " ●" } # Git: branch/detached head, dirty status -prompt_git() { +function prompt_git { local ref dirty if git rev-parse --is-inside-work-tree &>/dev/null; then ZSH_THEME_GIT_PROMPT_DIRTY='±' @@ -263,7 +263,7 @@ prompt_git() { } # Dir: current working directory -prompt_dir() { +function prompt_dir { prompt_segment blue black '\w' } @@ -271,7 +271,7 @@ prompt_dir() { # - was there an error # - am I root # - are there background jobs? -prompt_status() { +function prompt_status { local symbols symbols=() [[ $RETVAL -ne 0 ]] && symbols+="$(ansi_single $(fg_color red))✘" @@ -287,12 +287,12 @@ prompt_status() { # requires setting prompt_foo to use PRIGHT vs PR # doesn't quite work per above -rightprompt() { +function rightprompt { printf "%*s" $COLUMNS "$PRIGHT" } # quick right prompt I grabbed to test things. -__command_rprompt() { +function __command_rprompt { local times= n=$COLUMNS tz for tz in ZRH:Europe/Zurich PIT:US/Eastern \ MTV:US/Pacific TOK:Asia/Tokyo; do @@ -306,7 +306,7 @@ __command_rprompt() { # _omb_util_add_prompt_command __command_rprompt # this doens't wrap code in \[ \] -ansi_r() { +function ansi_r { local seq declare -a mycodes2=("${!1}") @@ -327,7 +327,7 @@ ansi_r() { # Begin a segment on the right # Takes two arguments, background and foreground. Both can be omitted, # rendering default background/foreground. -prompt_right_segment() { +function prompt_right_segment { local bg fg declare -a codes @@ -390,7 +390,7 @@ prompt_right_segment() { # (add-hook 'comint-preoutput-filter-functions # 'dirtrack-filter-out-pwd-prompt t t))) -prompt_emacsdir() { +function prompt_emacsdir { # no color or other setting... this will be deleted per above PR="DIR \w DIR$PR" } @@ -398,7 +398,7 @@ prompt_emacsdir() { ###################################################################### ## Main prompt -build_prompt() { +function build_prompt { [[ ! -z ${AG_EMACS_DIR+x} ]] && prompt_emacsdir prompt_status #[[ -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 # use that. -_omb_theme_PROMPT_COMMAND() { +function _omb_theme_PROMPT_COMMAND { RETVAL=$? PR="" PRIGHT="" diff --git a/themes/binaryanomaly/binaryanomaly.theme.sh b/themes/binaryanomaly/binaryanomaly.theme.sh index fafe19d..efbe992 100644 --- a/themes/binaryanomaly/binaryanomaly.theme.sh +++ b/themes/binaryanomaly/binaryanomaly.theme.sh @@ -38,7 +38,7 @@ function set_user_color() { esac } -scm_prompt() { +function scm_prompt { CHAR=$(scm_char) if [ $CHAR = $SCM_NONE_CHAR ] then @@ -62,7 +62,7 @@ function set_custom_colors() { powder_blue="\[$(tput setaf 153)\]" } -__ps_time() { +function __ps_time { echo "$(clock_prompt)${_omb_prompt_normal}\n" } diff --git a/themes/bobby/bobby.theme.sh b/themes/bobby/bobby.theme.sh index deb661f..d6f6b28 100644 --- a/themes/bobby/bobby.theme.sh +++ b/themes/bobby/bobby.theme.sh @@ -13,7 +13,7 @@ GIT_THEME_PROMPT_SUFFIX="${_omb_prompt_green}|" RVM_THEME_PROMPT_PREFIX="|" RVM_THEME_PROMPT_SUFFIX="|" -__bobby_clock() { +function __bobby_clock { printf "$(clock_prompt) " if [ "${THEME_SHOW_CLOCK_CHAR}" == "true" ]; then diff --git a/themes/brainy/brainy.theme.sh b/themes/brainy/brainy.theme.sh index e476841..cae9dcb 100644 --- a/themes/brainy/brainy.theme.sh +++ b/themes/brainy/brainy.theme.sh @@ -7,7 +7,7 @@ ## Parsers ## ############# -____brainy_top_left_parse() { +function ____brainy_top_left_parse { ifs_old="${IFS}" IFS="|" args=( $1 ) @@ -22,7 +22,7 @@ ____brainy_top_left_parse() { _TOP_LEFT+=" " } -____brainy_top_right_parse() { +function ____brainy_top_right_parse { ifs_old="${IFS}" IFS="|" args=( $1 ) @@ -39,7 +39,7 @@ ____brainy_top_right_parse() { (( __SEG_AT_RIGHT += 1 )) } -____brainy_bottom_parse() { +function ____brainy_bottom_parse { ifs_old="${IFS}" IFS="|" args=( $1 ) @@ -48,7 +48,7 @@ ____brainy_bottom_parse() { [ ${#args[1]} -gt 0 ] && _BOTTOM+=" " } -____brainy_top() { +function ____brainy_top { _TOP_LEFT="" _TOP_RIGHT="" __TOP_RIGHT_LEN=0 @@ -74,7 +74,7 @@ ____brainy_top() { printf "%s%s" "${_TOP_LEFT}" "${_TOP_RIGHT}" } -____brainy_bottom() { +function ____brainy_bottom { _BOTTOM="" for seg in $___BRAINY_BOTTOM; do info="$(___brainy_prompt_"${seg}")" @@ -87,7 +87,7 @@ ____brainy_bottom() { ## Segments ## ############## -___brainy_prompt_user_info() { +function ___brainy_prompt_user_info { color=$_omb_prompt_bold_navy if [ "${THEME_SHOW_SUDO}" == "true" ]; then if [ $(sudo -n id -u 2>&1 | grep 0) ]; then @@ -103,14 +103,14 @@ ___brainy_prompt_user_info() { fi } -___brainy_prompt_dir() { +function ___brainy_prompt_dir { color=$_omb_prompt_bold_olive box="[|]" info="\w" printf "%s|%s|%s|%s" "${color}" "${info}" "${_omb_prompt_bold_white}" "${box}" } -___brainy_prompt_scm() { +function ___brainy_prompt_scm { [ "${THEME_SHOW_SCM}" != "true" ] && return color=$_omb_prompt_bold_green box="$(scm_char) " @@ -118,7 +118,7 @@ ___brainy_prompt_scm() { printf "%s|%s|%s|%s" "${color}" "${info}" "${_omb_prompt_bold_white}" "${box}" } -___brainy_prompt_python() { +function ___brainy_prompt_python { [ "${THEME_SHOW_PYTHON}" != "true" ] && return color=$_omb_prompt_bold_olive box="[|]" @@ -126,7 +126,7 @@ ___brainy_prompt_python() { printf "%s|%s|%s|%s" "${color}" "${info}" "${_omb_prompt_bold_navy}" "${box}" } -___brainy_prompt_ruby() { +function ___brainy_prompt_ruby { [ "${THEME_SHOW_RUBY}" != "true" ] && return color=$_omb_prompt_bold_white box="[|]" @@ -134,7 +134,7 @@ ___brainy_prompt_ruby() { printf "%s|%s|%s|%s" "${color}" "${info}" "${_omb_prompt_bold_brown}" "${box}" } -___brainy_prompt_todo() { +function ___brainy_prompt_todo { [ "${THEME_SHOW_TODO}" != "true" ] && return _omb_util_binary_exists todo.sh || return color=$_omb_prompt_bold_white @@ -143,7 +143,7 @@ ___brainy_prompt_todo() { printf "%s|%s|%s|%s" "${color}" "${info}" "${_omb_prompt_bold_green}" "${box}" } -___brainy_prompt_clock() { +function ___brainy_prompt_clock { [ "${THEME_SHOW_CLOCK}" != "true" ] && return color=$THEME_CLOCK_COLOR box="[|]" @@ -151,7 +151,7 @@ ___brainy_prompt_clock() { 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" ] || [ "${THEME_SHOW_BATTERY}" != "true" ] && return info=$(battery_percentage) @@ -167,13 +167,13 @@ ___brainy_prompt_battery() { printf "%s|%s|%s|%s" "${color}" "${info}" "${_omb_prompt_bold_white}" "${box}" } -___brainy_prompt_exitcode() { +function ___brainy_prompt_exitcode { [ "${THEME_SHOW_EXITCODE}" != "true" ] && return color=$_omb_prompt_bold_purple [ "$exitcode" -ne 0 ] && printf "%s|%s" "${color}" "${exitcode}" } -___brainy_prompt_char() { +function ___brainy_prompt_char { color=$_omb_prompt_bold_white prompt_char="${__BRAINY_PROMPT_CHAR_PS1}" printf "%s|%s" "${color}" "${prompt_char}" @@ -183,19 +183,19 @@ ___brainy_prompt_char() { ## cli ## ######### -__brainy_show() { +function __brainy_show { typeset _seg=${1:-} shift export THEME_SHOW_${_seg}=true } -__brainy_hide() { +function __brainy_hide { typeset _seg=${1:-} shift export THEME_SHOW_${_seg}=false } -_brainy_completion() { +function _brainy_completion { local cur _action actions segments COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" @@ -217,7 +217,7 @@ _brainy_completion() { return 0 } -brainy() { +function brainy { typeset action=${1:-} shift typeset segs=${*:-} @@ -276,16 +276,16 @@ ___BRAINY_BOTTOM=${___BRAINY_BOTTOM:-"exitcode char"} ## Prompt ## ############ -__brainy_ps1() { +function __brainy_ps1 { printf "%s%s%s" "$(____brainy_top)" "$(____brainy_bottom)" "${_omb_prompt_normal}" } -__brainy_ps2() { +function __brainy_ps2 { color=$_omb_prompt_bold_white printf "%s%s%s" "${color}" "${__BRAINY_PROMPT_CHAR_PS2} " "${_omb_prompt_normal}" } -_omb_theme_PROMPT_COMMAND() { +function _omb_theme_PROMPT_COMMAND { exitcode="$?" PS1="$(__brainy_ps1)" diff --git a/themes/brunton/brunton.theme.sh b/themes/brunton/brunton.theme.sh index f5b79be..36ef2cd 100644 --- a/themes/brunton/brunton.theme.sh +++ b/themes/brunton/brunton.theme.sh @@ -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_HG_CHAR="${_omb_prompt_bold_brown}☿${_omb_prompt_normal}" -is_vim_shell() { +function is_vim_shell { if [ ! -z "$VIMRUNTIME" ] then echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]" fi } -scm_prompt() { +function scm_prompt { CHAR=$(scm_char) if [ $CHAR = $SCM_NONE_CHAR ] then @@ -26,7 +26,7 @@ scm_prompt() { 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_background_navy}@${_omb_prompt_brown}${_omb_prompt_background_navy}\h $(clock_prompt) ${_omb_prompt_reset_color}" PS1+="${_omb_prompt_normal} $(battery_charge)\n" diff --git a/themes/demula/demula.theme.sh b/themes/demula/demula.theme.sh index 201082a..c5c7478 100644 --- a/themes/demula/demula.theme.sh +++ b/themes/demula/demula.theme.sh @@ -55,7 +55,7 @@ case $TERM in ;; esac -is_vim_shell() { +function is_vim_shell { if [ ! -z "$VIMRUNTIME" ]; then echo "${D_INTERMEDIATE_COLOR}on ${D_VIMSHELL_COLOR}\ @@ -63,7 +63,7 @@ vim shell${D_DEFAULT_COLOR} " fi } -mitsuhikos_lastcommandfailed() { +function mitsuhikos_lastcommandfailed { code=$? if [ $code != 0 ]; then @@ -73,7 +73,7 @@ $code ${D_DEFAULT_COLOR}" } # vcprompt for scm instead of oh-my-bash default -demula_vcprompt() { +function demula_vcprompt { if [ ! -z "$VCPROMPT_EXECUTABLE" ]; then 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 -safe_battery_charge() { +function safe_battery_charge { if [ -e "${OSH}/plugins/battery/battery.plugin.sh" ]; then battery_charge @@ -91,7 +91,7 @@ safe_battery_charge() { } # -------------------------------------------------------------- PROMPT OUTPUT -_omb_theme_PROMPT_COMMAND() { +function _omb_theme_PROMPT_COMMAND { local LAST_COMMAND_FAILED=$(mitsuhikos_lastcommandfailed) local SAVE_CURSOR='\033[s' local RESTORE_CURSOR='\033[u' diff --git a/themes/doubletime/doubletime.theme.sh b/themes/doubletime/doubletime.theme.sh index 02b7aa9..b318f30 100644 --- a/themes/doubletime/doubletime.theme.sh +++ b/themes/doubletime/doubletime.theme.sh @@ -28,7 +28,7 @@ else THEME_PROMPT_HOST_COLOR="$_omb_prompt_navy" fi -doubletime_scm_prompt() { +function doubletime_scm_prompt { CHAR=$(scm_char) if [ $CHAR = $SCM_NONE_CHAR ]; then return @@ -53,7 +53,7 @@ $(doubletime_scm_prompt)$_omb_prompt_reset_color $ " _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND -git_prompt_status() { +function git_prompt_status { local git_status_output git_status_output=$(git status 2> /dev/null ) if [ -n "$(echo $git_status_output | grep 'Changes not staged')" ]; then diff --git a/themes/dulcie/dulcie.theme.sh b/themes/dulcie/dulcie.theme.sh index 773c093..20da55a 100644 --- a/themes/dulcie/dulcie.theme.sh +++ b/themes/dulcie/dulcie.theme.sh @@ -15,15 +15,15 @@ DULCIE_COLOR=${DULCIE_COLOR:=1} # 0 = monochrome, 1 = colorful 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\]" } -dulcie_background() { +function dulcie_background { echo -en "\[\e[48;5;${1}m\]" } -_omb_theme_PROMPT_COMMAND() { +function _omb_theme_PROMPT_COMMAND { color_user_root=$(dulcie_color 169) color_user_nonroot="${_omb_prompt_green}" color_host_local=$(dulcie_color 230) diff --git a/themes/duru/duru.theme.sh b/themes/duru/duru.theme.sh index 0bb26d9..a968c2b 100644 --- a/themes/duru/duru.theme.sh +++ b/themes/duru/duru.theme.sh @@ -5,7 +5,7 @@ SCM_THEME_PROMPT_SUFFIX="" SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}with changes" SCM_THEME_PROMPT_CLEAN="" -venv() { +function venv { if [ ! -z "$VIRTUAL_ENV" ] then local env=$VIRTUAL_ENV @@ -13,11 +13,11 @@ venv() { fi } -last_two_dirs() { +function last_two_dirs { 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}" } diff --git a/themes/emperor/emperor.theme.sh b/themes/emperor/emperor.theme.sh index c906c0a..2a78f46 100644 --- a/themes/emperor/emperor.theme.sh +++ b/themes/emperor/emperor.theme.sh @@ -28,7 +28,7 @@ function get_hour_color { echo "$hour_color" } -__emperor_clock() { +function __emperor_clock { THEME_CLOCK_COLOR=$(get_hour_color) clock_prompt } diff --git a/themes/gallifrey/gallifrey.theme.sh b/themes/gallifrey/gallifrey.theme.sh index bd1fba8..ab99ea6 100644 --- a/themes/gallifrey/gallifrey.theme.sh +++ b/themes/gallifrey/gallifrey.theme.sh @@ -14,7 +14,7 @@ SCM_HG_CHAR="h" # 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:' -scm_prompt() { +function scm_prompt { CHAR=$(scm_char) if [ $CHAR = $SCM_NONE_CHAR ] then @@ -24,7 +24,7 @@ scm_prompt() { fi } -_omb_theme_PROMPT_COMMAND() { +function _omb_theme_PROMPT_COMMAND { ps_host="${_omb_prompt_green}\h${_omb_prompt_normal}"; ps_user_mark="${_omb_prompt_bold}\$${_omb_prompt_normal}"; ps_root_mark="${_omb_prompt_normal}§" diff --git a/themes/half-life/half-life.theme.sh b/themes/half-life/half-life.theme.sh index eeb7d84..d9a741c 100644 --- a/themes/half-life/half-life.theme.sh +++ b/themes/half-life/half-life.theme.sh @@ -4,14 +4,14 @@ OSH_THEME_GIT_PROMPT_DIRTY="✗" OSH_THEME_GIT_PROMPT_CLEAN="✓" # Nicely formatted terminal prompt -_omb_theme_half_way_prompt_scm() { +function _omb_theme_half_way_prompt_scm { local CHAR=$(scm_char) if [[ $CHAR != "$SCM_NONE_CHAR" ]]; then printf '%s' " on ${_omb_prompt_navy}$(git_current_branch)$(parse_git_dirty)${_omb_prompt_normal} " fi } -_omb_theme_PROMPT_COMMAND() { +function _omb_theme_PROMPT_COMMAND { local ps_username="${_omb_prompt_purple}\u${_omb_prompt_normal}" local ps_path="${_omb_prompt_green}\w${_omb_prompt_normal}" local ps_user_mark="${_omb_prompt_red}λ${_omb_prompt_normal}" diff --git a/themes/mairan/mairan.theme.sh b/themes/mairan/mairan.theme.sh index 7674d28..5a9b2ad 100644 --- a/themes/mairan/mairan.theme.sh +++ b/themes/mairan/mairan.theme.sh @@ -55,7 +55,7 @@ esac PS3=">> " -__my_rvm_ruby_version() { +function __my_rvm_ruby_version { local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}') [ "$gemset" != "" ] && gemset="@$gemset" local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}') @@ -63,14 +63,14 @@ __my_rvm_ruby_version() { [ "$full" != "" ] && echo "[$full]" } -is_vim_shell() { +function is_vim_shell { if [ ! -z "$VIMRUNTIME" ] then echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]" fi } -modern_scm_prompt() { +function modern_scm_prompt { CHAR=$(scm_char) if [ $CHAR = $SCM_NONE_CHAR ] then @@ -81,7 +81,7 @@ modern_scm_prompt() { } # show chroot if exist -chroot(){ +function chroot { if [ -n "$debian_chroot" ] then my_ps_chroot="${_omb_prompt_bold_teal}$debian_chroot${_omb_prompt_normal}"; @@ -90,7 +90,7 @@ chroot(){ } # show virtualenvwrapper -my_ve(){ +function my_ve { if [ -n "$VIRTUAL_ENV" ] then my_ps_ve="${_omb_prompt_bold_purple}$ve${_omb_prompt_normal}"; @@ -99,7 +99,7 @@ my_ve(){ echo ""; } -_omb_theme_PROMPT_COMMAND() { +function _omb_theme_PROMPT_COMMAND { my_ps_host="$BOLD$ORANGE\h${_omb_prompt_normal}"; # yes, these are the the same for now ... diff --git a/themes/minimal/minimal.theme.sh b/themes/minimal/minimal.theme.sh index d8621e8..9d12a8a 100644 --- a/themes/minimal/minimal.theme.sh +++ b/themes/minimal/minimal.theme.sh @@ -5,7 +5,7 @@ SCM_THEME_PROMPT_SUFFIX="${_omb_prompt_teal})" SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" 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} " } diff --git a/themes/modern-t/modern-t.theme.sh b/themes/modern-t/modern-t.theme.sh index cace41d..4176d18 100644 --- a/themes/modern-t/modern-t.theme.sh +++ b/themes/modern-t/modern-t.theme.sh @@ -19,14 +19,14 @@ esac PS3=">> " -is_vim_shell() { +function is_vim_shell { if [ ! -z "$VIMRUNTIME" ] then echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]" fi } -modern_scm_prompt() { +function modern_scm_prompt { CHAR=$(scm_char) if [ $CHAR = $SCM_NONE_CHAR ] then @@ -36,7 +36,7 @@ modern_scm_prompt() { fi } -_omb_theme_PROMPT_COMMAND() { +function _omb_theme_PROMPT_COMMAND { if (($? != 0)); then local border_color=$_omb_prompt_bold_brown else diff --git a/themes/modern/modern.theme.sh b/themes/modern/modern.theme.sh index a9df981..7ecbe88 100644 --- a/themes/modern/modern.theme.sh +++ b/themes/modern/modern.theme.sh @@ -19,14 +19,14 @@ esac PS3=">> " -is_vim_shell() { +function is_vim_shell { if [ ! -z "$VIMRUNTIME" ] then echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]" fi } -modern_scm_prompt() { +function modern_scm_prompt { CHAR=$(scm_char) if [ $CHAR = $SCM_NONE_CHAR ] then @@ -36,7 +36,7 @@ modern_scm_prompt() { fi } -_omb_theme_PROMPT_COMMAND() { +function _omb_theme_PROMPT_COMMAND { if [ $? -ne 0 ] then # Yes, the indenting on these is weird, but it has to be like diff --git a/themes/nwinkler/nwinkler.theme.sh b/themes/nwinkler/nwinkler.theme.sh index 6fc165f..3d5b9c7 100644 --- a/themes/nwinkler/nwinkler.theme.sh +++ b/themes/nwinkler/nwinkler.theme.sh @@ -23,7 +23,7 @@ function prompt_end() { echo -e "$PROMPT_END" } -_omb_theme_PROMPT_COMMAND() { +function _omb_theme_PROMPT_COMMAND { local exit_status=$? if [[ $exit_status -eq 0 ]]; then PROMPT_END=$PROMPT_END_CLEAN else PROMPT_END=$PROMPT_END_DIRTY diff --git a/themes/nwinkler_random_colors/nwinkler_random_colors.theme.sh b/themes/nwinkler_random_colors/nwinkler_random_colors.theme.sh index 7edebd2..5083d3f 100644 --- a/themes/nwinkler_random_colors/nwinkler_random_colors.theme.sh +++ b/themes/nwinkler_random_colors/nwinkler_random_colors.theme.sh @@ -90,7 +90,7 @@ function prompt_end() { echo -e "$PROMPT_END" } -_omb_theme_PROMPT_COMMAND() { +function _omb_theme_PROMPT_COMMAND { local exit_status=$? if [[ $exit_status -eq 0 ]]; then PROMPT_END=$PROMPT_END_CLEAN else PROMPT_END=$PROMPT_END_DIRTY diff --git a/themes/pete/pete.theme.sh b/themes/pete/pete.theme.sh index cc34705..5688261 100644 --- a/themes/pete/pete.theme.sh +++ b/themes/pete/pete.theme.sh @@ -1,6 +1,6 @@ #! bash oh-my-bash.module -_omb_theme_PROMPT_COMMAND() { +function _omb_theme_PROMPT_COMMAND { # Save history history -a history -c diff --git a/themes/powerline-multiline/powerline-multiline.theme.sh b/themes/powerline-multiline/powerline-multiline.theme.sh index 8f55d74..0a1bbdd 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.sh +++ b/themes/powerline-multiline/powerline-multiline.theme.sh @@ -50,5 +50,5 @@ IN_VIM_THEME_PROMPT_TEXT="vim" POWERLINE_LEFT_PROMPT=${POWERLINE_LEFT_PROMPT:="scm python_venv ruby cwd"} 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 diff --git a/themes/powerline-naked/powerline-naked.theme.sh b/themes/powerline-naked/powerline-naked.theme.sh index 1fa252a..cd3a367 100644 --- a/themes/powerline-naked/powerline-naked.theme.sh +++ b/themes/powerline-naked/powerline-naked.theme.sh @@ -49,5 +49,5 @@ IN_VIM_THEME_PROMPT_TEXT="vim" 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 diff --git a/themes/powerline-plain/powerline-plain.theme.sh b/themes/powerline-plain/powerline-plain.theme.sh index 19ceafe..f8ee6ae 100644 --- a/themes/powerline-plain/powerline-plain.theme.sh +++ b/themes/powerline-plain/powerline-plain.theme.sh @@ -45,5 +45,5 @@ IN_VIM_THEME_PROMPT_TEXT="vim" 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 diff --git a/themes/powerline/powerline.theme.sh b/themes/powerline/powerline.theme.sh index 05e3539..04836f2 100644 --- a/themes/powerline/powerline.theme.sh +++ b/themes/powerline/powerline.theme.sh @@ -48,5 +48,5 @@ IN_VIM_THEME_PROMPT_TEXT="vim" 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 diff --git a/themes/pure/pure.theme.sh b/themes/pure/pure.theme.sh index 2ae8960..2fef1fe 100644 --- a/themes/pure/pure.theme.sh +++ b/themes/pure/pure.theme.sh @@ -14,7 +14,7 @@ SCM_HG_CHAR="${_omb_prompt_bold_brown}☿${_omb_prompt_normal}" # 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:' -scm_prompt() { +function scm_prompt { CHAR=$(scm_char) if [ $CHAR = $SCM_NONE_CHAR ] then @@ -24,7 +24,7 @@ scm_prompt() { fi } -_omb_theme_PROMPT_COMMAND() { +function _omb_theme_PROMPT_COMMAND { ps_host="${_omb_prompt_bold_navy}\h${_omb_prompt_normal}"; ps_user="${_omb_prompt_green}\u${_omb_prompt_normal}"; ps_user_mark="${_omb_prompt_green} $ ${_omb_prompt_normal}"; diff --git a/themes/pzq/pzq.theme.sh b/themes/pzq/pzq.theme.sh index 4001b8f..b9eb799 100644 --- a/themes/pzq/pzq.theme.sh +++ b/themes/pzq/pzq.theme.sh @@ -38,13 +38,13 @@ case $TERM in ;; esac -is_vim_shell() { +function is_vim_shell { if [[ ${VIMRUNTIME-} ]]; then echo "${D_INTERMEDIATE_COLOR}on ${D_VIMSHELL_COLOR}vim shell${D_DEFAULT_COLOR} " fi } -mitsuhikos_lastcommandfailed() { +function mitsuhikos_lastcommandfailed { local status=$? if ((status != 0)); then 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 -demula_vcprompt() { +function demula_vcprompt { 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}" $VCPROMPT_EXECUTABLE -f "$D_VCPROMPT_FORMAT" @@ -60,13 +60,13 @@ demula_vcprompt() { } # 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 battery_charge fi } -prompt_git() { +function prompt_git { local branchName='' # Check if the current directory is in a Git repository. @@ -85,7 +85,7 @@ prompt_git() { fi } -limited_pwd() { +function limited_pwd { # Max length of PWD to display local MAX_PWD_LENGTH=20 @@ -104,7 +104,7 @@ limited_pwd() { } # -------------------------------------------------------------- PROMPT OUTPUT -_omb_theme_PROMPT_COMMAND() { +function _omb_theme_PROMPT_COMMAND { local LAST_COMMAND_FAILED=$(mitsuhikos_lastcommandfailed) local SAVE_CURSOR='\[\e7' local RESTORE_CURSOR='\e8\]' diff --git a/themes/rainbowbrite/rainbowbrite.theme.sh b/themes/rainbowbrite/rainbowbrite.theme.sh index 301bd99..f810f9c 100644 --- a/themes/rainbowbrite/rainbowbrite.theme.sh +++ b/themes/rainbowbrite/rainbowbrite.theme.sh @@ -5,7 +5,7 @@ # ± ~/path/to (branch ✓) $ # in glorious red / blue / yellow color scheme -_omb_theme_PROMPT_COMMAND() { +function _omb_theme_PROMPT_COMMAND { # Save history history -a history -c diff --git a/themes/rana/rana.theme.sh b/themes/rana/rana.theme.sh index f8b4653..2bf6a16 100644 --- a/themes/rana/rana.theme.sh +++ b/themes/rana/rana.theme.sh @@ -83,13 +83,13 @@ case $TERM in ;; esac -is_vim_shell() { +function is_vim_shell { if [[ ${VIMRUNTIME-} ]]; then echo "${D_INTERMEDIATE_COLOR}on ${D_VIMSHELL_COLOR}vim shell${D_DEFAULT_COLOR} " fi } -mitsuhikos_lastcommandfailed() { +function mitsuhikos_lastcommandfailed { local status=$? if ((status != 0)); then 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 -demula_vcprompt() { +function demula_vcprompt { 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}" $VCPROMPT_EXECUTABLE -f "$D_VCPROMPT_FORMAT" @@ -105,13 +105,13 @@ demula_vcprompt() { } # 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 battery_charge fi } -prompt_git() { +function prompt_git { local s='' local branchName='' @@ -163,7 +163,7 @@ prompt_git() { } # -------------------------------------------------------------- PROMPT OUTPUT -_omb_theme_PROMPT_COMMAND() { +function _omb_theme_PROMPT_COMMAND { local LAST_COMMAND_FAILED=$(mitsuhikos_lastcommandfailed) local SAVE_CURSOR='\[\e7' local RESTORE_CURSOR='\e8\]' diff --git a/themes/rjorgenson/rjorgenson.theme.sh b/themes/rjorgenson/rjorgenson.theme.sh index 828c29a..3bf709a 100644 --- a/themes/rjorgenson/rjorgenson.theme.sh +++ b/themes/rjorgenson/rjorgenson.theme.sh @@ -29,7 +29,7 @@ case $TERM in esac -__my_rvm_ruby_version() { +function __my_rvm_ruby_version { local gemset ; gemset=$(awk -F'@' '{print $2}' <<< "${GEM_HOME}") local version ; version=$(awk -F'-' '{print $2}' <<< "${MY_RUBY_HOME}") [ "${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}" } -is_vim_shell() { +function is_vim_shell { if [ -n "${VIMRUNTIME}" ] ; then echo "${OMB_THEME_BRACKET_COLOR}[${OMB_THEME_STRING_COLOR}vim shell${OMB_THEME_BRACKET_COLOR}]${_omb_prompt_normal}" 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 return $? } # 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 -todo_txt_count() { +function todo_txt_count { if _omb_util_command_exists todo.sh; then # is todo.sh installed local count=$(todo.sh ls \ | awk '/TODO: [0-9]+ of ([0-9]+) tasks shown/ { print $4 }') @@ -61,7 +61,7 @@ todo_txt_count() { fi } -modern_scm_prompt() { +function modern_scm_prompt { local CHAR=$(scm_char) if [ ! "${CHAR}" = "${SCM_NONE_CHAR}" ] ; then printf "%s" \ @@ -71,7 +71,7 @@ modern_scm_prompt() { fi } -_omb_theme_PROMPT_COMMAND() { +function _omb_theme_PROMPT_COMMAND { local my_host="${OMB_THEME_STRING_COLOR}\h${_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}"; diff --git a/themes/sexy/sexy.theme.sh b/themes/sexy/sexy.theme.sh index c8bc0fd..93da89b 100644 --- a/themes/sexy/sexy.theme.sh +++ b/themes/sexy/sexy.theme.sh @@ -33,10 +33,10 @@ else RESET="\033[m" fi -parse_git_dirty () { +function parse_git_dirty { [[ $(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)/" } diff --git a/themes/slick/slick.theme.sh b/themes/slick/slick.theme.sh index d6e4195..08aa9d0 100644 --- a/themes/slick/slick.theme.sh +++ b/themes/slick/slick.theme.sh @@ -22,7 +22,7 @@ esac PS3=">> " -__my_rvm_ruby_version() { +function __my_rvm_ruby_version { local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}') [ "$gemset" != "" ] && gemset="@$gemset" local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}') @@ -30,21 +30,21 @@ __my_rvm_ruby_version() { [ "$full" != "" ] && echo "[$full]" } -__my_venv_prompt() { +function __my_venv_prompt { if [ ! -z "$VIRTUAL_ENV" ] then echo "[${_omb_prompt_navy}@${_omb_prompt_normal}${VIRTUAL_ENV##*/}]" fi } -is_vim_shell() { +function is_vim_shell { if [ ! -z "$VIMRUNTIME" ] then echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]" fi } -modern_scm_prompt() { +function modern_scm_prompt { CHAR=$(scm_char) if [ $CHAR = $SCM_NONE_CHAR ] then @@ -54,7 +54,7 @@ modern_scm_prompt() { fi } -_omb_theme_PROMPT_COMMAND() { +function _omb_theme_PROMPT_COMMAND { case $HOSTNAME in "clappy"* ) my_ps_host="${_omb_prompt_green}\h${_omb_prompt_normal}"; diff --git a/themes/tonka/tonka.theme.sh b/themes/tonka/tonka.theme.sh index 79540c9..7acc8e3 100644 --- a/themes/tonka/tonka.theme.sh +++ b/themes/tonka/tonka.theme.sh @@ -1,23 +1,23 @@ #! bash oh-my-bash.module -__tonka_time() { +function __tonka_time { THEME_CLOCK_FORMAT="%H%M" clock_prompt } -__tonka_date() { +function __tonka_date { THEME_CLOCK_FORMAT="%a,%d %b %y" clock_prompt } -__tonka_clock() { +function __tonka_clock { local LIGHT_BLUE="\[\033[1;34m\]" if [[ "${THEME_SHOW_CLOCK}" = "true" ]]; then echo "$(__tonka_time)${LIGHT_BLUE}:$(__tonka_date)${LIGHT_BLUE}:" fi } -_omb_theme_PROMPT_COMMAND() { +function _omb_theme_PROMPT_COMMAND { # Named "Tonka" because of the colour scheme local WHITE="\[\033[1;37m\]" diff --git a/themes/vscode/vscode.theme.sh b/themes/vscode/vscode.theme.sh index 55e60df..3b7b6dc 100644 --- a/themes/vscode/vscode.theme.sh +++ b/themes/vscode/vscode.theme.sh @@ -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 # -_omb_theme_vscode_initialize() { +function _omb_theme_vscode_initialize { local userpart='`export XIT=$? \ && [ ! -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\]➜"`' @@ -37,5 +37,5 @@ _omb_theme_vscode_initialize() { } _omb_theme_vscode_initialize -_omb_theme_PROMPT_COMMAND() { true; } +function _omb_theme_PROMPT_COMMAND { true; } PROMPT_DIRTRIM=4 diff --git a/themes/zork/zork.theme.sh b/themes/zork/zork.theme.sh index 949b1f6..6966a62 100644 --- a/themes/zork/zork.theme.sh +++ b/themes/zork/zork.theme.sh @@ -22,7 +22,7 @@ esac PS3=">> " -__my_rvm_ruby_version() { +function __my_rvm_ruby_version { local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}') [ "$gemset" != "" ] && gemset="@$gemset" local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}') @@ -30,14 +30,14 @@ __my_rvm_ruby_version() { [ "$full" != "" ] && echo "[$full]" } -is_vim_shell() { +function is_vim_shell { if [ ! -z "$VIMRUNTIME" ] then echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]" fi } -modern_scm_prompt() { +function modern_scm_prompt { CHAR=$(scm_char) if [ $CHAR = $SCM_NONE_CHAR ] then @@ -48,7 +48,7 @@ modern_scm_prompt() { } # show chroot if exist -chroot(){ +function chroot { if [ -n "$debian_chroot" ] then my_ps_chroot="${_omb_prompt_bold_teal}$debian_chroot${_omb_prompt_normal}"; @@ -57,7 +57,7 @@ chroot(){ } # show virtualenvwrapper -my_ve(){ +function my_ve { if [ -n "$VIRTUAL_ENV" ] then my_ps_ve="${_omb_prompt_bold_purple}$ve${_omb_prompt_normal}"; @@ -66,7 +66,7 @@ my_ve(){ echo ""; } -_omb_theme_PROMPT_COMMAND() { +function _omb_theme_PROMPT_COMMAND { my_ps_host="${_omb_prompt_green}\h${_omb_prompt_normal}"; # yes, these are the the same for now ... diff --git a/tools/bash-preexec.sh b/tools/bash-preexec.sh index d82b2ec..b3e19ff 100644 --- a/tools/bash-preexec.sh +++ b/tools/bash-preexec.sh @@ -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 # Reference https://stackoverflow.com/a/4441178 -__bp_require_not_readonly() { +function __bp_require_not_readonly { local var for var; do if ! ( unset "$var" 2> /dev/null ); then @@ -88,7 +88,7 @@ __bp_require_not_readonly() { # Remove ignorespace and or replace ignoreboth from HISTCONTROL # so we can accurately invoke preexec with a command from our # history even if it starts with a space. -__bp_adjust_histcontrol() { +function __bp_adjust_histcontrol { local histcontrol histcontrol="${HISTCONTROL:-}" histcontrol="${histcontrol//ignorespace}" @@ -112,7 +112,7 @@ declare -a preexec_functions # Trims leading and trailing whitespace from $2 and writes it to the variable # name passed as $1 -__bp_trim_whitespace() { +function __bp_trim_whitespace { local var=${1:?} text=${2:-} text="${text#"${text%%[![:space:]]*}"}" # remove leading 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 # writes the resulting string to the variable name passed as $1. Used for # manipulating substrings in PROMPT_COMMAND -__bp_sanitize_string() { +function __bp_sanitize_string { local var=${1:?} text=${2:-} sanitized __bp_trim_whitespace sanitized "$text" sanitized=${sanitized%;} @@ -135,14 +135,14 @@ __bp_sanitize_string() { # This function is installed as part of the PROMPT_COMMAND; # 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. -__bp_interactive_mode() { +function __bp_interactive_mode { __bp_preexec_interactive_mode="on"; } # This function is installed as part of the PROMPT_COMMAND. # 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 # its pipeline. Note: this MUST be the first thing done in this function. # 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 # precmd functions. This is available for instance in zsh. We can simulate it in bash # by setting the value here. -__bp_set_ret_value() { +function __bp_set_ret_value { return ${1:+"$1"} } -__bp_in_prompt_command() { +function __bp_in_prompt_command { local prompt_command_array 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 # environment to attempt to detect if the current command is being invoked # 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. # 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_install() { +function __bp_install { # Exit if we already have this installed. if [[ "${PROMPT_COMMAND:-}" == *"__bp_precmd_invoke_cmd"* ]]; then return 1; @@ -351,7 +351,7 @@ __bp_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 # 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 # if it can't, just stop the installation __bp_require_not_readonly PROMPT_COMMAND HISTCONTROL HISTTIMEFORMAT || return diff --git a/tools/git-completion.bash b/tools/git-completion.bash index 7c3a753..d96a880 100644 --- a/tools/git-completion.bash +++ b/tools/git-completion.bash @@ -1854,7 +1854,7 @@ _git_gitk () # 2: The tag file to list symbol names from. # 3: A prefix to be added 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-}" " /^${1//\//\\/}/ { print pfx \$1 sfx } " "$2" @@ -1869,7 +1869,7 @@ __git_match_ctag () { # the current word to be completed. # --sfx=: A suffix to be appended to each symbol name instead # of the default space. -__git_complete_symbol () { +function __git_complete_symbol { local tags=tags pfx="" cur_="${cur-}" sfx=" " while test $# != 0; do @@ -3332,7 +3332,7 @@ _git_worktree () esac } -__git_complete_common () { +function __git_complete_common { local command="$1" case "$cur" in @@ -3343,7 +3343,7 @@ __git_complete_common () { } __git_cmds_with_parseopt_helper= -__git_support_parseopt_helper () { +function __git_support_parseopt_helper { test -n "$__git_cmds_with_parseopt_helper" || __git_cmds_with_parseopt_helper="$(__git --list-cmds=parseopt)" @@ -3357,11 +3357,11 @@ __git_support_parseopt_helper () { esac } -__git_have_func () { +function __git_have_func { declare -f -- "$1" >/dev/null 2>&1 } -__git_complete_command () { +function __git_complete_command { local command="$1" local completion_func="_git_${command//-/_}" if ! __git_have_func $completion_func && diff --git a/tools/install.sh b/tools/install.sh index 54a6ae1..cdadf98 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -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 fi -_omb_install_print_version() { +function _omb_install_print_version { local OMB_VERSINFO 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 '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' \ 'usage: ./install.sh [--unattended | --dry-run | --help | --usage | --version]' \ 'usage: bash -c "$(< install.sh)" [--unattended | --dry-run | --help | --usage |' \ ' --version]' } -_omb_install_print_help() { +function _omb_install_print_help { _omb_install_print_version _omb_install_print_usage printf '%s\n' \ @@ -52,7 +52,7 @@ _omb_install_print_help() { ## @fn _omb_install_readargs [options...] ## @var[out] install_opts ## @var[out] install_prefix -_omb_install_readargs() { +function _omb_install_readargs { install_opts= install_prefix= while (($#)); do @@ -101,7 +101,7 @@ _omb_install_readargs() { done } -_omb_install_run() { +function _omb_install_run { if [[ :$install_opts: == *:dry-run:* ]]; then printf '%s\n' "$BOLD$GREEN[dryrun]$NORMAL $BOLD$*$NORMAL" >&5 else @@ -110,7 +110,7 @@ _omb_install_run() { fi } -_omb_install_banner() { +function _omb_install_banner { # MOTD message :) printf '%s' "$GREEN" printf '%s\n' \ @@ -126,7 +126,7 @@ _omb_install_banner() { ## @fn _omb_install_user_bashrc ## @var[in] install_opts ## @var[in] OSH -_omb_install_user_bashrc() { +function _omb_install_user_bashrc { printf "${BLUE}Looking for an existing bash config...${NORMAL}\n" if [[ -f ~/.bashrc || -h ~/.bashrc ]]; then local bashrc_backup=~/.bashrc.omb-backup-$(date +%Y%m%d%H%M%S) @@ -169,7 +169,7 @@ export OSH='${OSH//\'/\'\\\'\'}' fi } -_omb_install_system_bashrc() { +function _omb_install_system_bashrc { printf "${BLUE}Creating a bashrc template at '$OSH/bashrc'...${NORMAL}\n" local 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" } -_omb_install_main() { +function _omb_install_main { # Use colors, but only if connected to a terminal, and that terminal # supports them. if type -P tput &>/dev/null; then diff --git a/tools/uninstall.sh b/tools/uninstall.sh index e4678e8..ffc279a 100755 --- a/tools/uninstall.sh +++ b/tools/uninstall.sh @@ -3,12 +3,12 @@ # Note: this file is intentionally written in POSIX sh so that oh-my-bash can # 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 } # 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= printf '%s\n' "Looking for original bash config..." IFS='