feat(tmux): add tmux-sessionizer
parent
af1f1fec2e
commit
414a3a1fdf
|
@ -3,6 +3,37 @@
|
|||
with lib;
|
||||
let
|
||||
cfg = config.my.programs.tmux;
|
||||
|
||||
tmux-sessionizer = pkgs.writeShellApplication {
|
||||
name = "ts";
|
||||
runtimeInputs = with pkgs; [ tmux findutils coreutils procps fd ];
|
||||
text = ''
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [[ $# -eq 1 ]]; then
|
||||
selected=$1
|
||||
else
|
||||
selected=$(fd -gH '.git' ~/ --min-depth 1 --max-depth 5 --type d --prune --exec dirname {} | fzf)
|
||||
fi
|
||||
|
||||
if [[ -z $selected ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
selected_name=$(basename "$selected" | tr . _)
|
||||
|
||||
if ! tmux has-session -t="$selected_name" 2> /dev/null; then
|
||||
tmux new-session -ds "$selected_name" -c "$selected"
|
||||
fi
|
||||
|
||||
if [[ -z ''${TMUX+x} ]]; then
|
||||
tmux attach -t "$selected_name"
|
||||
else
|
||||
tmux switch-client -t "$selected_name"
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
||||
in
|
||||
{
|
||||
options.my.programs.tmux = {
|
||||
|
@ -12,22 +43,24 @@ in
|
|||
|
||||
config = mkIf cfg.enable {
|
||||
my.shell.abbreviations.t = "tmux";
|
||||
home-manager.users.moritz.programs.tmux = {
|
||||
enable = true;
|
||||
clock24 = true;
|
||||
customPaneNavigationAndResize = true;
|
||||
keyMode = "vi";
|
||||
mouse = true;
|
||||
newSession = true;
|
||||
prefix = "C-Space";
|
||||
sensibleOnTop = false;
|
||||
plugins = with pkgs.tmuxPlugins; [
|
||||
sensible
|
||||
tmux-fzf
|
||||
yank
|
||||
];
|
||||
};
|
||||
|
||||
home-manager.users.moritz.home.packages = [ tmux-sessionizer ];
|
||||
home-manager.users.moritz.programs = {
|
||||
tmux = {
|
||||
enable = true;
|
||||
clock24 = true;
|
||||
customPaneNavigationAndResize = true;
|
||||
keyMode = "vi";
|
||||
mouse = true;
|
||||
newSession = true;
|
||||
prefix = "C-Space";
|
||||
sensibleOnTop = false;
|
||||
plugins = with pkgs.tmuxPlugins; [
|
||||
sensible
|
||||
tmux-fzf
|
||||
yank
|
||||
];
|
||||
};
|
||||
fzf.tmux.enableShellIntegration = true;
|
||||
fish.interactiveShellInit =
|
||||
let
|
||||
|
@ -39,11 +72,11 @@ in
|
|||
if ! fish_is_root_user && test "$TERM_PROGRAM" != 'vscode' && ${insideVariableMissing}
|
||||
if test -z $tmux_autostarted
|
||||
set -x tmux_autostarted true
|
||||
tmux a
|
||||
ts
|
||||
end
|
||||
end
|
||||
'';
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue