commit 95bde49b1c5e889abb8d0a963891f7b915cafe61 parent f469b0efa305decb72eb07cde130f6eb000e8058 Author: Vincent Demeester <vincent@sbr.pm> Date: Thu, 17 Aug 2023 12:15:02 +0200 Add tm.sh to scripts Signed-off-by: Vincent Demeester <vincent@sbr.pm> Diffstat:
A | nix/packages/my/scripts/bin/tm.sh | | | 17 | +++++++++++++++++ |
M | nix/packages/my/scripts/default.nix | | | 2 | +- |
M | users/vincent/core/tmux/tmux.conf | | | 4 | ++++ |
3 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/nix/packages/my/scripts/bin/tm.sh b/nix/packages/my/scripts/bin/tm.sh @@ -0,0 +1,17 @@ +#!/bin/sh +tm() { + if [ -z $1 ]; then + tmux switch-client -l + else + if [ -z "$TMUX" ]; then + tmux new-session -As $1 + else + if ! tmux has-session -t $1 2>/dev/null; then + TMUX= tmux new-session -ds $1 + fi + tmux switch-client -t $1 + fi + fi +} + +tm $1 diff --git a/nix/packages/my/scripts/default.nix b/nix/packages/my/scripts/default.nix @@ -1,7 +1,7 @@ { stdenv }: stdenv.mkDerivation { - name = "vde-scripts-0.3"; + name = "vde-scripts-0.4"; builder = ./builder.sh; src = ./.; } diff --git a/users/vincent/core/tmux/tmux.conf b/users/vincent/core/tmux/tmux.conf @@ -92,3 +92,6 @@ set-option -g visual-bell on set-option -g visual-silence off set-window-option -g monitor-activity on set-option -g bell-action none + +bind m switch-client -l +bind M command-prompt -p 'switch session:' "run \"tm.sh '%%'\""+ \ No newline at end of file