From d1ebd50708b3391cf767ebb669af3f1434a17760 Mon Sep 17 00:00:00 2001 From: Jacopo De Simoi Date: Fri, 21 Jan 2022 18:43:59 -0500 Subject: [PATCH] Add tmux-guard This function executes its arguments only if within a ~tmux~ session --- zshrc.org | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/zshrc.org b/zshrc.org index 88b4afb..e84d902 100644 --- a/zshrc.org +++ b/zshrc.org @@ -157,7 +157,19 @@ setup-pi-webcam() :END: *** Misc helpers :pi:daily:android: - + - tmux guard + This function checks if we are in a tmux session before + executing the command; otherwise print an error and bail out +#+begin_src sh + tmux-guard() + { + if [[ -v TMUX ]]; then + $@ + else + echo tmux-guard: ensure you are in a tmux session to run $@ + fi + } +#+end_src - wttr.in #+begin_src sh wttr()