From a1e7e0bc3e2cf040d24580ecfe3f73899b358aa1 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sun, 20 Aug 2023 06:52:48 +0200 Subject: fish: port functions and more aliases --- user/emacs/init.el | 5 +++++ user/nanopi.nix | 1 + user/settings/emacs.nix | 1 + user/settings/fish.nix | 7 +++++++ user/settings/fish/functions/delink.fish | 10 ++++++++++ user/settings/fish/functions/ecpenv.fish | 3 +++ user/settings/fish/functions/esetenv.fish | 3 +++ user/settings/fish/functions/field.fish | 3 +++ user/settings/fish/functions/help.fish | 3 +++ user/settings/fish/functions/tere.fish | 6 ++++++ user/settings/shell.nix | 1 + 11 files changed, 43 insertions(+) create mode 100644 user/settings/fish/functions/delink.fish create mode 100644 user/settings/fish/functions/ecpenv.fish create mode 100755 user/settings/fish/functions/esetenv.fish create mode 100644 user/settings/fish/functions/field.fish create mode 100644 user/settings/fish/functions/help.fish create mode 100644 user/settings/fish/functions/tere.fish diff --git a/user/emacs/init.el b/user/emacs/init.el index 9b136bce..f5729f21 100644 --- a/user/emacs/init.el +++ b/user/emacs/init.el @@ -763,6 +763,11 @@ _p_rev _u_pper _=_: upper/lower _r_esolve (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on) +(use-package fish-mode + :mode (("\\.fish\\'" . fish-mode)) + :config (progn + (setq fish-enable-auto-indent t))) + ;;;; make (general-add-hook 'makefile-mode-hook (lambda () diff --git a/user/nanopi.nix b/user/nanopi.nix index ac0b938a..13ec9ae9 100644 --- a/user/nanopi.nix +++ b/user/nanopi.nix @@ -4,6 +4,7 @@ ./modules/tabnine.nix ./settings/base.nix ./settings/development/base.nix + ./settings/fish.nix ./settings/git.nix ./settings/nix.nix ./settings/nixos.nix diff --git a/user/settings/emacs.nix b/user/settings/emacs.nix index 1303c8ef..79bb99f7 100644 --- a/user/settings/emacs.nix +++ b/user/settings/emacs.nix @@ -140,6 +140,7 @@ in evil-surround evil-textobj-tree-sitter eyebrowse + fish-mode format-all flycheck general diff --git a/user/settings/fish.nix b/user/settings/fish.nix index 5af965cd..6ddbe120 100644 --- a/user/settings/fish.nix +++ b/user/settings/fish.nix @@ -27,5 +27,12 @@ interactiveShellInit = '' bind \es __ghq_repository_search ''; + functions = { + ds = "du -hd1 $argv[1] | sort -h"; + }; + }; + xdg.configFile."fish/functions" = { + recursive = true; + source = ./fish/functions; }; } diff --git a/user/settings/fish/functions/delink.fish b/user/settings/fish/functions/delink.fish new file mode 100644 index 00000000..ff7ff64b --- /dev/null +++ b/user/settings/fish/functions/delink.fish @@ -0,0 +1,10 @@ +function delink + if test ! -L $argv[1] + echo "$argv[1] is not a symlink" + return 1 + end + set -l src (readlink $argv[1]) + rm $argv[1] + cp $src $argv[1] + chmod u+w $argv[1] +end diff --git a/user/settings/fish/functions/ecpenv.fish b/user/settings/fish/functions/ecpenv.fish new file mode 100644 index 00000000..68d6051b --- /dev/null +++ b/user/settings/fish/functions/ecpenv.fish @@ -0,0 +1,3 @@ +function ecpenv + esetenv $argv[1] $$argv[1] +end diff --git a/user/settings/fish/functions/esetenv.fish b/user/settings/fish/functions/esetenv.fish new file mode 100755 index 00000000..17357925 --- /dev/null +++ b/user/settings/fish/functions/esetenv.fish @@ -0,0 +1,3 @@ +function esetenv + emacsclient -e "(setenv \"$argv[1]\" \"$argv[2]\")" +end diff --git a/user/settings/fish/functions/field.fish b/user/settings/fish/functions/field.fish new file mode 100644 index 00000000..96e17bd2 --- /dev/null +++ b/user/settings/fish/functions/field.fish @@ -0,0 +1,3 @@ +function field + awk "{ print \$$argv[1]}" +end diff --git a/user/settings/fish/functions/help.fish b/user/settings/fish/functions/help.fish new file mode 100644 index 00000000..e649f43e --- /dev/null +++ b/user/settings/fish/functions/help.fish @@ -0,0 +1,3 @@ +function help + $argv --help 2>&1 | bat --plan --language=help +end diff --git a/user/settings/fish/functions/tere.fish b/user/settings/fish/functions/tere.fish new file mode 100644 index 00000000..ba5816f9 --- /dev/null +++ b/user/settings/fish/functions/tere.fish @@ -0,0 +1,6 @@ +function tere + set -f result $(command tere $argv) + if test -n $result + cd $result + end +end diff --git a/user/settings/shell.nix b/user/settings/shell.nix index ab9bafed..46d3f37b 100644 --- a/user/settings/shell.nix +++ b/user/settings/shell.nix @@ -57,6 +57,7 @@ in dj = "docker pull"; dk = "docker push"; + dc = "docker-compose"; dcb = "dc build"; dcd = "dc down"; dcj = "dc pull"; -- cgit 1.4.1