From ef0ec4693c9041efca5017a234ea6ed44b61a43c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Sat, 23 Sep 2023 09:46:46 +0200 Subject: [PATCH] feat: new abbreviations --- modules/profiles/base.nix | 2 ++ modules/programs/fish.nix | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/modules/profiles/base.nix b/modules/profiles/base.nix index c23dcf9..e76753c 100644 --- a/modules/profiles/base.nix +++ b/modules/profiles/base.nix @@ -105,6 +105,8 @@ in abbreviations = { us = "systemctl --user"; rs = "sudo systemctl"; + uj = "journalctl --user"; + rj = "sudo journalctl"; }; aliases = { ls = "exa -lh --icons --git"; diff --git a/modules/programs/fish.nix b/modules/programs/fish.nix index 3e9293c..c29dd7c 100644 --- a/modules/programs/fish.nix +++ b/modules/programs/fish.nix @@ -46,14 +46,46 @@ in # visual mode, but due to fish_cursor_default, is redundant here set fish_cursor_visual block + # Complex abbreviations + function last_history_item + echo $history[1] + end + abbr -a !! --position anywhere --function last_history_item + + function sed_history_item + echo $history[1] | perl -p -e (string trim -l --chars=! $argv) + end + abbr -a sed_history --position command --regex '^!s/.+/.*/g?' --function sed_history_item + + function multicd + echo cd (string repeat -n (math (string length -- $argv[1]) - 1) ../) + end + abbr --add dotdot --regex '^\.\.+$' --function multicd + + abbr -a P --position anywhere --set-cursor "% | $PAGER" + + function editor_edit + echo $EDITOR $argv + end + abbr -a editor_edit_files --position command --regex ".+\.(txt|md|org)" --function editor_edit + + function editor + echo $EDITOR + end + abbr -a e --function editor + # Completions complete -c c -kfa '(zoxide query -l | sed "s|$HOME|~|")' ${optionalString config.virtualisation.podman.dockerCompat /* fish */ "complete -c docker -w podman"} + complete -c nom -fn "not __fish_seen_subcommand_from build shell develop" -a "build shell develop" + + complete -c nom -fn "__fish_seen_subcommand_from build" -w "nix build" + complete -c nom -fn "__fish_seen_subcommand_from shell" -w "nix shell" + complete -c nom -fn "__fish_seen_subcommand_from develop" -w "nix develop" complete -c timers \ -n "__fish_seen_subcommand_from toggle" \ -fa '(timers --json l | ${getExe pkgs.jq} -r .[][].name)' - complete -c timers \ -n "__fish_seen_subcommand_from remove" \ -fa '(timers --json l | ${getExe pkgs.jq} -r .[][].name)'