diff options
| author | Daiderd Jordan <daiderd@gmail.com> | 2016-11-07 22:47:17 +0100 |
|---|---|---|
| committer | Daiderd Jordan <daiderd@gmail.com> | 2016-11-07 22:47:17 +0100 |
| commit | 8b8cab4e8131d6bfe4bdf00362d9cee4bd6560d9 (patch) | |
| tree | 35f201f29ad3e93fbc7b2189250fb53549f682d0 /modules | |
| parent | 81b8a44e400569717385556c17b34eb9d14410c5 (diff) | |
add programs.tmux.enableFzf option
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/programs/tmux.nix | 22 | ||||
| -rw-r--r-- | modules/system/write-text.nix | 6 |
2 files changed, 25 insertions, 3 deletions
diff --git a/modules/programs/tmux.nix b/modules/programs/tmux.nix index ea17d3d..5f8264d 100644 --- a/modules/programs/tmux.nix +++ b/modules/programs/tmux.nix @@ -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 diff --git a/modules/system/write-text.nix b/modules/system/write-text.nix index f15fedd..1fc97dd 100644 --- a/modules/system/write-text.nix +++ b/modules/system/write-text.nix @@ -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); }; } |
