feat: initial fish shell configuration

- Core config layered on CachyOS base with Catppuccin Mocha theming
- Fisher plugins: fzf.fish, catppuccin, autopair, replay, puffer-fish, magic-enter, spark
- Smart CLI wrappers with fallbacks (bat, lsd, btop, dust, prettyping)
- Custom functions: git, docker, network, kitty, AI session management
- Extensive abbreviation system for keyboard-driven workflows
- Secrets/local sourcing pattern for private and machine-specific config
- README with full documentation and personalization guide
- AGPLv3+ license with copyright headers on all source files
This commit is contained in:
2026-04-26 00:59:48 -04:00
commit 4c1e7a7eb9
131 changed files with 5625 additions and 0 deletions
+229
View File
@@ -0,0 +1,229 @@
# Copyright (C) 2026 Rootiest
# SPDX-License-Identifier: AGPL-3.0-or-later
### Abreviations ###
# Neovim
abbr -a n nvim
abbr -a nv nvim
abbr -a neovim nvim
abbr -a cdnv 'cd ~/.config/nvim # Neovim Config'
abbr -a cdnvn 'cd ~/.config/nvim;nvim'
# VSCode
abbr -a v antigravity
# Kate
abbr -a k kate
# WezTerm SSH
abbr -a s wezterm ssh
# Neovim in a new tab
#abbr -a editt wezterm cli spawn nvim # WezTerm
abbr -a editt kitty @ launch --type=tab --cwd=current nvim # Kitty
# LazyGit
abbr -a lg lazygit
# Sudo shell
abbr -a sudu sudo -s
# Kitty
abbr -a kt kitty
# cat
abbr -a c cat
# chezmoi
abbr -a cm chezmoi
# chezmoi cd
abbr -a cmcd chezmoi cd
abbr -a czcd chezmoi cd
abbr -a cdcm chezmoi cd
abbr -a cdcz chezmoi cd
# chezmoi edit
abbr -a cme chezmoi edit
abbr -a cze chezmoi edit
# chezmoi add
abbr -a cmad chezmoi add
abbr -a czad chezmoi add
# chezmoi apply
abbr -a cmap chezmoi apply
abbr -a czap chezmoi apply
# chezmoi rm
abbr -a cmrm chezmoi forget
abbr -a cmf chezmoi forget
abbr -a czrm chezmoi forget
abbr -a czf chezmoi forget
# chezmoi init
abbr -a cmi chezmoi init
abbr -a czi chezmoi init
# Edit
abbr -a e edit
# Sudoedit
abbr -a se sudoedit
# Git
abbr -a g git
# Antigravity
abbr -a ag antigravity
abbr -a ag. antigravity .
# Quit
# abbr -a :q wezterm cli kill-pane # WezTerm
# abbr -a :Q wezterm cli kill-pane # WezTerm
abbr -a :q kitty @ close-window # Kitty (Closes the active split/pane)
abbr -a :Q kitty @ close-tab # Kitty (Closes the whole tab)
# Window Creation (OS Windows)
# abbr -a :w wezterm cli spawn --new-window # WezTerm
abbr -a :w kitty @ launch --type=os-window # Kitty
# Window Splits (Panes)
# abbr -a :wv wezterm cli split-pane --bottom # WezTerm
abbr -a :wv kitty @ launch --location=hsplit # Kitty (Horizontal split)
# abbr -a :wh wezterm cli split-pane --right # WezTerm
abbr -a :wh kitty @ launch --location=vsplit # Kitty (Vertical split)
# Window Detach (Move Pane)
# abbr -a :wo wezterm cli move-pane-to-new-tab --new-window # WezTerm
abbr -a :wo kitty @ detach-window --target-tab=new # Kitty (Moves pane to new tab)
# abbr -a :wot wezterm cli move-pane-to-new-tab # WezTerm
abbr -a :wot kitty @ detach-window # Kitty (Same as above, default behavior)
# Tab Creation
# abbr -a :t wezterm cli spawn # WezTerm
abbr -a :t kitty @ launch --type=tab # Kitty
# Rename Tab
# abbr -a :tl wezterm cli set-tab-title # WezTerm
abbr -a :tl "kitty @ set-tab-title" # Kitty -> Usage: :tl "New Title"
# Rename Window
# abbr -a :tw wezterm cli set-window-title # WezTerm
abbr -a :tw "kitty @ set-window-title" # Kitty
# Rename Workspace
# abbr -a :twk wezterm cli rename-workspace # WezTerm
# Kitty does not have a direct CLI equivalent for renaming a dynamic "workspace" session.
# Tab Navigation
# abbr -a :tp wezterm cli activate-tab --tab-relative -1 # WezTerm
abbr -a :tp "kitty @ focus-tab --match neighbor:left" # Kitty
# abbr -a :tn wezterm cli activate-tab --tab-relative 1 # WezTerm
abbr -a :tn "kitty @ focus-tab --match neighbor:right" # Kitty
# Specialty Tab Shortcuts (New Tab in specific dir)
# abbr -a :tgk wezterm cli spawn --cwd ~/.config/kitty # WezTerm
abbr -a :tgk kitty @ launch --type=tab --cwd ~/.config/kitty # Kitty
# abbr -a :tgn wezterm cli spawn --cwd ~/.config/nvim # WezTerm
abbr -a :tgn kitty @ launch --type=tab --cwd ~/.config/nvim # Kitty
# abbr -a :tgf wezterm cli spawn --cwd ~/.config/fish # WezTerm
abbr -a :tgf kitty @ launch --type=tab --cwd ~/.config/fish # Kitty
# abbr -a :tgh wezterm cli spawn --cwd ~ # WezTerm
abbr -a :tgh kitty @ launch --type=tab --cwd ~
# abbr -a :tgcz wezterm cli spawn --cwd ~/.local/share/chezmoi # WezTerm
abbr -a :tgcz kitty @ launch --type=tab --cwd ~/.local/share/chezmoi # Kitty
# abbr -a :tgcm wezterm cli spawn --cwd ~/.config/chezmoi # WezTerm
abbr -a :tgcm kitty @ launch --type=tab --cwd ~/.config/chezmoi # Kitty
# abbr -a :tgp wezterm cli spawn --cwd ~/projects # WezTerm
abbr -a :tgp kitty @ launch --type=tab --cwd ~/projects # Kitty
# abbr -a :tgr wezterm cli spawn -- sudo -i # WezTerm
abbr -a :tgr kitty @ launch --type=tab -- sudo -i
# Specialty Window Shortcuts (New OS Window in specific dir)
# abbr -a :wgk wezterm cli spawn --new-window --cwd ~/.config/kitty # WezTerm
abbr -a :wgk kitty @ launch --type=os-window --cwd ~/.config/kitty # Kitty
# abbr -a :wgn wezterm cli spawn --new-window --cwd ~/.config/nvim # WezTerm
abbr -a :wgn kitty @ launch --type=os-window --cwd ~/.config/nvim # Kitty
# abbr -a :wgf wezterm cli spawn --new-window --cwd ~/.config/fish # WezTerm
abbr -a :wgf kitty @ launch --type=os-window --cwd ~/.config/fish # Kitty
# abbr -a :wgh wezterm cli spawn --new-window --cwd ~ # WezTerm
abbr -a :wgh kitty @ launch --type=os-window --cwd ~
# abbr -a :wgzd wezterm cli spawn --new-window --cwd ~/.local/share/chezmoi # WezTerm
abbr -a :wgzd kitty @ launch --type=os-window --cwd ~/.local/share/chezmoi # Kitty
# abbr -a :wgcz wezterm cli spawn --new-window --cwd ~/.config/chezmoi # WezTerm
abbr -a :wgcz kitty @ launch --type=os-window --cwd ~/.config/chezmoi # Kitty
# abbr -a :wgp wezterm cli spawn --new-window --cwd ~/projects # WezTerm
abbr -a :wgp kitty @ launch --type=os-window --cwd ~/projects # Kitty
# abbr -a :wgr wezterm cli spawn --new-window -- sudo -i # WezTerm
abbr -a :wgr kitty @ launch --type=os-window -- sudo -i # Kitty
# Specialty Window Vertical Shortcuts (Split Bottom)
# abbr -a :wvgk wezterm cli split-pane --bottom --cwd ~/.config/kitty # WezTerm
abbr -a :wvgk kitty @ launch --location=hsplit --cwd ~/.config/kitty # Kitty
# abbr -a :wvgn wezterm cli split-pane --bottom --cwd ~/.config/nvim # WezTerm
abbr -a :wvgn kitty @ launch --location=hsplit --cwd ~/.config/nvim # Kitty
# abbr -a :wvgf wezterm cli split-pane --bottom --cwd ~/.config/fish # WezTerm
abbr -a :wvgf kitty @ launch --location=hsplit --cwd ~/.config/fish # Kitty
# abbr -a :wvgh wezterm cli split-pane --bottom --cwd ~ # WezTerm
abbr -a :wvgh kitty @ launch --location=hsplit --cwd ~ # Kitty
# abbr -a :wvgcz wezterm cli split-pane --bottom --cwd ~/.local/share/chezmoi # WezTerm
abbr -a :wvgcz kitty @ launch --location=hsplit --cwd ~/.local/share/chezmoi # Kitty
# abbr -a :wvgcm wezterm cli split-pane --bottom --cwd ~/.config/chezmoi # WezTerm
abbr -a :wvgcm kitty @ launch --location=hsplit --cwd ~/.config/chezmoi # Kitty
# abbr -a :wvgp wezterm cli split-pane --bottom --cwd ~/projects # WezTerm
abbr -a :wvgp kitty @ launch --location=hsplit --cwd ~/projects # Kitty
# abbr -a :wvgr wezterm cli split-pane --bottom -- sudo -i # WezTerm
abbr -a :wvgr kitty @ launch --location=hsplit -- sudo -i # Kitty
# Specialty Window Horizontal Shortcuts (Split Right)
# abbr -a :whgk wezterm cli split-pane --bottom --cwd ~/.config/kitty # WezTerm
abbr -a :whgk kitty @ launch --location=vsplit --cwd ~/.config/kitty # Kitty
# abbr -a :whgn wezterm cli split-pane --bottom --cwd ~/.config/nvim # WezTerm
abbr -a :whgn kitty @ launch --location=vsplit --cwd ~/.config/nvim # Kitty
# abbr -a :whgf wezterm cli split-pane --bottom --cwd ~/.config/fish # WezTerm
abbr -a :whgf kitty @ launch --location=vsplit --cwd ~/.config/fish # Kitty
# abbr -a :whgh wezterm cli split-pane --bottom --cwd ~ # WezTerm
abbr -a :whgh kitty @ launch --location=vsplit --cwd ~ # Kitty
# abbr -a :whgcz wezterm cli split-pane --bottom --cwd ~/.local/share/chezmoi # WezTerm
abbr -a :whgcz kitty @ launch --location=vsplit --cwd ~/.local/share/chezmoi # Kitty
# abbr -a :whgcm wezterm cli split-pane --bottom --cwd ~/.config/chezmoi # WezTerm
abbr -a :whgcm kitty @ launch --location=vsplit --cwd ~/.config/chezmoi # Kitty
# abbr -a :whgp wezterm cli split-pane --bottom --cwd ~/projects # WezTerm
abbr -a :whgp kitty @ launch --location=vsplit --cwd ~/projects # Kitty
# abbr -a :whgr wezterm cli split-pane --bottom -- sudo -i # WezTerm
abbr -a :whgr kitty @ launch --location=vsplit --cwd current sudo -i # Kitty -> Specialty cd Shortcuts
abbr -a :cdk 'cd ~/.config/kitty/ # Kitty Config'
abbr -a :cdkn 'cd ~/.config/kitty;nvim'
abbr -a :cdn cd '~/.config/nvim/ # Neovim Config'
abbr -a :cdnn 'cd ~/.config/nvim;nvim'
abbr -a :cdf 'cd ~/.config/fish/ # Fish Config'
abbr -a :cdfn 'cd ~/.config/fish;nvim'
abbr -a :cdh 'cd ~ # Home Directory'
abbr -a :cdhn 'cd ~;nvim'
abbr -a :cdcz cd '~/.local/share/chezmoi/ # Chezmoi Source'
abbr -a :cdczn 'cd ~/.local/share/chezmoi;nvim'
abbr -a :cdcm 'cd ~/.config/chezmoi/ # Chezmoi Config'
abbr -a :cdcmn 'cd ~/.config/chezmoi;nvim'
abbr -a :cdp --regex ':cdp' --set-cursor 'cd ~/projects/%'
# abbr -a cdp_slash --position anywhere --regex ':cdp/' --set-cursor 'cd ~/projects/%'
abbr -a :cdpn 'cd ~/projects;nvim'
abbr -a :cdw 'cd ~/.config/wezterm/ # WezTerm Config'
abbr -a :cdwn 'cd ~/.config/wezterm;nvim'
abbr -a editt kitty @ launch --type tab nvim
# Spawn window
abbr -a :sw spwin
### SSH ###
abbr -a sshr 'ssh rootiest@rootiest-server.local'
abbr -a sshrt 'ssh rootiest-server'
abbr -a sshrl 'ssh rootiest@rootiest-server.local'
### Docker ###
abbr -a dcr 'docker context use rootiest # Rootiest Server'
abbr -a dcl 'docker context use default # Local Host'
abbr -a dck 'docker context use racknerd # RackNerd Server'
abbr -a lzd ld
abbr -a dcls 'docker context ls'
### Beads ###
abbr -a bl 'bd list'
abbr -a bs 'bd sync'
abbr -a bc 'bd create --title'
abbr -a bsh 'bd show'
abbr -a lb lazybeads
### Systemctl ###
abbr -a sc systemctl
abbr -a ssc 'sudo systemctl'
abbr -a scu 'systemctl --user'
abbr -a st 'systemctl status'
abbr -a scs 'systemctl start'
abbr -a scr 'systemctl restart'
abbr -a ssct 'sudo systemctl status'
abbr -a sscs 'sudo systemctl start'
abbr -a sscr 'sudo systemctl restart'
### Rootiest Notes ###
abbr -a cdnote 'cd ~/Documents/Rootiest\ Notes/ # Rootiest Notes'
+39
View File
@@ -0,0 +1,39 @@
status is-interactive || exit
set --global autopair_left "(" "[" "{" '"' "'"
set --global autopair_right ")" "]" "}" '"' "'"
set --global autopair_pairs "()" "[]" "{}" '""' "''"
function _autopair_fish_key_bindings --on-variable fish_key_bindings
set --query fish_key_bindings[1] || return
test $fish_key_bindings = fish_default_key_bindings &&
set --local mode default insert ||
set --local mode insert default
bind --mode $mode[-1] --erase \177 \b \t
bind --mode $mode[1] \177 _autopair_backspace # macOS ⌫
bind --mode $mode[1] \b _autopair_backspace
bind --mode $mode[1] \t _autopair_tab
printf "%s\n" $autopair_pairs | while read --local left right --delimiter ""
bind --mode $mode[-1] --erase $left $right
if test $left = $right
bind --mode $mode[1] $left "_autopair_insert_same \\$left"
else
bind --mode $mode[1] $left "_autopair_insert_left \\$left \\$right"
bind --mode $mode[1] $right "_autopair_insert_right \\$right"
end
end
end
_autopair_fish_key_bindings
function _autopair_uninstall --on-event autopair_uninstall
string collect (
bind --all | string replace --filter --regex -- "_autopair.*" --erase
set --names | string replace --filter --regex -- "^autopair" "set --erase autopair"
) | source
functions --erase (functions --all | string match "_autopair_*")
end
+54
View File
@@ -0,0 +1,54 @@
set -g theme_nerd_fonts yes
set -g theme_color_scheme catpuccin-mocha
set -g theme_display_user ssh
set -g default_user rootiest
set -g theme_display_cmd_duration yes
set -g theme_display_git_dirty yes
set -g theme_display_virtualenv yes
set -g theme_display_screen yes
set -g theme_display_docker_machine yes
set -g theme_display_docker_context yes
set -g theme_display_nix yes
set -g theme_display_k8s_context yes
set -g theme_display_k8s_namespace yes
set -g theme_display_aws_vault_profile yes
set -g fish_key_bindings fish_vi_key_bindings
set -g theme_nerd_fonts yes
set -g theme_color_scheme catpuccin-mocha
set -g theme_display_user ssh
set -g default_user rootiest
function bobthefish_colors -S -d 'Define a custom bobthefish color scheme'
# optionally include a base color scheme...
# ___bobthefish_colors default
# then override everything you want! note that these must be defined with `set -x`
set -x color_initial_segment_exit ffffff ce000f --bold
set -x color_initial_segment_private ffffff 255e87
set -x color_initial_segment_su ffffff 189303 --bold
set -x color_initial_segment_jobs ffffff 255e87 --bold
set -x color_path 45475a a6adc8
set -x color_path_basename 45475a ffffff --bold
set -x color_path_nowrite f37799 585b70
set -x color_path_nowrite_basename f37799 585b70 --bold
set -x color_repo 89d88b 585b70
set -x color_repo_work_tree 45475a ffffff --bold
set -x color_repo_dirty f3799a ffffff
set -x color_repo_staged ebd391 45475a
set -x color_vi_mode_default a6adc8 45475a --bold
set -x color_vi_mode_insert 89d88b 45475a --bold
set -x color_vi_mode_visual ebd391 45475a --bold
set -x color_vagrant 48b4fb ffffff --bold
set -x color_aws_vault
set -x color_aws_vault_expired
set -x color_username 585b70 74a8fc --bold
set -x color_hostname 585b70 74a8fc
set -x color_rvm f37799 585b70 --bold
set -x color_virtualfish 89b4fa 585b70 --bold
set -x color_virtualgo 89b4fa 585b70 --bold
set -x color_desk 89b4fa 585b70 --bold
set -x color_nix 89b4fa 585b70 --bold
end
+13
View File
@@ -0,0 +1,13 @@
complete -c cheat -f -a "(cheat -l | tail -n +2 | cut -d ' ' -f 1)"
complete -c cheat -l init -d "Write a default config file to stdout"
complete -c cheat -s c -l colorize -d "Colorize output"
complete -c cheat -s d -l directories -d "List cheatsheet directories"
complete -c cheat -s e -l edit -x -a "(cheat -l | tail -n +2 | cut -d ' ' -f 1)" -d "Edit cheatsheet"
complete -c cheat -s l -l list -d "List cheatsheets"
complete -c cheat -s p -l path -x -a "(cheat -d | cut -d ':' -f 1)" -d "Return only sheets found on given path"
complete -c cheat -s r -l regex -d "Treat search phrase as a regex"
complete -c cheat -s s -l search -x -d "Search cheatsheets for given phrase"
complete -c cheat -s t -l tag -x -a "(cheat -T)" -d "Return only sheets matching the given tag"
complete -c cheat -s T -l tags -d "List all tags in use"
complete -c cheat -s v -l version -d "Print the version number"
complete -c cheat -l rm -x -a "(cheat -l | tail -n +2 | cut -d ' ' -f 1)" -d "Remove (delete) cheatsheet"
+14
View File
@@ -0,0 +1,14 @@
# This file was created by fish when upgrading to version 4.3, to migrate
# the 'fish_key_bindings' variable from its old default scope (universal)
# to its new default scope (global). We recommend you delete this file
# and configure key bindings in ~/.config/fish/config.fish if needed.
# set --global fish_key_bindings fish_default_key_bindings
# Prior to version 4.3, fish shipped an event handler that runs
# `set --universal fish_key_bindings fish_default_key_bindings`
# whenever the fish_key_bindings variable is erased.
# This means that as long as any fish < 4.3 is still running on this system,
# we cannot complete the migration.
# As a workaround, erase the universal variable at every shell startup.
set --erase --universal fish_key_bindings
+49
View File
@@ -0,0 +1,49 @@
# This file was created by fish when upgrading to version 4.3, to migrate
# theme variables from universal to global scope.
# Don't edit this file, as it will be written by the web-config tool (`fish_config`).
# To customize your theme, delete this file and see
# help interactive#syntax-highlighting
# or
# man fish-interactive | less +/^SYNTAX.HIGHLIGHTING
# for appropriate commands to add to ~/.config/fish/config.fish instead.
# See also the release notes for fish 4.3.0 (run `help relnotes`).
set --global fish_color_autosuggestion 6c7086
set --global fish_color_cancel f38ba8
set --global fish_color_command 89b4fa
set --global fish_color_comment 7f849c
set --global fish_color_cwd f9e2af
set --global fish_color_cwd_root red
set --global fish_color_end fab387
set --global fish_color_error f38ba8
set --global fish_color_escape eba0ac
set --global fish_color_gray 6c7086
set --global fish_color_history_current --bold
set --global fish_color_host 89b4fa
set --global fish_color_host_remote a6e3a1
set --global fish_color_keyword f38ba8
set --global fish_color_match F28779
set --global fish_color_normal cdd6f4
set --global fish_color_operator f5c2e7
set --global fish_color_option a6e3a1
set --global fish_color_param f2cdcd
set --global fish_color_quote a6e3a1
set --global fish_color_redirection f5c2e7
set --global fish_color_search_match --background=313244
set --global fish_color_selection --background=313244
set --global fish_color_status f38ba8
set --global fish_color_user 94e2d5
set --global fish_color_valid_path --underline
set --global fish_pager_color_background
set --global fish_pager_color_completion cdd6f4
set --global fish_pager_color_description 6c7086
set --global fish_pager_color_prefix f5c2e7
set --global fish_pager_color_progress 6c7086
set --global fish_pager_color_secondary_background
set --global fish_pager_color_secondary_completion
set --global fish_pager_color_secondary_description
set --global fish_pager_color_secondary_prefix
set --global fish_pager_color_selected_background
set --global fish_pager_color_selected_completion
set --global fish_pager_color_selected_description
set --global fish_pager_color_selected_prefix
+27
View File
@@ -0,0 +1,27 @@
# fzf.fish is only meant to be used in interactive mode. If not in interactive mode and not in CI, skip the config to speed up shell startup
if not status is-interactive && test "$CI" != true
exit
end
# Because of scoping rules, to capture the shell variables exactly as they are, we must read
# them before even executing _fzf_search_variables. We use psub to store the
# variables' info in temporary files and pass in the filenames as arguments.
# This variable is global so that it can be referenced by fzf_configure_bindings and in tests
set --global _fzf_search_vars_command '_fzf_search_variables (set --show | psub) (set --names | psub)'
# Install the default bindings, which are mnemonic and minimally conflict with fish's preset bindings
fzf_configure_bindings
# Doesn't erase autoloaded _fzf_* functions because they are not easily accessible once key bindings are erased
function _fzf_uninstall --on-event fzf_uninstall
_fzf_uninstall_bindings
set --erase _fzf_search_vars_command
functions --erase _fzf_uninstall _fzf_migration_message _fzf_uninstall_bindings fzf_configure_bindings
complete --erase fzf_configure_bindings
set_color cyan
echo "fzf.fish uninstalled."
echo "You may need to manually remove fzf_configure_bindings from your config.fish if you were using custom key bindings."
set_color normal
end
+25
View File
@@ -0,0 +1,25 @@
function magic-enter-cmd --description "Print the command to run when no command was given"
set -l cmd ls
if command git rev-parse --is-inside-work-tree &>/dev/null
set cmd "git status -sb"
end
echo $cmd
end
function magic-enter
set -l cmd (commandline)
if test -z "$cmd"
commandline -r (magic-enter-cmd)
commandline -f suppress-autosuggestion
end
commandline -f execute
end
function magic-enter-bindings --description "Bind magic-enter for default and vi key bindings"
bind \r magic-enter
if functions -q fish_vi_key_bindings
bind -M insert \r magic-enter
bind -M default \r magic-enter
end
end
magic-enter-bindings
+27
View File
@@ -0,0 +1,27 @@
status is-interactive || exit
function _puffer_fish_key_bindings --on-variable fish_key_bindings
set -l modes
if test "$fish_key_bindings" = fish_default_key_bindings
set modes default insert
else
set modes insert default
end
bind --mode $modes[1] '.' _puffer_fish_expand_dot
bind --mode $modes[1] '!' _puffer_fish_expand_bang
bind --mode $modes[1] '$' _puffer_fish_expand_buck
bind --mode $modes[1] '*' _puffer_fish_expand_star
bind --mode $modes[2] --erase '.' '!' '$' '*'
end
_puffer_fish_key_bindings
set -l uninstall_event puffer_fish_key_bindings_uninstall
function _$uninstall_event --on-event $uninstall_event
bind -e '.'
bind -e '!'
bind -e '$'
bind -e '*'
end
+248
View File
@@ -0,0 +1,248 @@
# Copyright 2013-2023 The Cobra Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# fish completion for tailscale -*- shell-script -*-
function __tailscale_debug
set -l file "$BASH_COMP_DEBUG_FILE"
if test -n "$file"
echo "$argv" >> $file
end
end
function __tailscale_perform_completion
__tailscale_debug "Starting __tailscale_perform_completion"
# Extract all args except the last one
set -l args (commandline -opc)
# Extract the last arg and escape it in case it is a space
set -l lastArg (string escape -- (commandline -ct))
__tailscale_debug "args: $args"
__tailscale_debug "last arg: $lastArg"
set -l requestComp "$args[1] completion __complete --descs=true --flags=true -- $args[2..-1] $lastArg"
__tailscale_debug "Calling $requestComp"
set -l results (eval $requestComp 2> /dev/null)
# Some programs may output extra empty lines after the directive.
# Let's ignore them or else it will break completion.
# Ref: https://github.com/spf13/cobra/issues/1279
for line in $results[-1..1]
if test (string trim -- $line) = ""
# Found an empty line, remove it
set results $results[1..-2]
else
# Found non-empty line, we have our proper output
break
end
end
set -l comps $results[1..-2]
set -l directiveLine $results[-1]
# For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)
# completions must be prefixed with the flag
set -l flagPrefix (string match -r -- '-.*=' "$lastArg")
__tailscale_debug "Comps: $comps"
__tailscale_debug "DirectiveLine: $directiveLine"
__tailscale_debug "flagPrefix: $flagPrefix"
for comp in $comps
printf "%s%s\n" "$flagPrefix" "$comp"
end
printf "%s\n" "$directiveLine"
end
# this function limits calls to __tailscale_perform_completion, by caching the result behind $__tailscale_perform_completion_once_result
function __tailscale_perform_completion_once
__tailscale_debug "Starting __tailscale_perform_completion_once"
if test -n "$__tailscale_perform_completion_once_result"
__tailscale_debug "Seems like a valid result already exists, skipping __tailscale_perform_completion"
return 0
end
set --global __tailscale_perform_completion_once_result (__tailscale_perform_completion)
if test -z "$__tailscale_perform_completion_once_result"
__tailscale_debug "No completions, probably due to a failure"
return 1
end
__tailscale_debug "Performed completions and set __tailscale_perform_completion_once_result"
return 0
end
# this function is used to clear the $__tailscale_perform_completion_once_result variable after completions are run
function __tailscale_clear_perform_completion_once_result
__tailscale_debug ""
__tailscale_debug "========= clearing previously set __tailscale_perform_completion_once_result variable =========="
set --erase __tailscale_perform_completion_once_result
__tailscale_debug "Successfully erased the variable __tailscale_perform_completion_once_result"
end
function __tailscale_requires_order_preservation
__tailscale_debug ""
__tailscale_debug "========= checking if order preservation is required =========="
__tailscale_perform_completion_once
if test -z "$__tailscale_perform_completion_once_result"
__tailscale_debug "Error determining if order preservation is required"
return 1
end
set -l directive (string sub --start 2 $__tailscale_perform_completion_once_result[-1])
__tailscale_debug "Directive is: $directive"
set -l shellCompDirectiveKeepOrder 32
set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)
__tailscale_debug "Keeporder is: $keeporder"
if test $keeporder -ne 0
__tailscale_debug "This does require order preservation"
return 0
end
__tailscale_debug "This doesn't require order preservation"
return 1
end
# This function does two things:
# - Obtain the completions and store them in the global __tailscale_comp_results
# - Return false if file completion should be performed
function __tailscale_prepare_completions
__tailscale_debug ""
__tailscale_debug "========= starting completion logic =========="
# Start fresh
set --erase __tailscale_comp_results
__tailscale_perform_completion_once
__tailscale_debug "Completion results: $__tailscale_perform_completion_once_result"
if test -z "$__tailscale_perform_completion_once_result"
__tailscale_debug "No completion, probably due to a failure"
# Might as well do file completion, in case it helps
return 1
end
set -l directive (string sub --start 2 $__tailscale_perform_completion_once_result[-1])
set --global __tailscale_comp_results $__tailscale_perform_completion_once_result[1..-2]
__tailscale_debug "Completions are: $__tailscale_comp_results"
__tailscale_debug "Directive is: $directive"
set -l shellCompDirectiveError 1
set -l shellCompDirectiveNoSpace 2
set -l shellCompDirectiveNoFileComp 4
set -l shellCompDirectiveFilterFileExt 8
set -l shellCompDirectiveFilterDirs 16
if test -z "$directive"
set directive 0
end
set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)
if test $compErr -eq 1
__tailscale_debug "Received error directive: aborting."
# Might as well do file completion, in case it helps
return 1
end
set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)
set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)
if test $filefilter -eq 1; or test $dirfilter -eq 1
__tailscale_debug "File extension filtering or directory filtering not supported"
# Do full file completion instead
return 1
end
set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)
set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)
__tailscale_debug "nospace: $nospace, nofiles: $nofiles"
# If we want to prevent a space, or if file completion is NOT disabled,
# we need to count the number of valid completions.
# To do so, we will filter on prefix as the completions we have received
# may not already be filtered so as to allow fish to match on different
# criteria than the prefix.
if test $nospace -ne 0; or test $nofiles -eq 0
set -l prefix (commandline -t | string escape --style=regex)
__tailscale_debug "prefix: $prefix"
set -l completions (string match -r -- "^$prefix.*" $__tailscale_comp_results)
set --global __tailscale_comp_results $completions
__tailscale_debug "Filtered completions are: $__tailscale_comp_results"
# Important not to quote the variable for count to work
set -l numComps (count $__tailscale_comp_results)
__tailscale_debug "numComps: $numComps"
if test $numComps -eq 1; and test $nospace -ne 0
# We must first split on \t to get rid of the descriptions to be
# able to check what the actual completion will be.
# We don't need descriptions anyway since there is only a single
# real completion which the shell will expand immediately.
set -l split (string split --max 1 \t $__tailscale_comp_results[1])
# Fish won't add a space if the completion ends with any
# of the following characters: @=/:.,
set -l lastChar (string sub -s -1 -- $split)
if not string match -r -q "[@=/:.,]" -- "$lastChar"
# In other cases, to support the "nospace" directive we trick the shell
# by outputting an extra, longer completion.
__tailscale_debug "Adding second completion to perform nospace directive"
set --global __tailscale_comp_results $split[1] $split[1].
__tailscale_debug "Completions are now: $__tailscale_comp_results"
end
end
if test $numComps -eq 0; and test $nofiles -eq 0
# To be consistent with bash and zsh, we only trigger file
# completion when there are no other completions
__tailscale_debug "Requesting file completion"
return 1
end
end
return 0
end
# Since Fish completions are only loaded once the user triggers them, we trigger them ourselves
# so we can properly delete any completions provided by another script.
# Only do this if the program can be found, or else fish may print some errors; besides,
# the existing completions will only be loaded if the program can be found.
if type -q "tailscale"
# The space after the program name is essential to trigger completion for the program
# and not completion of the program name itself.
# Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
complete --do-complete "tailscale " > /dev/null 2>&1
end
# Remove any pre-existing completions for the program since we will be handling all of them.
complete -c tailscale -e
# this will get called after the two calls below and clear the $__tailscale_perform_completion_once_result global
complete -c tailscale -n '__tailscale_clear_perform_completion_once_result'
# The call to __tailscale_prepare_completions will setup __tailscale_comp_results
# which provides the program's completion choices.
# If this doesn't require order preservation, we don't use the -k flag
complete -c tailscale -n 'not __tailscale_requires_order_preservation && __tailscale_prepare_completions' -f -a '$__tailscale_comp_results'
# otherwise we use the -k flag
complete -k -c tailscale -n '__tailscale_requires_order_preservation && __tailscale_prepare_completions' -f -a '$__tailscale_comp_results'
+43
View File
@@ -0,0 +1,43 @@
###
# wakatime.fish
#
# hook script to send wakatime a tick (unofficial)
# see: https://github.com/ik11235/wakatime.fish
###
function __register_wakatime_fish_before_exec -e fish_postexec
if set -q FISH_WAKATIME_DISABLED
return 0
end
set -l exec_command_str
set exec_command_str (string split -f1 ' ' "$argv")
if test "$exec_command_str" = 'exit'
return 0
end
set -l PLUGIN_NAME "ik11235/wakatime.fish"
set -l PLUGIN_VERSION "0.0.6"
set -l project
set -l wakatime_path
if type -p wakatime 2>&1 > /dev/null
set wakatime_path (type -p wakatime)
else if type -p ~/.wakatime/wakatime-cli 2>&1 > /dev/null
set wakatime_path (type -p ~/.wakatime/wakatime-cli)
else
echo "wakatime command not found. Please read \"https://wakatime.com/terminal\" and install wakatime."
return 1
end
if git rev-parse --is-inside-work-tree &> /dev/null
set project (basename (git rev-parse --show-toplevel))
else
set project "Terminal"
end
$wakatime_path --write --plugin "$PLUGIN_NAME/$PLUGIN_VERSION" --entity-type app --project "$project" --entity "$exec_command_str" &> /dev/null&; disown
end
+100
View File
@@ -0,0 +1,100 @@
# =============================================================================
#
# 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 __zoxide_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)'
# Jump to a directory using interactive search.
function __zoxide_zi
set -l result (command zoxide query --interactive -- $argv)
and __zoxide_cd $result
end
# =============================================================================
#
# Commands for zoxide. Disable these using --no-cmd.
#
abbr --erase z &>/dev/null
alias z=__zoxide_z
abbr --erase zi &>/dev/null
alias zi=__zoxide_zi
# =============================================================================
#
# To initialize zoxide, add this to your configuration (usually
# ~/.config/fish/config.fish):
#
# zoxide init fish | source