mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-12-14 11:57:34 +00:00
add programs.tmux.enableFzf option
This commit is contained in:
parent
81b8a44e40
commit
8b8cab4e81
3 changed files with 26 additions and 3 deletions
|
@ -47,6 +47,7 @@ let
|
|||
programs.tmux.loginShell = "${pkgs.lnl.zsh}/bin/zsh -l";
|
||||
programs.tmux.enableSensible = true;
|
||||
programs.tmux.enableMouse = true;
|
||||
programs.tmux.enableFzf = true;
|
||||
programs.tmux.enableVim = true;
|
||||
|
||||
programs.tmux.tmuxConfig = ''
|
||||
|
|
|
@ -15,6 +15,14 @@ let
|
|||
|
||||
tmuxOptions = concatMapStringsSep "\n" (attr: attr.text) (attrValues cfg.tmuxOptions);
|
||||
|
||||
fzfTmuxSession = pkgs.writeScript "fzf-tmux-session" ''
|
||||
#! ${stdenv.shell}
|
||||
set -e
|
||||
|
||||
session=$(tmux list-sessions -F '#{session_name}' | fzf --query="$1" --exit-0)
|
||||
tmux switch-client -t "$session"
|
||||
'';
|
||||
|
||||
in {
|
||||
options = {
|
||||
|
||||
|
@ -44,6 +52,15 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
programs.tmux.enableFzf = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
example = true;
|
||||
description = ''
|
||||
Enable fzf keybindings for selecting sessions and panes.
|
||||
'';
|
||||
};
|
||||
|
||||
programs.tmux.enableVim = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
|
@ -102,6 +119,11 @@ in {
|
|||
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
|
||||
'';
|
||||
|
||||
programs.tmux.tmuxOptions.fzf.text = mkIf cfg.enableFzf ''
|
||||
bind-key -n M-p run "tmux split-window -p 40 -c '#{pane_current_path}' 'tmux send-keys -t #{pane_id} \"$(fzf -m | paste -sd\\ -)\"'"
|
||||
bind-key -n M-s run "tmux split-window -p 40 'tmux send-keys -t #{pane_id} \"$(${fzfTmuxSession})\"'"
|
||||
'';
|
||||
|
||||
programs.tmux.tmuxOptions.vim.text = mkIf cfg.enableVim (''
|
||||
setw -g mode-keys vi
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ in
|
|||
};
|
||||
|
||||
text = mkOption {
|
||||
default = null;
|
||||
type = types.nullOr types.lines;
|
||||
type = types.lines;
|
||||
default = "";
|
||||
description = ''
|
||||
Text of the file.
|
||||
'';
|
||||
|
@ -50,7 +50,7 @@ in
|
|||
|
||||
config = {
|
||||
|
||||
source = mkIf (config.text != null) (mkDefault sourceDrv);
|
||||
source = mkIf (config.text != "") (mkDefault sourceDrv);
|
||||
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue