Add .dotfiles/bin directory and tat command

This commit is contained in:
2021-05-17 12:21:51 -07:00
parent d9a25a0dd0
commit 86ee41ba1e
2 changed files with 23 additions and 0 deletions

22
bin/tat Executable file
View File

@@ -0,0 +1,22 @@
#!/bin/sh
#
# Attach or create tmux session named the same as current directory.
session_name="$(basename "$PWD" | tr . -)"
session_exists() {
tmux list-sessions | sed -E 's/:.*$//' | grep -q "^$session_name$"
}
not_in_tmux() {
[ -z "$TMUX" ]
}
if not_in_tmux; then
tmux new-session -As "$session_name"
else
if ! session_exists; then
(TMUX='' tmux new-session -Ad -s "$session_name")
fi
tmux switch-client -t "$session_name"
fi