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

@@ -14,33 +14,34 @@ Resolve a command alias to it's full name."
fi
case "$1" in
"session" | "ses" | "s" )
"session" | "ses" | "s")
echo "load-session"
;;
"window" | "win" | "w" )
"window" | "win" | "w")
echo "load-window"
;;
"new-ses" | "nses" | "ns" )
"new-ses" | "nses" | "ns")
echo "new-session"
;;
"new-win" | "nwin" | "nw" )
"new-win" | "nwin" | "nw")
echo "new-window"
;;
"edit-ses" | "eses" | "es" )
"edit-ses" | "eses" | "es")
echo "edit-session"
;;
"edit-win" | "ewin" | "ew" )
"edit-win" | "ewin" | "ew")
echo "edit-window"
;;
"l" )
"l")
echo "list"
;;
"list-ses" | "lses" | "ls" )
"list-ses" | "lses" | "ls")
echo "list-sessions"
;;
"list-win" | "lwin" | "lw" )
"list-win" | "lwin" | "lw")
echo "list-windows"
;;
* )
*)
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

@@ -20,11 +20,11 @@ if calling-complete "$@"; then
fi
has-completions() {
grep -i "^# Provide tmuxifier completions" "$1" >/dev/null
grep -i "^# Provide tmuxifier completions" "$1" > /dev/null
}
if [ -z "$1" ]; then
echo "$(tmuxifier-help completions $@)" >&2
tmuxifier-help completions "$@" >&2
exit 1
fi

View File

@@ -14,8 +14,8 @@ Outputs the name of the current Tmux session."
fi
if [ -n "$TMUX" ]; then
for item in $(tmuxifier-tmux list-pane -F "#{session_name}");do
echo $item
for item in $(tmuxifier-tmux list-pane -F "#{session_name}"); do
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

@@ -18,7 +18,7 @@ if calling-complete "$@"; then
fi
has-help() {
grep -i "^# Provide tmuxifier help" "$1" >/dev/null
grep -i "^# Provide tmuxifier help" "$1" > /dev/null
}
if [ -z "$1" ]; then

View File

@@ -14,25 +14,25 @@ if [ -z "$shell" ]; then
fi
case "$shell" in
bash )
bash)
profile='~/.bash_profile'
;;
zsh )
zsh)
profile='~/.zshrc'
;;
ksh )
ksh)
profile='~/.profile'
;;
csh )
csh)
profile='~/.cshrc'
;;
tcsh )
tcsh)
profile='~/.tcshrc'
;;
fish )
fish)
profile='~/.config/fish/config.fish'
;;
* )
*)
profile='shell init file'
;;
esac
@@ -45,15 +45,15 @@ Load Tmuxifier by adding the following to your ${profile}:
"
case "$shell" in
csh | tcsh )
csh | tcsh)
echo " eval \`tmuxifier init -\`
"
;;
fish )
fish)
echo " eval (tmuxifier init -)
"
;;
* )
*)
echo " eval \"\$(tmuxifier init -)\"
"
;;
@@ -64,26 +64,26 @@ 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
case "$shell" in
csh | tcsh )
csh | tcsh)
echo "setenv TMUXIFIER \"$TMUXIFIER\";"
echo "source \"\$TMUXIFIER/init.tcsh\";"
;;
fish )
fish)
echo "set -gx TMUXIFIER \"$TMUXIFIER\";"
# fish shell 2.0.0 does not have the source alias
if [[ $(fish --version 2>&1 | awk -F'version ' '{print $2}') = '2.0.0' ]]; then
echo ". \"\$TMUXIFIER/init.fish\";"
else
echo "source \"\$TMUXIFIER/init.fish\";"
fi
fi
;;
* )
*)
echo "export TMUXIFIER=\"$TMUXIFIER\";"
echo "source \"\$TMUXIFIER/init.sh\";"
;;

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

View File

@@ -19,16 +19,16 @@ fi
# The vercomp() function is shamelessly ripped/borrowed from the following
# StackOverflow answer: http://stackoverflow.com/a/4025065/42146
vercomp () {
vercomp() {
if [[ $1 == $2 ]]; then return 0; fi
local IFS=.
local i ver1=($1) ver2=($2)
# fill empty fields in ver1 with zeros
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do ver1[i]=0; done
for ((i = ${#ver1[@]}; i < ${#ver2[@]}; i++)); do ver1[i]=0; done
for ((i=0; i<${#ver1[@]}; i++)); do
for ((i = 0; i < ${#ver1[@]}; i++)); do
# fill empty fields in ver2 with zeros
if [[ -z ${ver2[i]} ]]; then ver2[i]=0; fi
@@ -63,8 +63,8 @@ else
vercomp "$version" "$1"
case $? in
0) echo '=';;
1) echo '>';;
2) echo '<';;
0) echo '=' ;;
1) echo '>' ;;
2) echo '<' ;;
esac
fi