Commit 95bde49b1c5e

Vincent Demeester <vincent@sbr.pm>
2023-08-17 12:15:02
Add tm.sh to scripts
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent f469b0e
Changed files (3)
nix
packages
my
users
vincent
core
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
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 = ./.;
 }
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