mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 06:39:14 +00:00
packages/tmux-sessionizer: maybe-create
This commit is contained in:
parent
d4c5b1c667
commit
ddeb5859b0
1 changed files with 15 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
writeShellApplication,
|
||||
tmux,
|
||||
procps,
|
||||
symlinkJoin,
|
||||
}: let
|
||||
tmux-register-session = writeShellApplication {
|
||||
|
|
@ -14,10 +15,24 @@
|
|||
fi
|
||||
'';
|
||||
};
|
||||
|
||||
tmux-maybe-create = writeShellApplication {
|
||||
name = "__tmux-maybe-create";
|
||||
runtimeInputs = [procps tmux];
|
||||
text = ''
|
||||
session_name="$1"
|
||||
session_dir="$2"
|
||||
|
||||
if ! pgrep tmux >/dev/null 2>&1 || ! tmux has -t="$session_name" 2>/dev/null; then
|
||||
tmux new-session -ds "$session_name" -c "$session_dir"
|
||||
fi
|
||||
'';
|
||||
};
|
||||
in
|
||||
symlinkJoin {
|
||||
name = "tmux-sessionizer";
|
||||
paths = [
|
||||
tmux-register-session
|
||||
tmux-maybe-create
|
||||
];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue