mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 14:49: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,
|
writeShellApplication,
|
||||||
tmux,
|
tmux,
|
||||||
|
procps,
|
||||||
symlinkJoin,
|
symlinkJoin,
|
||||||
}: let
|
}: let
|
||||||
tmux-register-session = writeShellApplication {
|
tmux-register-session = writeShellApplication {
|
||||||
|
|
@ -14,10 +15,24 @@
|
||||||
fi
|
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
|
in
|
||||||
symlinkJoin {
|
symlinkJoin {
|
||||||
name = "tmux-sessionizer";
|
name = "tmux-sessionizer";
|
||||||
paths = [
|
paths = [
|
||||||
tmux-register-session
|
tmux-register-session
|
||||||
|
tmux-maybe-create
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue