aboutsummaryrefslogtreecommitdiff
path: root/dot_config/fish
diff options
context:
space:
mode:
authortwells46 <173561638+twells46@users.noreply.github.com>2025-12-31 13:28:05 -0600
committertwells46 <173561638+twells46@users.noreply.github.com>2025-12-31 13:28:05 -0600
commit2140ab51deed88e90eafebf9520fa5f9995dc7c9 (patch)
tree03cf1dcd2900495c1efb79aaa85f3254ecd5fb87 /dot_config/fish
parentff8f50638e4b17a9d7cc88d2f0d9560b7effce39 (diff)
Migrate from stow
Diffstat (limited to 'dot_config/fish')
-rw-r--r--dot_config/fish/completions/.keep0
-rw-r--r--dot_config/fish/conf.d/aliases.fish10
-rw-r--r--dot_config/fish/conf.d/env.fish55
-rw-r--r--dot_config/fish/conf.d/rustup.fish1
-rw-r--r--dot_config/fish/config.fish9
-rw-r--r--dot_config/fish/fish_variables6
-rw-r--r--dot_config/fish/functions/fish_prompt.fish10
-rw-r--r--dot_config/fish/functions/lfcd.fish18
-rw-r--r--dot_config/fish/functions/z.fish76
-rw-r--r--dot_config/fish/functions/zi.fish17
10 files changed, 202 insertions, 0 deletions
diff --git a/dot_config/fish/completions/.keep b/dot_config/fish/completions/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/dot_config/fish/completions/.keep
diff --git a/dot_config/fish/conf.d/aliases.fish b/dot_config/fish/conf.d/aliases.fish
new file mode 100644
index 0000000..cf2dc5f
--- /dev/null
+++ b/dot_config/fish/conf.d/aliases.fish
@@ -0,0 +1,10 @@
+alias ls "ls -h --color=auto --group-directories-first"
+alias tree "tree -C"
+alias cp "cp -iv"
+alias rm "rm -Iv"
+alias mv "mv -iv"
+alias mkdir "mkdir -pv"
+alias nvbm "nvim $XDG_DATA_HOME/bookmarks"
+alias less "less -R"
+alias zathura "zathura --fork"
+alias lf "lfcd"
diff --git a/dot_config/fish/conf.d/env.fish b/dot_config/fish/conf.d/env.fish
new file mode 100644
index 0000000..19d6ce5
--- /dev/null
+++ b/dot_config/fish/conf.d/env.fish
@@ -0,0 +1,55 @@
+################## NOTICE ##################
+# Since we are calling `st /usr/bin/fish` instead of setting fish as the
+# user shell, these variables are now set in ~/.profile (for dash) and
+# are inherited by fish.
+############################################
+
+#set -gx EDITOR "/usr/bin/kak"
+#
+#set -gx EDITOR "kak"
+#
+#set -gx XDG_CONFIG_HOME "$HOME/.config"
+#set -gx XDG_DATA_HOME "$HOME/.local/share"
+#set -gx XDG_CACHE_HOME "$HOME/.cache"
+#
+#set -gx MPD_HOST "$XDG_RUNTIME_DIR/mpd.sock"
+#set -gx XINITRC "$XDG_CONFIG_HOME/x11/xinitrc"
+#
+#set -gx CARGO_HOME "$XDG_DATA_HOME/rust/cargo"
+#set -gx RUSTUP_HOME "$XDG_DATA_HOME/rust/rustup"
+#
+#set -gx GOPATH "$XDG_DATA_HOME/go"
+#set -gx GOMODCACHE "$XDG_CACHE_HOME/go/mod"
+#set -pgx PATH '/usr/local/go/bin'
+#set -pgx PATH "$GOPATH/bin"
+#
+#set -gx PYTHONSTARTUP "$XDG_CONFIG_HOME/python/pythonrc"
+#set -gx SQLITE_HISTORY "$XDG_DATA_HOME/sqlite_history"
+#
+#set -gx PASSWORD_STORE_DIR "$XDG_DATA_HOME/password-store"
+#set -gx GNUPGHOME "$XDG_DATA_HOME/gnupg"
+#
+#set -gx FZF_DEFAULT_OPTS "--reverse --height=50%"
+#set -gx _ZO_FZF_OPTS "--scheme=path --tiebreak=index --height=75% --reverse --border=rounded --no-scrollbar --preview=\"ls --color -al {2}\" --preview-window=right"
+##set -gx BAT_THEME "base16"
+#set -gx MANPAGER "less -R --use-color -Dd+r -Du+b"
+#
+## Ollama
+#set -gx OLLAMA_NOHISTORY 1
+#
+## Plan9
+##set -gx PLAN9 "/usr/local/plan9"
+##set -gxax PATH "$PLAN9/bin"
+#
+## Misc.
+## set -gx XINITRC "$XDG_CONFIG_HOME/x11/xinitrc"
+## set -gx XAUTHORITY "$XDG_RUNTIME_DIR/Xauthority"
+#set -gx GTK2_RC_FILES "$XDG_CONFIG_HOME/gtk-2.0/gtkrc-2.0"
+#set -gx WGETRC "$XDG_CONFIG_HOME/wget/wgetrc"
+#set -gx INPUTRC "$XDG_CONFIG_HOME/shell/inputrc"
+#set -gx ANSIBLE_CONFIG "$XDG_CONFIG_HOME/ansible/ansible.cfg"
+#set -gx MBSYNCRC "$XDG_CONFIG_HOME/mbsync/config"
+#set -gx ELECTRUMDIR "$XDG_DATA_HOME/electrum"
+#set -gx PYTHONSTARTUP "$XDG_CONFIG_HOME/python/pythonrc"
+#set -gx SQLITE_HISTORY "$XDG_DATA_HOME/sqlite_history"
+#
diff --git a/dot_config/fish/conf.d/rustup.fish b/dot_config/fish/conf.d/rustup.fish
new file mode 100644
index 0000000..cf1d54a
--- /dev/null
+++ b/dot_config/fish/conf.d/rustup.fish
@@ -0,0 +1 @@
+source "/home/tom/.local/share/rust/cargo/env.fish"
diff --git a/dot_config/fish/config.fish b/dot_config/fish/config.fish
new file mode 100644
index 0000000..0808119
--- /dev/null
+++ b/dot_config/fish/config.fish
@@ -0,0 +1,9 @@
+if status is-interactive
+ # Commands to run in interactive sessions can go here
+ set -g fish_greeting
+ abbr --add lf lfcd
+ fzf --fish | source
+
+ # Set fish_key_bindings globally per 4.3 update instructions
+ set --global fish_key_bindings fish_default_key_bindings
+end
diff --git a/dot_config/fish/fish_variables b/dot_config/fish/fish_variables
new file mode 100644
index 0000000..687fe6c
--- /dev/null
+++ b/dot_config/fish/fish_variables
@@ -0,0 +1,6 @@
+# This file contains fish universal variable definitions.
+# VERSION: 3.0
+SETUVAR --export CARAPACE_BRIDGES:zsh\x2cfish\x2cbash\x2cinshellisense
+SETUVAR __fish_initialized:4300
+SETUVAR _fish_abbr_lf:lfcd
+SETUVAR fish_user_paths:/home/tom/\x2elocal/bin
diff --git a/dot_config/fish/functions/fish_prompt.fish b/dot_config/fish/functions/fish_prompt.fish
new file mode 100644
index 0000000..415f452
--- /dev/null
+++ b/dot_config/fish/functions/fish_prompt.fish
@@ -0,0 +1,10 @@
+function fish_prompt
+ set -l last_status $status
+ # Prompt status only if it's not 0
+ set -l stat
+ if test $last_status -ne 0
+ set stat (set_color red)" [$last_status] "(set_color normal)
+ end
+
+ string join '' -- (set_color green) (prompt_pwd -D 50) (set_color normal) $stat '> '
+end
diff --git a/dot_config/fish/functions/lfcd.fish b/dot_config/fish/functions/lfcd.fish
new file mode 100644
index 0000000..9007021
--- /dev/null
+++ b/dot_config/fish/functions/lfcd.fish
@@ -0,0 +1,18 @@
+# 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/z.fish b/dot_config/fish/functions/z.fish
new file mode 100644
index 0000000..6b1d535
--- /dev/null
+++ b/dot_config/fish/functions/z.fish
@@ -0,0 +1,76 @@
+# =============================================================================
+#
+# Utility functions for zoxide.
+#
+
+# pwd based on the value of _ZO_RESOLVE_SYMLINKS.
+function __zoxide_pwd
+ builtin pwd -L
+end
+
+# A copy of fish's internal cd function. This makes it possible to use
+# `alias cd=z` without causing an infinite loop.
+if ! builtin functions --query __zoxide_cd_internal
+ string replace --regex -- '^function cd\s' 'function __zoxide_cd_internal ' <$__fish_data_dir/functions/cd.fish | source
+end
+
+# cd + custom logic based on the value of _ZO_ECHO.
+function __zoxide_cd
+ if set -q __zoxide_loop
+ builtin echo "zoxide: infinite loop detected"
+ builtin echo "Avoid aliasing `cd` to `z` directly, use `zoxide init --cmd=cd fish` instead"
+ return 1
+ end
+ __zoxide_loop=1 __zoxide_cd_internal $argv
+end
+
+# =============================================================================
+#
+# Hook configuration for zoxide.
+#
+
+# Initialize hook to add new entries to the database.
+function __zoxide_hook --on-variable PWD
+ test -z "$fish_private_mode"
+ and command zoxide add -- (__zoxide_pwd)
+end
+
+# =============================================================================
+#
+# When using zoxide with --no-cmd, alias these internal functions as desired.
+#
+
+# Jump to a directory using only keywords.
+function z
+ set -l argc (builtin count $argv)
+ if test $argc -eq 0
+ __zoxide_cd $HOME
+ else if test "$argv" = -
+ __zoxide_cd -
+ else if test $argc -eq 1 -a -d $argv[1]
+ __zoxide_cd $argv[1]
+ else if test $argc -eq 2 -a $argv[1] = --
+ __zoxide_cd -- $argv[2]
+ else
+ set -l result (command zoxide query --exclude (__zoxide_pwd) -- $argv)
+ and __zoxide_cd $result
+ end
+end
+
+# Completions.
+function __zoxide_z_complete
+ set -l tokens (builtin commandline --current-process --tokenize)
+ set -l curr_tokens (builtin commandline --cut-at-cursor --current-process --tokenize)
+
+ if test (builtin count $tokens) -le 2 -a (builtin count $curr_tokens) -eq 1
+ # If there are < 2 arguments, use `cd` completions.
+ complete --do-complete "'' "(builtin commandline --cut-at-cursor --current-token) | string match --regex -- '.*/$'
+ else if test (builtin count $tokens) -eq (builtin count $curr_tokens)
+ # If the last argument is empty, use interactive selection.
+ set -l query $tokens[2..-1]
+ set -l result (command zoxide query --exclude (__zoxide_pwd) --interactive -- $query)
+ and __zoxide_cd $result
+ and builtin commandline --function cancel-commandline repaint
+ end
+end
+complete --command __zoxide_z --no-files --arguments '(__zoxide_z_complete)'
diff --git a/dot_config/fish/functions/zi.fish b/dot_config/fish/functions/zi.fish
new file mode 100644
index 0000000..c529662
--- /dev/null
+++ b/dot_config/fish/functions/zi.fish
@@ -0,0 +1,17 @@
+if ! builtin functions --query __zoxide_cd_internal
+ string replace --regex -- '^function cd\s' 'function __zoxide_cd_internal ' <$__fish_data_dir/functions/cd.fish | source
+end
+function __zoxide_cd
+ if set -q __zoxide_loop
+ builtin echo "zoxide: infinite loop detected"
+ builtin echo "Avoid aliasing `cd` to `z` directly, use `zoxide init --cmd=cd fish` instead"
+ return 1
+ end
+ __zoxide_loop=1 __zoxide_cd_internal $argv
+end
+
+# Jump to a directory using interactive search.
+function zi
+ set -l result (command zoxide query --interactive -- $argv)
+ and __zoxide_cd $result
+end