|
@ -1,13 +1,48 @@ |
|
|
#!/usr/bin/env sh |
|
|
#!/usr/bin/env sh |
|
|
|
|
|
|
|
|
WORKSPACES=${WORKSPACES:-$HOME/Documents} |
|
|
|
|
|
|
|
|
WORKSPACES=${WORKSPACES:-$HOME/Documents:$HOME/docs/prg} |
|
|
|
|
|
|
|
|
IFS=':' findargs=$WORKSPACES |
|
|
IFS=':' findargs=$WORKSPACES |
|
|
|
|
|
|
|
|
|
|
|
while test $# -gt 0; do |
|
|
|
|
|
case "$1" in |
|
|
|
|
|
-d|--depth) |
|
|
|
|
|
shift |
|
|
if test -z "$1"; then |
|
|
if test -z "$1"; then |
|
|
sessiondir="$(find $findargs -maxdepth 2 -type d 2>/dev/null | fzf)" |
|
|
|
|
|
|
|
|
echo "No appropriate option given after depth" |
|
|
|
|
|
exit 1 |
|
|
else |
|
|
else |
|
|
|
|
|
depth="$1" |
|
|
|
|
|
fi |
|
|
|
|
|
shift; |
|
|
|
|
|
;; |
|
|
|
|
|
-*) |
|
|
|
|
|
echo "Invalid option $1" |
|
|
|
|
|
exit 1 |
|
|
|
|
|
;; |
|
|
|
|
|
*) |
|
|
sessiondir="$1" |
|
|
sessiondir="$1" |
|
|
|
|
|
shift; |
|
|
|
|
|
;; |
|
|
|
|
|
esac |
|
|
|
|
|
done |
|
|
|
|
|
|
|
|
|
|
|
if test -z "$sessiondir"; then |
|
|
|
|
|
if ! test -z "$depth" && test "$depth" -eq 0; then |
|
|
|
|
|
sessiondir="$(find $findargs\ |
|
|
|
|
|
\! -iwholename '*.git*'\ |
|
|
|
|
|
\! -iwholename '*node_modules*'\ |
|
|
|
|
|
\! -iwholename '*__pycache__*'\ |
|
|
|
|
|
\! -iwholename '*venv*'\ |
|
|
|
|
|
-type d 2>/dev/null | fzf)" |
|
|
|
|
|
else |
|
|
|
|
|
sessiondir="$(find $findargs -maxdepth ${depth:-2}\ |
|
|
|
|
|
\! -iwholename '*.git*'\ |
|
|
|
|
|
\! -iwholename '*node_modules*'\ |
|
|
|
|
|
\! -iwholename '*__pycache__*'\ |
|
|
|
|
|
\! -iwholename '*venv*'\ |
|
|
|
|
|
-type d 2>/dev/null | fzf)" |
|
|
|
|
|
fi |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
if test -z "$sessiondir" || ! test -d "$sessiondir"; then |
|
|
if test -z "$sessiondir" || ! test -d "$sessiondir"; then |
|
@ -23,5 +58,9 @@ else |
|
|
if ! tmux has-session -t="$name" 2> /dev/null; then |
|
|
if ! tmux has-session -t="$name" 2> /dev/null; then |
|
|
tmux new-session -d -c "$sessiondir" -s "$name" |
|
|
tmux new-session -d -c "$sessiondir" -s "$name" |
|
|
fi |
|
|
fi |
|
|
|
|
|
if test -z "$TMUX"; then |
|
|
|
|
|
tmux attach -t "$name" |
|
|
|
|
|
else |
|
|
tmux switch-client -t "$name" |
|
|
tmux switch-client -t "$name" |
|
|
fi |
|
|
fi |
|
|
|
|
|
fi |