diff --git a/alex/fish/functions/bangbang.fish b/alex/fish/functions/bangbang.fish index 1f2f067..5104d6a 100644 --- a/alex/fish/functions/bangbang.fish +++ b/alex/fish/functions/bangbang.fish @@ -22,8 +22,3 @@ function bind_dollar commandline --insert '$' end end - -function fish_user_key_bindings - bind ! bind_bang - bind '$' bind_dollar -end diff --git a/alex/fish/functions/fish-user-key-bindings.fish b/alex/fish/functions/fish-user-key-bindings.fish new file mode 100644 index 0000000..132ee65 --- /dev/null +++ b/alex/fish/functions/fish-user-key-bindings.fish @@ -0,0 +1,5 @@ +function fish_user_key_bindings + bind ! bind_bang + bind '$' bind_dollar + bind @ bind_at +end diff --git a/alex/fish/functions/latest-file.fish b/alex/fish/functions/latest-file.fish new file mode 100644 index 0000000..c31ccea --- /dev/null +++ b/alex/fish/functions/latest-file.fish @@ -0,0 +1,20 @@ +function bind_at + set -l token (commandline -t) + if string match -q -- "*@" "$token" + commandline -f backward-delete-char + set -l newest_file + for f in (command ls -tA) + if test -f "$f" + set newest_file "$f" + break + end + end + if test -n "$newest_file" + commandline -i (string escape -- "$newest_file") + else + commandline -i "@" + end + else + commandline -i "@" + end +end diff --git a/alex/home.nix b/alex/home.nix index ad322c0..7836538 100644 --- a/alex/home.nix +++ b/alex/home.nix @@ -181,10 +181,13 @@ programs.fish = { enable = true; interactiveShellInit = '' + source ~/.config/fish/functions/latest-file.fish source ~/.config/fish/functions/cardboard.fish source ~/.config/fish/functions/bangbang.fish source ~/.config/fish/functions/borg-h.fish + source ~/.config/fish/functions/fish-user-key-bindings.fish + set PATH ~/.cargo/bin $PATH set PATH ~/scripts $PATH set PATH ~/.local/bin $PATH