Skip to content

Commit

Permalink
Merge branch '_omb_util_print'
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Sep 8, 2024
2 parents 1a7ef75 + 4309ed7 commit 770d6ef
Show file tree
Hide file tree
Showing 65 changed files with 518 additions and 477 deletions.
4 changes: 2 additions & 2 deletions aliases/misc.aliases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# 1. FILE AND FOLDER MANAGEMENT
# -------------------------------

alias numFiles='echo $(ls -1 | wc -l)' # numFiles: Count of non-hidden files in current dir
alias numFiles='_omb_util_print $(ls -1 | wc -l)' # numFiles: Count of non-hidden files in current dir
alias make1mb='truncate -s 1m ./1MB.dat' # make1mb: Creates a file of 1mb size (all zeros)
alias make5mb='truncate -s 5m ./5MB.dat' # make5mb: Creates a file of 5mb size (all zeros)
alias make10mb='truncate -s 10m ./10MB.dat' # make10mb: Creates a file of 10mb size (all zeros)
Expand Down Expand Up @@ -95,7 +95,7 @@ alias mountReadWrite='mount -uw /' # mountReadWrite: For use when booted in
alias bdate="date '+%a, %b %d %Y %T %Z'"
alias cal3='cal -3'
alias da='date "+%Y-%m-%d %A %T %Z"'
alias daysleft='echo "There are $(($(date +%j -d"Dec 31, $(date +%Y)")-$(date +%j))) left in year $(date +%Y)."'
alias daysleft='_omb_util_print "There are $(($(date +%j -d"Dec 31, $(date +%Y)")-$(date +%j))) left in year $(date +%Y)."'
alias epochtime='date +%s'
alias mytime='date +%H:%M:%S'
alias secconvert='date -d@1234567890'
Expand Down
2 changes: 1 addition & 1 deletion completions/django.completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function _omb_completion_django_init {
python=${python##*/}
[[ $python ]] && pythons+=("$python")
done
_omb_util_split pythons "$(printf '%s\n' "${pythons[@]}" | sort -u)" $'\n'
_omb_util_split pythons "$(_omb_util_print_lines "${pythons[@]}" | sort -u)" $'\n'
fi

complete -F _omb_completion_django_python -o default "${pythons[@]}"
Expand Down
8 changes: 4 additions & 4 deletions completions/gh.completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ EOF
# HOST - Host to be looked-up in hub config. Default is "github.com"
function __hub_github_user {
if [ -n "$GITHUB_USER" ]; then
echo $GITHUB_USER
_omb_util_print $GITHUB_USER
return
fi
local line h k v host=${1:-github.com} config=${HUB_CONFIG:-~/.config/gh}
Expand All @@ -299,7 +299,7 @@ EOF
k=${k#* }
v=${v#* }
if [ "$h" = "$host" ] && [ "$k" = "user" ]; then
echo "$v"
_omb_util_print "$v"
break
fi
done < "$config"
Expand Down Expand Up @@ -343,7 +343,7 @@ EOF
repo=${i#*:}
_omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/remotes/${remote}/" | while read branch; do
echo "${repo}:${branch#${remote}/}"
_omb_util_print "${repo}:${branch#${remote}/}"
done
done
fi
Expand All @@ -357,7 +357,7 @@ EOF
if [ -d "$dir" ]; then
_omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/remotes/${remote}/" | while read i; do
echo "${i#${remote}/}"
_omb_util_print "${i#${remote}/}"
done
_omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/tags/"
Expand Down
12 changes: 6 additions & 6 deletions completions/git_flow_avh.completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ __git_flow_prefix ()
{
case "$1" in
feature|bugfix|release|hotfix|support)
_omb_prompt_git config "gitflow.prefix.$1" 2> /dev/null || echo "$1/"
_omb_prompt_git config "gitflow.prefix.$1" 2> /dev/null || _omb_util_print "$1/"
return
;;
esac
Expand All @@ -561,7 +561,7 @@ __git_flow_list_local_branches ()
while read -r entry; do
eval "$entry"
ref="${ref#$prefix}"
echo "$ref"
_omb_util_print "$ref"
done | sort
else
_omb_prompt_git for-each-ref --format="ref=%(refname:short)" refs/heads/ | sort
Expand All @@ -572,25 +572,25 @@ __git_flow_list_local_branches ()
__git_flow_list_remote_branches ()
{
local prefix="$(__git_flow_prefix $1)"
local origin="$(_omb_prompt_git config gitflow.origin 2> /dev/null || echo "origin")"
local origin="$(_omb_prompt_git config gitflow.origin 2> /dev/null || _omb_util_print "origin")"
_omb_prompt_git for-each-ref --shell --format='%(refname:short)' refs/remotes/$origin/$prefix | \
while read -r entry; do
eval "$entry"
ref="${ref##$prefix}"
echo "$ref"
_omb_util_print "$ref"
done | sort
}

__git_flow_list_branches ()
{
local origin="$(_omb_prompt_git config gitflow.origin 2> /dev/null || echo "origin")"
local origin="$(_omb_prompt_git config gitflow.origin 2> /dev/null || _omb_util_print "origin")"
if [ -n "$1" ]; then
local prefix="$(__git_flow_prefix $1)"
_omb_prompt_git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix refs/remotes/$origin/$prefix | \
while read -r entry; do
eval "$entry"
ref="${ref##$prefix}"
echo "$ref"
_omb_util_print "$ref"
done | sort
else
_omb_prompt_git for-each-ref --format="%(refname:short)" refs/heads/ refs/remotes/$origin | sort
Expand Down
6 changes: 3 additions & 3 deletions completions/gradle.completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ function __gradle {
newest_gradle_file=$(find . -type f -name build.gradle -newer "$cache_dir/$gradle_files_checksum")
if [[ $newest_gradle_file ]]; then
tasks=$(eval "$parsing_command")
[[ $tasks ]] && echo "$tasks" > "$cache_dir/$gradle_files_checksum"
[[ $tasks ]] && _omb_util_print "$tasks" > "$cache_dir/$gradle_files_checksum"
else
tasks=$(< "$cache_dir/$gradle_files_checksum")
touch "$cache_dir/$gradle_files_checksum"
fi
else
tasks=$(eval "$parsing_command")
[[ $tasks ]] && echo "$tasks" > "$cache_dir/$gradle_files_checksum"
[[ $tasks ]] && _omb_util_print "$tasks" > "$cache_dir/$gradle_files_checksum"
fi
else
tasks=$(eval "$parsing_command")
[[ $tasks ]] && echo "$tasks" > "$cache_dir/$gradle_files_checksum"
[[ $tasks ]] && _omb_util_print "$tasks" > "$cache_dir/$gradle_files_checksum"
fi
COMPREPLY=($(compgen -W "$tasks" -- "$cur"))
}
Expand Down
2 changes: 1 addition & 1 deletion completions/grunt.completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function _grunt_gruntfile {
local gruntfile
for gruntfile in "$curpath"/{G,g}runtfile.{js,coffee}; do
if [[ -e $gruntfile ]]; then
echo "$gruntfile"
_omb_util_print "$gruntfile"
return 0
fi
done
Expand Down
8 changes: 4 additions & 4 deletions completions/hub.completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ EOF
# HOST - Host to be looked-up in hub config. Default is "github.com"
function __hub_github_user {
if [ -n "$GITHUB_USER" ]; then
echo $GITHUB_USER
_omb_util_print $GITHUB_USER
return
fi
local line h k v host=${1:-github.com} config=${HUB_CONFIG:-~/.config/hub}
Expand All @@ -321,7 +321,7 @@ EOF
k=${k#* }
v=${v#* }
if [ "$h" = "$host" ] && [ "$k" = "user" ]; then
echo "$v"
_omb_util_print "$v"
break
fi
done < "$config"
Expand Down Expand Up @@ -365,7 +365,7 @@ EOF
repo=${i#*:}
_omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/remotes/${remote}/" | while read branch; do
echo "${repo}:${branch#${remote}/}"
_omb_util_print "${repo}:${branch#${remote}/}"
done
done
fi
Expand All @@ -379,7 +379,7 @@ EOF
if [ -d "$dir" ]; then
_omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/remotes/${remote}/" | while read i; do
echo "${i#${remote}/}"
_omb_util_print "${i#${remote}/}"
done
_omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/tags/"
Expand Down
6 changes: 3 additions & 3 deletions completions/maven.completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ function __find_mvn_projects {
local withoutPom=${LINE%/pom.xml}
local module=${withoutPom#./}
if [[ ! $module ]]; then
echo "."
_omb_util_print "."
else
echo $module
_omb_util_print $module
fi
done
}
Expand Down Expand Up @@ -89,7 +89,7 @@ function _realpath {
}

# reassemble realpath
echo "$tmppwd/${1##*/}"
_omb_util_print "$tmppwd/${1##*/}"
return 1 #success
}

Expand Down
2 changes: 1 addition & 1 deletion completions/sdkman.completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if ! declare -F __sdkman_build_version_csv &>/dev/null; then
done
versions_csv=${versions_csv%?}
fi
echo "$versions_csv"
_omb_util_print "$versions_csv"
}
fi

Expand Down
4 changes: 2 additions & 2 deletions completions/tmux.completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function _tmux {
local skip_next=0
for ((i = 1; i <= COMP_CWORD; i++)); do
if ((skip_next == 1)); then
#echo "Skipping"
#_omb_util_print "Skipping"
skip_next=0;
elif [[ ${COMP_WORDS[i]} != -* ]]; then
cmd=${COMP_WORDS[i]}
Expand All @@ -82,7 +82,7 @@ function _tmux {
skip_next=0
for ((i = 1; i <= COMP_CWORD; i++)); do
if ((skip_next == 1)); then
#echo "Skipping"
#_omb_util_print "Skipping"
skip_next=0
elif [[ ${COMP_WORDS[i]} == -* ]]; then
option=${COMP_WORDS[i]}
Expand Down
6 changes: 3 additions & 3 deletions completions/vagrant.completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ function __pwdln {
((itr++))
pwdmod="${pwdmod#*/}"
done
echo -n $((itr-1))
_omb_util_put $((itr-1))
}

function __vagrantinvestigate {
if [[ -f $PWD/.vagrant || -d $PWD/.vagrant ]]; then
echo "$PWD/.vagrant"
_omb_util_print "$PWD/.vagrant"
return 0
else
pwdmod2=$PWD
for ((i = 2; i <= $(__pwdln); i++)); do
pwdmod2=${pwdmod2%/*}
if [[ -f $pwdmod2/.vagrant || -d $pwdmod2/.vagrant ]]; then
echo "$pwdmod2/.vagrant"
_omb_util_print "$pwdmod2/.vagrant"
return 0
fi
done
Expand Down
11 changes: 9 additions & 2 deletions completions/vault.completion.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
#! bash oh-my-bash.module
#
# Taken from https://github.com/iljaweis/vault-bash-completion
#
# * 2024-08-13 Confirmed that the current version is up-to-date with the
# archived version:
# https://github.com/iljaweis/vault-bash-completion/blob/c42047c5bd6aca9045b7945db1c41654080076e1/vault-bash-completion.sh
#
# ---------------------------------------------------------------------------
# vault-bash-completion
#
Expand All @@ -11,7 +18,7 @@ function _vault_mounts {
(
set -euo pipefail
if ! vault mounts 2> /dev/null | awk 'NR > 1 {print $1}'; then
echo "secret"
_omb_util_print "secret"
fi
)
}
Expand All @@ -31,7 +38,7 @@ function _vault {
if [[ $prev =~ ^(policies|policy-write|policy-delete) ]]; then
local policies=$(vault policies 2> /dev/null)
COMPREPLY=($(compgen -W "$policies" -- $cur))
elif (($(echo "$line" | wc -w) <= 2)); then
elif (($(wc -w <<< "$line") <= 2)); then
if [[ $line =~ ^vault\ (read|write|delete|list)\ $ ]]; then
COMPREPLY=($(compgen -W "$(_vault_mounts)" -- ''))
else
Expand Down
Loading

0 comments on commit 770d6ef

Please sign in to comment.