Select the types of activity you want to include in your feed.
Void Linux workstation powered by niri, Fish and NeoVim. Contains scripts, browser extensions, custom XBPS packages, and typst plugins.
git.anhgelus.world/anhgelus/dotfiles
···11+# This is terribly complicated
22+# It's because:
33+# 1. bun run has to have dynamic completions
44+# 2. there are global options
55+# 3. bun {install add remove} gets special options
66+# 4. I don't know how to write fish completions well
77+# Contributions very welcome!!
88+99+function __fish__get_bun_bins
1010+ string split ' ' (bun getcompletes b)
1111+end
1212+1313+function __fish__get_bun_scripts
1414+ set -lx SHELL bash
1515+ set -lx MAX_DESCRIPTION_LEN 40
1616+ string trim (string split '\n' (string split '\t' (bun getcompletes z)))
1717+end
1818+1919+function __fish__get_bun_packages
2020+ if test (commandline -ct) != ""
2121+ set -lx SHELL fish
2222+ string split ' ' (bun getcompletes a (commandline -ct))
2323+ end
2424+end
2525+2626+function __history_completions
2727+ set -l tokens (commandline --current-process --tokenize)
2828+ history --prefix (commandline) | string replace -r \^$tokens[1]\\s\* "" | string replace -r \^$tokens[2]\\s\* "" | string split ' '
2929+end
3030+3131+function __fish__get_bun_bun_js_files
3232+ string split ' ' (bun getcompletes j)
3333+end
3434+3535+set -l bun_install_boolean_flags yarn production optional development no-save dry-run force no-cache silent verbose global
3636+set -l bun_install_boolean_flags_descriptions "Write a yarn.lock file (yarn v1)" "Don't install devDependencies" "Add dependency to optionalDependencies" "Add dependency to devDependencies" "Don't update package.json or save a lockfile" "Don't install anything" "Always request the latest versions from the registry & reinstall all dependencies" "Ignore manifest cache entirely" "Don't output anything" "Excessively verbose logging" "Use global folder"
3737+3838+set -l bun_builtin_cmds_without_run dev create help bun upgrade discord install remove add init pm x
3939+set -l bun_builtin_cmds_accepting_flags create help bun upgrade discord run init link unlink pm x
4040+4141+function __bun_complete_bins_scripts --inherit-variable bun_builtin_cmds_without_run -d "Emit bun completions for bins and scripts"
4242+ # Do nothing if we already have a builtin subcommand,
4343+ # or any subcommand other than "run".
4444+ if __fish_seen_subcommand_from $bun_builtin_cmds_without_run
4545+ or not __fish_use_subcommand && not __fish_seen_subcommand_from run
4646+ return
4747+ end
4848+ # Do we already have a bin or script subcommand?
4949+ set -l bins (__fish__get_bun_bins)
5050+ if __fish_seen_subcommand_from $bins
5151+ return
5252+ end
5353+ # Scripts have descriptions appended with a tab separator.
5454+ # Strip off descriptions for the purposes of subcommand testing.
5555+ set -l scripts (__fish__get_bun_scripts)
5656+ if __fish_seen_subcommand_from (string split \t -f 1 -- $scripts)
5757+ return
5858+ end
5959+ # Emit scripts.
6060+ for script in $scripts
6161+ echo $script
6262+ end
6363+ # Emit binaries and JS files (but only if we're doing `bun run`).
6464+ if __fish_seen_subcommand_from run
6565+ for bin in $bins
6666+ echo "$bin"\t"package bin"
6767+ end
6868+ for file in (__fish__get_bun_bun_js_files)
6969+ echo "$file"\t"Bun.js"
7070+ end
7171+ end
7272+end
7373+7474+7575+# Clear existing completions
7676+complete -e -c bun
7777+7878+# Dynamically emit scripts and binaries
7979+complete -c bun -f -a "(__bun_complete_bins_scripts)"
8080+8181+# Complete flags if we have no subcommand or a flag-friendly one.
8282+set -l flag_applies "__fish_use_subcommand; or __fish_seen_subcommand_from $bun_builtin_cmds_accepting_flags"
8383+complete -c bun \
8484+ -n $flag_applies --no-files -s 'u' -l 'origin' -r -d 'Server URL. Rewrites import paths'
8585+complete -c bun \
8686+ -n $flag_applies --no-files -s 'p' -l 'port' -r -d 'Port number to start server from'
8787+complete -c bun \
8888+ -n $flag_applies --no-files -s 'd' -l 'define' -r -d 'Substitute K:V while parsing, e.g. --define process.env.NODE_ENV:\"development\"'
8989+complete -c bun \
9090+ -n $flag_applies --no-files -s 'e' -l 'external' -r -d 'Exclude module from transpilation (can use * wildcards). ex: -e react'
9191+complete -c bun \
9292+ -n $flag_applies --no-files -l 'use' -r -d 'Use a framework (ex: next)'
9393+complete -c bun \
9494+ -n $flag_applies --no-files -l 'hot' -r -d 'Enable hot reloading in Bun\'s JavaScript runtime'
9595+9696+# Complete dev and create as first subcommand.
9797+complete -c bun \
9898+ -n "__fish_use_subcommand" -a 'dev' -d 'Start dev server'
9999+complete -c bun \
100100+ -n "__fish_use_subcommand" -a 'create' -f -d 'Create a new project from a template'
101101+102102+# Complete "next" and "react" if we've seen "create".
103103+complete -c bun \
104104+ -n "__fish_seen_subcommand_from create" -a 'next' -d 'new Next.js project'
105105+106106+complete -c bun \
107107+ -n "__fish_seen_subcommand_from create" -a 'react' -d 'new React project'
108108+109109+# Complete "upgrade" as first subcommand.
110110+complete -c bun \
111111+ -n "__fish_use_subcommand" -a 'upgrade' -d 'Upgrade bun to the latest version' -x
112112+# Complete "-h/--help" unconditionally.
113113+complete -c bun \
114114+ -s "h" -l "help" -d 'See all commands and flags' -x
115115+116116+# Complete "-v/--version" if we have no subcommand.
117117+complete -c bun \
118118+ -n "not __fish_use_subcommand" -l "version" -s "v" -d 'Bun\'s version' -x
119119+120120+# Complete additional subcommands.
121121+complete -c bun \
122122+ -n "__fish_use_subcommand" -a 'discord' -d 'Open bun\'s Discord server' -x
123123+124124+125125+complete -c bun \
126126+ -n "__fish_use_subcommand" -a 'bun' -d 'Generate a new bundle'
127127+128128+129129+complete -c bun \
130130+ -n "__fish_seen_subcommand_from bun" -F -d 'Bundle this'
131131+132132+complete -c bun \
133133+ -n "__fish_seen_subcommand_from create; and __fish_seen_subcommand_from react next" -F -d "Create in directory"
134134+135135+136136+complete -c bun \
137137+ -n "__fish_use_subcommand" -a 'init' -F -d 'Start an empty Bun project'
138138+139139+complete -c bun \
140140+ -n "__fish_use_subcommand" -a 'install' -f -d 'Install packages from package.json'
141141+142142+complete -c bun \
143143+ -n "__fish_use_subcommand" -a 'add' -F -d 'Add a package to package.json'
144144+145145+complete -c bun \
146146+ -n "__fish_use_subcommand" -a 'remove' -F -d 'Remove a package from package.json'
147147+148148+149149+for i in (seq (count $bun_install_boolean_flags))
150150+ complete -c bun \
151151+ -n "__fish_seen_subcommand_from install add remove" -l "$bun_install_boolean_flags[$i]" -d "$bun_install_boolean_flags_descriptions[$i]"
152152+end
153153+154154+complete -c bun \
155155+ -n "__fish_seen_subcommand_from install add remove" -l 'cwd' -d 'Change working directory'
156156+157157+complete -c bun \
158158+ -n "__fish_seen_subcommand_from install add remove" -l 'cache-dir' -d 'Choose a cache directory (default: $HOME/.bun/install/cache)'
159159+160160+complete -c bun \
161161+ -n "__fish_seen_subcommand_from add" -d 'Popular' -a '(__fish__get_bun_packages)'
162162+163163+complete -c bun \
164164+ -n "__fish_seen_subcommand_from add" -d 'History' -a '(__history_completions)'
165165+166166+complete -c bun \
167167+ -n "__fish_seen_subcommand_from pm; and not __fish_seen_subcommand_from (__fish__get_bun_bins) (__fish__get_bun_scripts) cache;" -a 'bin ls cache hash hash-print hash-string' -f
168168+169169+complete -c bun \
170170+ -n "__fish_seen_subcommand_from pm; and __fish_seen_subcommand_from cache; and not __fish_seen_subcommand_from (__fish__get_bun_bins) (__fish__get_bun_scripts);" -a 'rm' -f
171171+172172+# Add built-in subcommands with descriptions.
173173+complete -c bun -n "__fish_use_subcommand" -a "create" -f -d "Create a new project from a template"
174174+complete -c bun -n "__fish_use_subcommand" -a "build bun" --require-parameter -F -d "Transpile and bundle one or more files"
175175+complete -c bun -n "__fish_use_subcommand" -a "upgrade" -d "Upgrade Bun"
176176+complete -c bun -n "__fish_use_subcommand" -a "run" -d "Run a script or package binary"
177177+complete -c bun -n "__fish_use_subcommand" -a "install" -d "Install dependencies from package.json" -f
178178+complete -c bun -n "__fish_use_subcommand" -a "remove" -d "Remove a dependency from package.json" -f
179179+complete -c bun -n "__fish_use_subcommand" -a "add" -d "Add a dependency to package.json" -f
180180+complete -c bun -n "__fish_use_subcommand" -a "init" -d "Initialize a Bun project in this directory" -f
181181+complete -c bun -n "__fish_use_subcommand" -a "link" -d "Register or link a local npm package" -f
182182+complete -c bun -n "__fish_use_subcommand" -a "unlink" -d "Unregister a local npm package" -f
183183+complete -c bun -n "__fish_use_subcommand" -a "pm" -d "Additional package management utilities" -f
184184+complete -c bun -n "__fish_use_subcommand" -a "x" -d "Execute a package binary, installing if needed" -f
185185+complete -c bun -n "__fish_use_subcommand" -a "outdated" -d "Display the latest versions of outdated dependencies" -f
186186+complete -c bun -n "__fish_use_subcommand" -a "publish" -d "Publish your package from local to npm" -f
+177
config/fish/completions/packwiz.fish
···11+# fish completion for packwiz -*- shell-script -*-
22+33+function __packwiz_debug
44+ set -l file "$BASH_COMP_DEBUG_FILE"
55+ if test -n "$file"
66+ echo "$argv" >> $file
77+ end
88+end
99+1010+function __packwiz_perform_completion
1111+ __packwiz_debug "Starting __packwiz_perform_completion"
1212+1313+ # Extract all args except the last one
1414+ set -l args (commandline -opc)
1515+ # Extract the last arg and escape it in case it is a space
1616+ set -l lastArg (string escape -- (commandline -ct))
1717+1818+ __packwiz_debug "args: $args"
1919+ __packwiz_debug "last arg: $lastArg"
2020+2121+ # Disable ActiveHelp which is not supported for fish shell
2222+ set -l requestComp "PACKWIZ_ACTIVE_HELP=0 $args[1] __complete $args[2..-1] $lastArg"
2323+2424+ __packwiz_debug "Calling $requestComp"
2525+ set -l results (eval $requestComp 2> /dev/null)
2626+2727+ # Some programs may output extra empty lines after the directive.
2828+ # Let's ignore them or else it will break completion.
2929+ # Ref: https://github.com/spf13/cobra/issues/1279
3030+ for line in $results[-1..1]
3131+ if test (string trim -- $line) = ""
3232+ # Found an empty line, remove it
3333+ set results $results[1..-2]
3434+ else
3535+ # Found non-empty line, we have our proper output
3636+ break
3737+ end
3838+ end
3939+4040+ set -l comps $results[1..-2]
4141+ set -l directiveLine $results[-1]
4242+4343+ # For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)
4444+ # completions must be prefixed with the flag
4545+ set -l flagPrefix (string match -r -- '-.*=' "$lastArg")
4646+4747+ __packwiz_debug "Comps: $comps"
4848+ __packwiz_debug "DirectiveLine: $directiveLine"
4949+ __packwiz_debug "flagPrefix: $flagPrefix"
5050+5151+ for comp in $comps
5252+ printf "%s%s\n" "$flagPrefix" "$comp"
5353+ end
5454+5555+ printf "%s\n" "$directiveLine"
5656+end
5757+5858+# This function does two things:
5959+# - Obtain the completions and store them in the global __packwiz_comp_results
6060+# - Return false if file completion should be performed
6161+function __packwiz_prepare_completions
6262+ __packwiz_debug ""
6363+ __packwiz_debug "========= starting completion logic =========="
6464+6565+ # Start fresh
6666+ set --erase __packwiz_comp_results
6767+6868+ set -l results (__packwiz_perform_completion)
6969+ __packwiz_debug "Completion results: $results"
7070+7171+ if test -z "$results"
7272+ __packwiz_debug "No completion, probably due to a failure"
7373+ # Might as well do file completion, in case it helps
7474+ return 1
7575+ end
7676+7777+ set -l directive (string sub --start 2 $results[-1])
7878+ set --global __packwiz_comp_results $results[1..-2]
7979+8080+ __packwiz_debug "Completions are: $__packwiz_comp_results"
8181+ __packwiz_debug "Directive is: $directive"
8282+8383+ set -l shellCompDirectiveError 1
8484+ set -l shellCompDirectiveNoSpace 2
8585+ set -l shellCompDirectiveNoFileComp 4
8686+ set -l shellCompDirectiveFilterFileExt 8
8787+ set -l shellCompDirectiveFilterDirs 16
8888+8989+ if test -z "$directive"
9090+ set directive 0
9191+ end
9292+9393+ set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)
9494+ if test $compErr -eq 1
9595+ __packwiz_debug "Received error directive: aborting."
9696+ # Might as well do file completion, in case it helps
9797+ return 1
9898+ end
9999+100100+ set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)
101101+ set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)
102102+ if test $filefilter -eq 1; or test $dirfilter -eq 1
103103+ __packwiz_debug "File extension filtering or directory filtering not supported"
104104+ # Do full file completion instead
105105+ return 1
106106+ end
107107+108108+ set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)
109109+ set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)
110110+111111+ __packwiz_debug "nospace: $nospace, nofiles: $nofiles"
112112+113113+ # If we want to prevent a space, or if file completion is NOT disabled,
114114+ # we need to count the number of valid completions.
115115+ # To do so, we will filter on prefix as the completions we have received
116116+ # may not already be filtered so as to allow fish to match on different
117117+ # criteria than the prefix.
118118+ if test $nospace -ne 0; or test $nofiles -eq 0
119119+ set -l prefix (commandline -t | string escape --style=regex)
120120+ __packwiz_debug "prefix: $prefix"
121121+122122+ set -l completions (string match -r -- "^$prefix.*" $__packwiz_comp_results)
123123+ set --global __packwiz_comp_results $completions
124124+ __packwiz_debug "Filtered completions are: $__packwiz_comp_results"
125125+126126+ # Important not to quote the variable for count to work
127127+ set -l numComps (count $__packwiz_comp_results)
128128+ __packwiz_debug "numComps: $numComps"
129129+130130+ if test $numComps -eq 1; and test $nospace -ne 0
131131+ # We must first split on \t to get rid of the descriptions to be
132132+ # able to check what the actual completion will be.
133133+ # We don't need descriptions anyway since there is only a single
134134+ # real completion which the shell will expand immediately.
135135+ set -l split (string split --max 1 \t $__packwiz_comp_results[1])
136136+137137+ # Fish won't add a space if the completion ends with any
138138+ # of the following characters: @=/:.,
139139+ set -l lastChar (string sub -s -1 -- $split)
140140+ if not string match -r -q "[@=/:.,]" -- "$lastChar"
141141+ # In other cases, to support the "nospace" directive we trick the shell
142142+ # by outputting an extra, longer completion.
143143+ __packwiz_debug "Adding second completion to perform nospace directive"
144144+ set --global __packwiz_comp_results $split[1] $split[1].
145145+ __packwiz_debug "Completions are now: $__packwiz_comp_results"
146146+ end
147147+ end
148148+149149+ if test $numComps -eq 0; and test $nofiles -eq 0
150150+ # To be consistent with bash and zsh, we only trigger file
151151+ # completion when there are no other completions
152152+ __packwiz_debug "Requesting file completion"
153153+ return 1
154154+ end
155155+ end
156156+157157+ return 0
158158+end
159159+160160+# Since Fish completions are only loaded once the user triggers them, we trigger them ourselves
161161+# so we can properly delete any completions provided by another script.
162162+# Only do this if the program can be found, or else fish may print some errors; besides,
163163+# the existing completions will only be loaded if the program can be found.
164164+if type -q "packwiz"
165165+ # The space after the program name is essential to trigger completion for the program
166166+ # and not completion of the program name itself.
167167+ # Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
168168+ complete --do-complete "packwiz " > /dev/null 2>&1
169169+end
170170+171171+# Remove any pre-existing completions for the program since we will be handling all of them.
172172+complete -c packwiz -e
173173+174174+# The call to __packwiz_prepare_completions will setup __packwiz_comp_results
175175+# which provides the program's completion choices.
176176+complete -c packwiz -n '__packwiz_prepare_completions' -f -a '$__packwiz_comp_results'
177177+
+14
config/fish/config.fish
···11+if status is-interactive
22+ # Commands to run in interactive sessions can go here
33+ if tty | string match "/dev/tty1"
44+ $HOME/start
55+ end
66+end
77+88+# bun
99+set --export BUN_INSTALL "$HOME/.bun"
1010+set --export GOPATH "$HOME/go"
1111+set --export PATH $BUN_INSTALL/bin $GOPATH/bin $HOME/.local/bin $PATH
1212+1313+# gpg
1414+export GPG_TTY=$(tty)
···11+function fish_greeting
22+ if not set -q fish_greeting
33+ set -l line1 (printf (_ 'Welcome to %sanhgelus-void%s.') (set_color "#95d5b2" green) (set_color normal))
44+ set -l line2 \n(printf (_ 'Workstation powered by the %svoid%s.') (set_color green) (set_color normal))
55+ set -g fish_greeting "$line1$line2"
66+ end
77+88+ if set -q fish_private_mode
99+ set -l line (_ "fish is running in private mode, history will not be persisted.")
1010+ if set -q fish_greeting[1]
1111+ set -g fish_greeting $fish_greeting\n$line
1212+ else
1313+ set -g fish_greeting $line
1414+ end
1515+ end
1616+1717+ # The greeting used to be skipped when fish_greeting was empty (not just undefined)
1818+ # Keep it that way to not print superfluous newlines on old configuration
1919+ test -n "$fish_greeting"
2020+ and echo $fish_greeting
2121+end
+34
config/fish/functions/fish_prompt.fish
···11+# name: Default
22+# author: Lily Ballard
33+44+function fish_prompt --description 'Write out the prompt'
55+ set -l last_pipestatus $pipestatus
66+ set -lx __fish_last_status $status # Export for __fish_print_pipestatus.
77+ set -l normal (set_color normal)
88+ set -q fish_color_status
99+ or set -g fish_color_status red
1010+1111+ # Color the prompt differently when we're root
1212+ set -l color_cwd "#ffd6ff"
1313+ set -l suffix '>'
1414+ if functions -q fish_is_root_user; and fish_is_root_user
1515+ if set -q fish_color_cwd_root
1616+ set color_cwd $fish_color_cwd_root
1717+ end
1818+ set suffix '#'
1919+ end
2020+2121+ # Write pipestatus
2222+ # If the status was carried over (if no command is issued or if `set` leaves the status untouched), don't bold it.
2323+ set -l bold_flag --bold
2424+ set -q __fish_prompt_status_generation; or set -g __fish_prompt_status_generation $status_generation
2525+ if test $__fish_prompt_status_generation = $status_generation
2626+ set bold_flag
2727+ end
2828+ set __fish_prompt_status_generation $status_generation
2929+ set -l status_color (set_color $fish_color_status)
3030+ set -l statusb_color (set_color $bold_flag $fish_color_status)
3131+ set -l prompt_status (__fish_print_pipestatus "[" "]" "|" "$status_color" "$statusb_color" $last_pipestatus)
3232+3333+ echo -n -s (prompt_login)' ' (set_color $color_cwd) (prompt_pwd) $normal (fish_vcs_prompt) $normal " "$prompt_status $suffix " "
3434+end
+28
config/fish/functions/prompt_login.fish
···11+function prompt_login --description "display user name for the prompt"
22+ if not set -q __fish_machine
33+ set -g __fish_machine
44+ set -l debian_chroot $debian_chroot
55+66+ if test -r /etc/debian_chroot
77+ set debian_chroot (cat /etc/debian_chroot)
88+ end
99+1010+ if set -q debian_chroot[1]
1111+ and test -n "$debian_chroot"
1212+ set -g __fish_machine "(chroot:$debian_chroot)"
1313+ end
1414+ end
1515+1616+ # Prepend the chroot environment if present
1717+ if set -q __fish_machine[1]
1818+ echo -n -s (set_color yellow) "$__fish_machine" (set_color normal) ' '
1919+ end
2020+2121+ # If we're running via SSH, change the host color.
2222+ set -l color_host "#95d5b2"
2323+ if set -q SSH_TTY; and set -q fish_color_host_remote
2424+ set color_host $fish_color_host_remote
2525+ end
2626+2727+ echo -n -s (set_color "#ffd6ff" green) "$USER" (set_color normal) @ (set_color $color_host) (prompt_hostname) (set_color normal)
2828+end