···11+### key-bindings.fish ###
22+# ____ ____
33+# / __/___ / __/
44+# / /_/_ / / /_
55+# / __/ / /_/ __/
66+# /_/ /___/_/ key-bindings.fish
77+#
88+# - $FZF_TMUX_OPTS
99+# - $FZF_CTRL_T_COMMAND
1010+# - $FZF_CTRL_T_OPTS
1111+# - $FZF_CTRL_R_OPTS
1212+# - $FZF_ALT_C_COMMAND
1313+# - $FZF_ALT_C_OPTS
1414+1515+status is-interactive; or exit 0
1616+1717+1818+# Key bindings
1919+# ------------
2020+function fzf_key_bindings
2121+2222+ function __fzf_defaults
2323+ # $1: Prepend to FZF_DEFAULT_OPTS_FILE and FZF_DEFAULT_OPTS
2424+ # $2: Append to FZF_DEFAULT_OPTS_FILE and FZF_DEFAULT_OPTS
2525+ test -n "$FZF_TMUX_HEIGHT"; or set FZF_TMUX_HEIGHT 40%
2626+ echo "--height $FZF_TMUX_HEIGHT --bind=ctrl-z:ignore" $argv[1]
2727+ command cat "$FZF_DEFAULT_OPTS_FILE" 2> /dev/null
2828+ echo $FZF_DEFAULT_OPTS $argv[2]
2929+ end
3030+3131+ # Store current token in $dir as root for the 'find' command
3232+ function fzf-file-widget -d "List files and folders"
3333+ set -l commandline (__fzf_parse_commandline)
3434+ set -lx dir $commandline[1]
3535+ set -l fzf_query $commandline[2]
3636+ set -l prefix $commandline[3]
3737+3838+ test -n "$FZF_TMUX_HEIGHT"; or set FZF_TMUX_HEIGHT 40%
3939+ begin
4040+ set -lx FZF_DEFAULT_OPTS (__fzf_defaults "--reverse --walker=file,dir,follow,hidden --scheme=path --walker-root='$dir'" "$FZF_CTRL_T_OPTS")
4141+ set -lx FZF_DEFAULT_COMMAND "$FZF_CTRL_T_COMMAND"
4242+ set -lx FZF_DEFAULT_OPTS_FILE ''
4343+ eval (__fzfcmd)' -m --query "'$fzf_query'"' | while read -l r; set result $result $r; end
4444+ end
4545+ if [ -z "$result" ]
4646+ commandline -f repaint
4747+ return
4848+ else
4949+ # Remove last token from commandline.
5050+ commandline -t ""
5151+ end
5252+ for i in $result
5353+ commandline -it -- $prefix
5454+ commandline -it -- (string escape $i)
5555+ commandline -it -- ' '
5656+ end
5757+ commandline -f repaint
5858+ end
5959+6060+ function fzf-history-widget -d "Show command history"
6161+ test -n "$FZF_TMUX_HEIGHT"; or set FZF_TMUX_HEIGHT 40%
6262+ begin
6363+ set -l FISH_MAJOR (echo $version | cut -f1 -d.)
6464+ set -l FISH_MINOR (echo $version | cut -f2 -d.)
6565+6666+ # merge history from other sessions before searching
6767+ if test -z "$fish_private_mode"
6868+ builtin history merge
6969+ end
7070+7171+ # history's -z flag is needed for multi-line support.
7272+ # history's -z flag was added in fish 2.4.0, so don't use it for versions
7373+ # before 2.4.0.
7474+ if [ "$FISH_MAJOR" -gt 2 -o \( "$FISH_MAJOR" -eq 2 -a "$FISH_MINOR" -ge 4 \) ];
7575+ if type -P perl > /dev/null 2>&1
7676+ set -lx FZF_DEFAULT_OPTS (__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort --wrap-sign '"\t"↳ ' --highlight-line $FZF_CTRL_R_OPTS +m")
7777+ set -lx FZF_DEFAULT_OPTS_FILE ''
7878+ builtin history -z --reverse | command perl -0 -pe 's/^/$.\t/g; s/\n/\n\t/gm' | eval (__fzfcmd) --tac --read0 --print0 -q '(commandline)' | command perl -pe 's/^\d*\t//' | read -lz result
7979+ and commandline -- $result
8080+ else
8181+ set -lx FZF_DEFAULT_OPTS (__fzf_defaults "" "--scheme=history --bind=ctrl-r:toggle-sort --wrap-sign '"\t"↳ ' --highlight-line $FZF_CTRL_R_OPTS +m")
8282+ set -lx FZF_DEFAULT_OPTS_FILE ''
8383+ builtin history -z | eval (__fzfcmd) --read0 --print0 -q '(commandline)' | read -lz result
8484+ and commandline -- $result
8585+ end
8686+ else
8787+ builtin history | eval (__fzfcmd) -q '(commandline)' | read -l result
8888+ and commandline -- $result
8989+ end
9090+ end
9191+ commandline -f repaint
9292+ end
9393+9494+ function fzf-cd-widget -d "Change directory"
9595+ set -l commandline (__fzf_parse_commandline)
9696+ set -lx dir $commandline[1]
9797+ set -l fzf_query $commandline[2]
9898+ set -l prefix $commandline[3]
9999+100100+ test -n "$FZF_TMUX_HEIGHT"; or set FZF_TMUX_HEIGHT 40%
101101+ begin
102102+ set -lx FZF_DEFAULT_OPTS (__fzf_defaults "--reverse --walker=dir,follow,hidden --scheme=path --walker-root='$dir'" "$FZF_ALT_C_OPTS")
103103+ set -lx FZF_DEFAULT_OPTS_FILE ''
104104+ set -lx FZF_DEFAULT_COMMAND "$FZF_ALT_C_COMMAND"
105105+ eval (__fzfcmd)' +m --query "'$fzf_query'"' | read -l result
106106+107107+ if [ -n "$result" ]
108108+ cd -- $result
109109+110110+ # Remove last token from commandline.
111111+ commandline -t ""
112112+ commandline -it -- $prefix
113113+ end
114114+ end
115115+116116+ commandline -f repaint
117117+ end
118118+119119+ function __fzfcmd
120120+ test -n "$FZF_TMUX"; or set FZF_TMUX 0
121121+ test -n "$FZF_TMUX_HEIGHT"; or set FZF_TMUX_HEIGHT 40%
122122+ if [ -n "$FZF_TMUX_OPTS" ]
123123+ echo "fzf-tmux $FZF_TMUX_OPTS -- "
124124+ else if [ $FZF_TMUX -eq 1 ]
125125+ echo "fzf-tmux -d$FZF_TMUX_HEIGHT -- "
126126+ else
127127+ echo "fzf"
128128+ end
129129+ end
130130+131131+ bind \cr fzf-history-widget
132132+ if not set -q FZF_CTRL_T_COMMAND; or test -n "$FZF_CTRL_T_COMMAND"
133133+ bind \ct fzf-file-widget
134134+ end
135135+ if not set -q FZF_ALT_C_COMMAND; or test -n "$FZF_ALT_C_COMMAND"
136136+ bind \ec fzf-cd-widget
137137+ end
138138+139139+ if bind -M insert > /dev/null 2>&1
140140+ bind -M insert \cr fzf-history-widget
141141+ if not set -q FZF_CTRL_T_COMMAND; or test -n "$FZF_CTRL_T_COMMAND"
142142+ bind -M insert \ct fzf-file-widget
143143+ end
144144+ if not set -q FZF_ALT_C_COMMAND; or test -n "$FZF_ALT_C_COMMAND"
145145+ bind -M insert \ec fzf-cd-widget
146146+ end
147147+ end
148148+149149+ function __fzf_parse_commandline -d 'Parse the current command line token and return split of existing filepath, fzf query, and optional -option= prefix'
150150+ set -l commandline (commandline -t)
151151+152152+ # strip -option= from token if present
153153+ set -l prefix (string match -r -- '^-[^\s=]+=' $commandline)
154154+ set commandline (string replace -- "$prefix" '' $commandline)
155155+156156+ # eval is used to do shell expansion on paths
157157+ eval set commandline $commandline
158158+159159+ if [ -z $commandline ]
160160+ # Default to current directory with no --query
161161+ set dir '.'
162162+ set fzf_query ''
163163+ else
164164+ set dir (__fzf_get_dir $commandline)
165165+166166+ if [ "$dir" = "." -a (string sub -l 1 -- $commandline) != '.' ]
167167+ # if $dir is "." but commandline is not a relative path, this means no file path found
168168+ set fzf_query $commandline
169169+ else
170170+ # Also remove trailing slash after dir, to "split" input properly
171171+ set fzf_query (string replace -r "^$dir/?" -- '' "$commandline")
172172+ end
173173+ end
174174+175175+ echo $dir
176176+ echo $fzf_query
177177+ echo $prefix
178178+ end
179179+180180+ function __fzf_get_dir -d 'Find the longest existing filepath from input string'
181181+ set dir $argv
182182+183183+ # Strip all trailing slashes. Ignore if $dir is root dir (/)
184184+ if [ (string length -- $dir) -gt 1 ]
185185+ set dir (string replace -r '/*$' -- '' $dir)
186186+ end
187187+188188+ # Iteratively check if dir exists and strip tail end of path
189189+ while [ ! -d "$dir" ]
190190+ # If path is absolute, this can keep going until ends up at /
191191+ # If path is relative, this can keep going until entire input is consumed, dirname returns "."
192192+ set dir (dirname -- "$dir")
193193+ end
194194+195195+ echo $dir
196196+ end
197197+198198+end
199199+### end: key-bindings.fish ###
200200+fzf_key_bindings
···11+{ config, pkgs, ... }:
22+33+{
44+ # Home Manager needs a bit of information about you and the paths it should
55+ # manage.
66+ home.username = "noah";
77+ home.homeDirectory = "/Users/noah";
88+99+ # This value determines the Home Manager release that your configuration is
1010+ # compatible with. This helps avoid breakage when a new Home Manager release
1111+ # introduces backwards incompatible changes.
1212+ #
1313+ # You should not change this value, even if you update Home Manager. If you do
1414+ # want to update the value, then make sure to first check the Home Manager
1515+ # release notes.
1616+ home.stateVersion = "24.11"; # Please read the comment before changing.
1717+1818+ # The home.packages option allows you to install Nix packages into your
1919+ # environment.
2020+ home.packages = [
2121+ # # Adds the 'hello' command to your environment. It prints a friendly
2222+ # # "Hello, world!" when run.
2323+ # pkgs.hello
2424+2525+ # # It is sometimes useful to fine-tune packages, for example, by applying
2626+ # # overrides. You can do that directly here, just don't forget the
2727+ # # parentheses. Maybe you want to install Nerd Fonts with a limited number of
2828+ # # fonts?
2929+ # (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; })
3030+3131+ # # You can also create simple shell scripts directly inside your
3232+ # # configuration. For example, this adds a command 'my-hello' to your
3333+ # # environment:
3434+ # (pkgs.writeShellScriptBin "my-hello" ''
3535+ # echo "Hello, ${config.home.username}!"
3636+ # '')
3737+ ];
3838+3939+ # Home Manager is pretty good at managing dotfiles. The primary way to manage
4040+ # plain files is through 'home.file'.
4141+ home.file = {
4242+ # # Building this configuration will create a copy of 'dotfiles/screenrc' in
4343+ # # the Nix store. Activating the configuration will then make '~/.screenrc' a
4444+ # # symlink to the Nix store copy.
4545+ # ".screenrc".source = dotfiles/screenrc;
4646+4747+ # # You can also set the file content immediately.
4848+ # ".gradle/gradle.properties".text = ''
4949+ # org.gradle.console=verbose
5050+ # org.gradle.daemon.idletimeout=3600000
5151+ # '';
5252+ };
5353+5454+ # Home Manager can also manage your environment variables through
5555+ # 'home.sessionVariables'. These will be explicitly sourced when using a
5656+ # shell provided by Home Manager. If you don't want to manage your shell
5757+ # through Home Manager then you have to manually source 'hm-session-vars.sh'
5858+ # located at either
5959+ #
6060+ # ~/.nix-profile/etc/profile.d/hm-session-vars.sh
6161+ #
6262+ # or
6363+ #
6464+ # ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh
6565+ #
6666+ # or
6767+ #
6868+ # /etc/profiles/per-user/noah/etc/profile.d/hm-session-vars.sh
6969+ #
7070+ home.sessionVariables = {
7171+ # EDITOR = "emacs";
7272+ };
7373+7474+ # Let Home Manager install and manage itself.
7575+ programs.home-manager.enable = true;
7676+}