Update the t script
This commit is contained in:
parent
bf4789fb11
commit
7832d6b0b6
23
bin/t
23
bin/t
|
@ -14,9 +14,9 @@ if [[ -z "${selected}" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
session_name=$(basename "${selected}" | sed 's/\./-/g')
|
session_name=$(basename "${selected}" | sed 's/\./-/g')
|
||||||
tmux_running=$(pgrep tmux)
|
|
||||||
|
|
||||||
session_path="${selected}"
|
session_path="${selected}"
|
||||||
|
|
||||||
|
# Git worktrees.
|
||||||
if [[ -e "${selected}/main" ]]; then
|
if [[ -e "${selected}/main" ]]; then
|
||||||
session_path="${selected}/main"
|
session_path="${selected}/main"
|
||||||
fi
|
fi
|
||||||
|
@ -25,20 +25,15 @@ if tmux has-session -t "${session_name}" 2> /dev/null; then
|
||||||
tmux attach -t "${session_name}"
|
tmux attach -t "${session_name}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If a .tmux file exists within the selected directory, run it with the
|
# If a .tmux file exists, run it with the generated session name and path.
|
||||||
# generated session name.
|
|
||||||
if [[ -e "${session_path}/.tmux" ]]; then
|
if [[ -e "${session_path}/.tmux" ]]; then
|
||||||
"${session_path}/.tmux" "${session_name}" "${selected}/main"
|
"${session_path}/.tmux" "${session_name}" "${session_path}"
|
||||||
|
exit
|
||||||
|
elif [[ -e "${session_path}/.ignored/.tmux" ]]; then
|
||||||
|
"${session_path}/.ignored/.tmux" "${session_name}" "${session_path}"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "${TMUX:-}" ]] && [[ -z "${tmux_running}" ]]; then
|
tmux new-session -d -s "${session_name}" -c "${session_path}"
|
||||||
tmux new-session -s "${session_name}" -c "${session_path}"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! tmux has-session -t "${session_name}" 2> /dev/null; then
|
tmux switch-client -t "${session_name}" || tmux attach -t "${session_name}"
|
||||||
tmux new-session -ds "${session_name}" -c "${session_path}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
tmux switch-client -t "${session_name}"
|
|
||||||
|
|
Loading…
Reference in a new issue