feat(tmux): add tmux-new script

nixos
Moritz Böhme 2023-10-27 09:00:02 +02:00
parent 58c8efa332
commit 02d9e30ce7
Signed by: moritz
GPG Key ID: 970C6E89EB0547A9
3 changed files with 18 additions and 10 deletions

View File

@ -155,7 +155,7 @@ in
bind = $mainMod , M , exec , hyprctl keyword general:layout master bind = $mainMod , M , exec , hyprctl keyword general:layout master
bind = $mainMod , R , exec , rofi -show combi bind = $mainMod , R , exec , rofi -show combi
bind = $mainMod , RETURN , exec , kitty bind = $mainMod , RETURN , exec , kitty
bind = $mainMod SHIFT , RETURN , exec , kitty -- tmux new -A -s home bind = $mainMod SHIFT , RETURN , exec , kitty -- tmux new "ts || tn home ~"
# XF86 keys # XF86 keys
binde = , XF86AudioLowerVolume , exec , pamixer -d 5 binde = , XF86AudioLowerVolume , exec , pamixer -d 5

View File

@ -7,8 +7,7 @@ let
tmux-switch = pkgs.writeShellApplication { tmux-switch = pkgs.writeShellApplication {
name = "tmux-switch"; name = "tmux-switch";
runtimeInputs = with pkgs; [ tmux ]; runtimeInputs = with pkgs; [ tmux ];
text = '' text = /* bash */ ''
#!/usr/bin/env bash
if [[ -z ''${TMUX+x} ]]; then if [[ -z ''${TMUX+x} ]]; then
tmux attach -t "$1" tmux attach -t "$1"
else else
@ -19,7 +18,7 @@ let
tmux-sessionizer = pkgs.writeFishApplication { tmux-sessionizer = pkgs.writeFishApplication {
name = "ts"; name = "ts";
runtimeInputs = with pkgs; [ tmux findutils coreutils procps fd tmux-switch gawk ]; runtimeInputs = with pkgs; [ tmux findutils coreutils procps fd tmux-new gawk ];
text = readFile ./tmux-sessionizer/script.fish; text = readFile ./tmux-sessionizer/script.fish;
completions = readFile ./tmux-sessionizer/completions.fish; completions = readFile ./tmux-sessionizer/completions.fish;
}; };
@ -31,6 +30,17 @@ let
completions = readFile ./tmux-attach/completions.fish; completions = readFile ./tmux-attach/completions.fish;
}; };
tmux-new = pkgs.writeFishApplication {
name = "tn";
runtimeInputs = with pkgs; [ tmux ];
text = /* fish */ ''
if ! tmux has-session -t $argv[1] 2> /dev/null
tmux new-session -ds $argv[1] -c $argv[2]
end
tmux-switch $argv[1]
'';
};
in in
{ {
options.my.programs.tmux = { options.my.programs.tmux = {
@ -60,6 +70,8 @@ in
home-manager.users.moritz.home.packages = [ home-manager.users.moritz.home.packages = [
tmux-sessionizer tmux-sessionizer
tmux-attach tmux-attach
tmux-switch
tmux-new
]; ];
home-manager.users.moritz.programs = { home-manager.users.moritz.programs = {
tmux = { tmux = {
@ -97,7 +109,7 @@ in
if ! fish_is_root_user && test "$TERM_PROGRAM" != 'vscode' && ${insideVariableMissing} if ! fish_is_root_user && test "$TERM_PROGRAM" != 'vscode' && ${insideVariableMissing}
if test -z $tmux_autostarted if test -z $tmux_autostarted
set -x tmux_autostarted true set -x tmux_autostarted true
tmux new -A -s home tn home ~
end end
end end
''; '';

View File

@ -13,8 +13,4 @@ if not test -n "$selected_name"
exit 1 exit 1
end end
if ! tmux has-session -t $selected_name 2> /dev/null tn "$selected_name" "$selected"
tmux new-session -ds $selected_name -c $selected
end
tmux-switch $selected_name