shell-wrappers: extend g-add script to allow non-tmux sessions
This commit is contained in:
parent
4f440e962b
commit
cd33a054b8
40
g-add.zsh
40
g-add.zsh
|
@ -8,11 +8,33 @@ if [[ -z $1 ]]; then
|
||||||
Options:
|
Options:
|
||||||
-p, --path PATH target directory to install into (defaults to ~/.local/bin)
|
-p, --path PATH target directory to install into (defaults to ~/.local/bin)
|
||||||
-d, --dot, -m, --multi create g.\$prog links, allowing multiple instances
|
-d, --dot, -m, --multi create g.\$prog links, allowing multiple instances
|
||||||
|
-n, --no-tmux don't launch with tmux
|
||||||
HELP
|
HELP
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
zparseopts -D -E p:=install_path -path:=install_path d=multi -dot=multi m=multi -multi=multi
|
zparseopts -D -E \
|
||||||
|
p:=install_path -path:=install_path \
|
||||||
|
d=multi -dot=multi m=multi -multi=multi \
|
||||||
|
n=notmux -no-tmux=notmux
|
||||||
|
|
||||||
|
|
||||||
|
do-install() {
|
||||||
|
local wrapper=$1
|
||||||
|
local install_path=$2
|
||||||
|
local prefix=$3
|
||||||
|
local prog=$4
|
||||||
|
local target="$prefix${prog:t}"
|
||||||
|
|
||||||
|
target="$prefix${prog:t}"
|
||||||
|
if [[ -e $install_path/${target} ]]; then
|
||||||
|
warning "${target} already exists at $install_path. Skipping."
|
||||||
|
else
|
||||||
|
check "Creating $prog link $target… "
|
||||||
|
ln -fsr lib/$wrapper $install_path/$target || fail
|
||||||
|
succeed
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [[ ! $install_path ]]; then
|
if [[ ! $install_path ]]; then
|
||||||
install_path=$HOME/.local/bin
|
install_path=$HOME/.local/bin
|
||||||
|
@ -20,15 +42,15 @@ else
|
||||||
install_path=${install_path[2]}
|
install_path=${install_path[2]}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ $notmux ]]; then
|
||||||
|
if [[ $multi ]]; then warning "Ignoring $multi, as no tmux is used"; fi
|
||||||
|
for prog in $@; do
|
||||||
|
do-install with-term $install_path g $prog
|
||||||
|
done
|
||||||
|
else
|
||||||
if [[ $multi ]]; then prefix='g.'; else prefix='g'; fi
|
if [[ $multi ]]; then prefix='g.'; else prefix='g'; fi
|
||||||
|
|
||||||
for prog in $@; do
|
for prog in $@; do
|
||||||
target="$prefix${prog:t}"
|
do-install g $install_path $prefix $prog
|
||||||
if [[ -e $install_path/${target} ]]; then
|
|
||||||
warning "${target} already exists at $install_path. Skipping."
|
|
||||||
else
|
|
||||||
check "Creating $target… "
|
|
||||||
ln -fsr lib/g $install_path/$target || fail
|
|
||||||
succeed
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
|
@ -5,4 +5,4 @@ zparseopts -D -E \
|
||||||
e:=execute -exec=execute -execute=execute \
|
e:=execute -exec=execute -execute=execute \
|
||||||
c:=class -class=class
|
c:=class -class=class
|
||||||
|
|
||||||
kitty -1 ${class+--class=}${class[2]} ${title:+-T} ${title[2]} ${=execute[2]} "$@"
|
kitty ${class+--class=}${class[2]} ${title+-T} ${title[2]} ${=execute[2]} "$@"
|
||||||
|
|
|
@ -8,4 +8,4 @@ else
|
||||||
server="qwerty";
|
server="qwerty";
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec x-terminal-emulator -t Weechat -e tmux new-session mosh "${server}" -- tmux attach "$@" -t weechat
|
exec x-terminal-emulator -t Weechat -e mosh "${server}" -- tmux attach "$@" -t weechat
|
||||||
|
|
Loading…
Reference in a new issue