From 86ee41ba1e6cc07804573f040fcb7e1cf27773ac Mon Sep 17 00:00:00 2001 From: Tim McCarthy Date: Mon, 17 May 2021 12:21:51 -0700 Subject: [PATCH] Add .dotfiles/bin directory and tat command --- bin/tat | 22 ++++++++++++++++++++++ fish/config.fish | 1 + 2 files changed, 23 insertions(+) create mode 100755 bin/tat diff --git a/bin/tat b/bin/tat new file mode 100755 index 0000000..e9c8100 --- /dev/null +++ b/bin/tat @@ -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 diff --git a/fish/config.fish b/fish/config.fish index 93bba8b..52091d5 100644 --- a/fish/config.fish +++ b/fish/config.fish @@ -7,6 +7,7 @@ set -g -x EDITOR "emacsclient" set -g -x ALTERNATE_EDITOR "vim" # Setup PATH +ensure_path ~/.dotfiles/bin ensure_path ~/bin ensure_path ~/.emacs.d/bin