]> Freerunner's - dotfiles.git/commitdiff
fish: update aliases/functions
authorAndre Ramnitz <tux.rising@gmail.com>
Thu, 17 Jul 2025 16:28:06 +0000 (18:28 +0200)
committerAndre Ramnitz <tux.rising@gmail.com>
Thu, 17 Jul 2025 16:28:06 +0000 (18:28 +0200)
dot-config/fish/completions/lf.fish [new file with mode: 0644]
dot-config/fish/fish_variables
dot-config/fish/functions/cdg.fish [new file with mode: 0644]
dot-config/fish/functions/lfcd.fish [new file with mode: 0644]
dot-config/fish/functions/y.fish [new file with mode: 0644]

diff --git a/dot-config/fish/completions/lf.fish b/dot-config/fish/completions/lf.fish
new file mode 100644 (file)
index 0000000..ff8d785
--- /dev/null
@@ -0,0 +1,24 @@
+# Autocompletion for fish shell.
+#
+# You may put this file to a directory in $fish_complete_path variable:
+#
+#     mkdir -p ~/.config/fish/completions
+#     ln -s "/path/to/lf.fish" ~/.config/fish/completions
+#
+
+complete -c lf -o command -r -d 'command to execute on client initialization'
+complete -c lf -o config -r -d 'path to the config file (instead of the usual paths)'
+complete -c lf -o cpuprofile -r -d 'path to the file to write the CPU profile'
+complete -c lf -o doc -d 'show documentation'
+complete -c lf -o last-dir-path -r -d 'path to the file to write the last dir on exit (to use for cd)'
+complete -c lf -o log -r -d 'path to the log file to write messages'
+complete -c lf -o memprofile -r -d 'path to the file to write the memory profile'
+complete -c lf -o print-last-dir -d 'print the last dir to stdout on exit (to use for cd)'
+complete -c lf -o print-selection -d 'print the selected files to stdout on open (to use as open file dialog)'
+complete -c lf -o remote -x -d 'send remote command to server'
+complete -c lf -o selection-path -r -d 'path to the file to write selected files on open (to use as open file dialog)'
+complete -c lf -o server -d 'start server (automatic)'
+complete -c lf -o single -d 'start a client without server'
+complete -c lf -o version -d 'show version'
+complete -c lf -o help -d 'show help'
+
index eb042f1a5c4ebe96e290240561eaf890ffec0d20..43b675548e32d881740990178f21622d58cb31d3 100644 (file)
@@ -29,4 +29,4 @@ SETUVAR fish_pager_color_description:yellow\x1e\x2di
 SETUVAR fish_pager_color_prefix:normal\x1e\x2d\x2dbold\x1e\x2d\x2dunderline
 SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan
 SETUVAR fish_pager_color_selected_background:\x2dr
-SETUVAR fish_user_paths:/home/andy/Applications\x1e/home/andy/go/bin\x1e/home/andy/\x2ecargo/bin\x1e/home/andy/\x2elocal/bin\x1e/home/andy/\x2espicetify
+SETUVAR fish_user_paths:/media/source/dart\x2dsass\x1e/home/andy/Applications\x1e/home/andy/go/bin\x1e/home/andy/\x2ecargo/bin\x1e/home/andy/\x2elocal/bin\x1e/home/andy/\x2espicetify
diff --git a/dot-config/fish/functions/cdg.fish b/dot-config/fish/functions/cdg.fish
new file mode 100644 (file)
index 0000000..59cfe11
--- /dev/null
@@ -0,0 +1,4 @@
+function cdg --wraps='cd (git rev-parse --show-toplevel)' --description 'alias cdg cd (git rev-parse --show-toplevel)'
+  cd (git rev-parse --show-toplevel) $argv
+        
+end
diff --git a/dot-config/fish/functions/lfcd.fish b/dot-config/fish/functions/lfcd.fish
new file mode 100644 (file)
index 0000000..1e50b6f
--- /dev/null
@@ -0,0 +1,19 @@
+# Change working dir in fish to last dir in lf on exit (adapted from ranger).
+#
+# You may put this file to a directory in $fish_function_path variable:
+#
+#     mkdir -p ~/.config/fish/functions
+#     ln -s "/path/to/lfcd.fish" ~/.config/fish/functions
+#
+# You may also like to assign a key (Ctrl-O) to this command:
+#
+#     bind \co 'set old_tty (stty -g); stty sane; lfcd; stty $old_tty; commandline -f repaint'
+#
+# You may put this in a function called fish_user_key_bindings.
+
+function lfcd --wraps="lf" --description="lf - Terminal file manager (changing directory on exit)"
+    # `command` is needed in case `lfcd` is aliased to `lf`.
+    # Quotes will cause `cd` to not change directory if `lf` prints nothing to stdout due to an error.
+    cd "$(command lf -print-last-dir $argv)"
+end
+
diff --git a/dot-config/fish/functions/y.fish b/dot-config/fish/functions/y.fish
new file mode 100644 (file)
index 0000000..8d6d44a
--- /dev/null
@@ -0,0 +1,9 @@
+function y
+       set tmp (mktemp -t "yazi-cwd.XXXXXX")
+       yazi $argv --cwd-file="$tmp"
+       if read -z cwd < "$tmp"; and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ]
+               builtin cd -- "$cwd"
+       end
+       rm -f -- "$tmp"
+end
+