style(shell): improve shell script formatting and quoting

Apply shfmt formatting and fix some schellcheck complaints.
This commit is contained in:
2025-11-25 02:52:36 +00:00
parent 9941b28063
commit adb008b301
17 changed files with 66 additions and 65 deletions

View File

@@ -214,8 +214,8 @@ load_window() {
if [ $# -gt 1 ]; then
window="$2"
else
window="${1/%.window.sh}"
window="${window/%.sh}"
window="${1/%.window.sh/}"
window="${window/%.sh/}"
fi
source "$file"
window=
@@ -258,8 +258,8 @@ load_session() {
if [ $# -gt 1 ]; then
session="$2"
else
session="${1/%.session.sh}"
session="${session/%.sh}"
session="${1/%.session.sh/}"
session="${session/%.sh/}"
fi
set_default_path=true
@@ -350,7 +350,6 @@ finalize_and_go_to_session() {
fi
}
#
# Internal functions
#
@@ -382,7 +381,7 @@ __get_current_window_index() {
-F "#{window_active}:#{window_index}" 2> /dev/null | grep "^1:")
if [ -n "$lookup" ]; then
echo "${lookup/1:}"
echo "${lookup/1:/}"
fi
}

View File

@@ -1,11 +1,11 @@
calling-help() {
if [[ " $@ " != *" --help "* ]] && [[ " $@ " != *" -h "* ]]; then
if [[ " $* " != *" --help "* ]] && [[ " $* " != *" -h "* ]]; then
return 1
fi
}
calling-complete() {
if [[ " $@ " != *" --complete "* ]]; then
if [[ " $* " != *" --complete "* ]]; then
return 1
fi
}

View File

@@ -43,4 +43,5 @@ case "$1" in
;;
*)
exit 1
;;
esac

View File

@@ -16,7 +16,8 @@ fi
shopt -s nullglob
{ for path in ${PATH//:/$'\n'}; do
{
for path in ${PATH//:/$'\n'}; do
for command in "${path}/tmuxifier-"*; do
command="${command##*tmuxifier-}"
echo "$command"

View File

@@ -24,7 +24,7 @@ has-completions() {
}
if [ -z "$1" ]; then
echo "$(tmuxifier-help completions $@)" >&2
tmuxifier-help completions "$@" >&2
exit 1
fi

View File

@@ -15,7 +15,7 @@ fi
if [ -n "$TMUX" ]; then
for item in $(tmuxifier-tmux list-pane -F "#{session_name}"); do
echo $item
echo "$item"
exit 0
done
fi

View File

@@ -22,7 +22,7 @@ if calling-complete "$@"; then
fi
if [ -z "$1" ]; then
echo "$(tmuxifier-help edit-session $@)" >&2
tmuxifier-help edit-session "$@" >&2
exit 1
fi

View File

@@ -22,7 +22,7 @@ if calling-complete "$@"; then
fi
if [ -z "$1" ]; then
echo "$(tmuxifier-help edit-window $@)" >&2
tmuxifier-help edit-window "$@" >&2
exit 1
fi

View File

@@ -64,8 +64,8 @@ Load Tmuxifier by adding the following to your ${profile}:
fi
# Print help if "-" argument is not given
if [[ " $@ " != *" - "* ]]; then
echo "$(tmuxifier-help init $@)" >&2
if [[ " $* " != *" - "* ]]; then
tmuxifier-help init "$@" >&2
exit 1
fi

View File

@@ -30,7 +30,7 @@ if calling-complete "$@"; then
fi
if [ -z "$1" ]; then
echo "$(tmuxifier-help load-session $@)" >&2
tmuxifier-help load-session "$@" >&2
exit 1
fi

View File

@@ -26,14 +26,14 @@ if calling-complete "$@"; then
fi
if [ -z "$1" ]; then
echo "$(tmuxifier-help load-window $@)" >&2
tmuxifier-help load-window "$@" >&2
exit 1
fi
# Load runtime functions.
source "$TMUXIFIER/lib/runtime.sh"
if [ ! -z $TMUX ]; then
if [ ! -z "$TMUX" ]; then
session="$(tmuxifier-current-session)"
load_window "$1"
else

View File

@@ -22,7 +22,7 @@ if calling-complete "$@"; then
fi
if [ -z "$1" ]; then
echo "$(tmuxifier-help new-session $@)" >&2
tmuxifier-help new-session "$@" >&2
exit 1
fi

View File

@@ -22,7 +22,7 @@ if calling-complete "$@"; then
fi
if [ -z "$1" ]; then
echo "$(tmuxifier-help new-window $@)" >&2
tmuxifier-help new-window "$@" >&2
exit 1
fi