···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
+17
.config/fish/config.fish
···11+if status is-interactive
22+ # Commands to run in interactive sessions can go here
33+ set -g fish_greeting
44+ set -gx SSH_AUTH_SOCK $(gpgconf --list-dirs agent-ssh-socket)
55+ set -gx EDITOR /usr/bin/helix
66+end
77+88+set --export PATH /usr/local/bin /usr/bin
99+# bun
1010+set --export BUN_INSTALL "$HOME/.bun"
1111+set --export PATH $BUN_INSTALL/bin $PATH
1212+# flyctl
1313+set --export FLYCTL_INSTALL "$HOME/.fly"
1414+set --export PATH $FLYCTL_INSTALL/bin $PATH
1515+# cargo
1616+set --export CARGO_INSTALL "$HOME/.cargo"
1717+set --export PATH $CARGO_INSTALL/bin $PATH
···11+function __fish_list_current_token --description 'List contents of token under the cursor if it is a directory, otherwise list the contents of the current directory'
22+ set -l val "$(commandline -t | string replace -r '^~' "$HOME")"
33+ set -l cmd
44+ if test -d $val
55+ set cmd ls -lGh $val
66+ else
77+ set -l dir (dirname -- $val)
88+ if test $dir != . -a -d $dir
99+ set cmd ls -lGh $dir
1010+ else
1111+ set cmd ls -lGh
1212+ end
1313+ end
1414+ __fish_echo $cmd
1515+end
+31
.config/fish/functions/fish_prompt.fish
···11+function fish_prompt --description 'Write out the prompt'
22+ set -l last_pipestatus $pipestatus
33+ set -lx __fish_last_status $status # Export for __fish_print_pipestatus.
44+ set -l normal (set_color normal)
55+ set -q fish_color_status
66+ or set -g fish_color_status red
77+88+ # Color the prompt differently when we're root
99+ set -l color_cwd $fish_color_cwd
1010+ set -l suffix '>'
1111+ if functions -q fish_is_root_user; and fish_is_root_user
1212+ if set -q fish_color_cwd_root
1313+ set color_cwd $fish_color_cwd_root
1414+ end
1515+ set suffix '#'
1616+ end
1717+1818+ # Write pipestatus
1919+ # If the status was carried over (if no command is issued or if `set` leaves the status untouched), don't bold it.
2020+ set -l bold_flag --bold
2121+ set -q __fish_prompt_status_generation; or set -g __fish_prompt_status_generation $status_generation
2222+ if test $__fish_prompt_status_generation = $status_generation
2323+ set bold_flag
2424+ end
2525+ set __fish_prompt_status_generation $status_generation
2626+ set -l status_color (set_color $fish_color_status)
2727+ set -l statusb_color (set_color $bold_flag $fish_color_status)
2828+ set -l prompt_status (__fish_print_pipestatus "[" "]" "|" "$status_color" "$statusb_color" $last_pipestatus)
2929+3030+ echo -n -s (prompt_login)' ' (set_color $color_cwd) (prompt_pwd) $normal (fish_vcs_prompt) $normal " "$prompt_status $suffix " "
3131+end
···11+function win10
22+ switch (incus list -f csv,noheader -c s win10)
33+ case RUNNING
44+ echo "win10 already running"
55+ case STOPPED
66+ incus start win10
77+ end
88+ $HOME/.scripts/looking-glass
99+end
+35
.scripts/looking-glass
···11+#!/usr/bin/env bash
22+33+VM=${1:-win10}
44+GROUP=wheel
55+66+# Relevant paths
77+INCUS=/var/run/incus
88+VMDIR=${INCUS}/${VM}
99+SPICE=${INCUS}/${VM}/qemu.spice
1010+1111+# First check if we have access to the shared memory device.
1212+#
1313+# Use udev rules to set permissions.
1414+# IVSHMEM=/dev/shm/looking-glass
1515+IVSHMEM=/dev/kvmfr0
1616+if ! [[ -r ${IVSHMEM} && -w ${IVSHMEM} ]]; then
1717+ ls -l ${IVSHMEM}
1818+ echo "need rw access to shared memory device ${IVSHMEM}"
1919+ exit 1
2020+fi
2121+2222+# Iff necessary, grant read-execute on the incus run directory to
2323+# the group in ${GROUP}.
2424+if ! [[ -x ${INCUS} && -r ${INCUS} ]]; then
2525+ sudo chown :${GROUP} ${INCUS} && sudo chmod g=rx ${INCUS}
2626+fi
2727+2828+# Iff necessary, grant read-execute on the vm directory, and
2929+# read-write on the spice socket, to the group in ${GROUP}.
3030+if ! [[ -x ${VMDIR} && -r ${VMDIR} && -r ${SPICE} && -w ${SPICE} ]]; then
3131+ sudo chown :${GROUP} ${VMDIR} && sudo chmod g=rx ${VMDIR}
3232+ sudo chown :${GROUP} ${SPICE} && sudo chmod g=rw ${SPICE}
3333+fi
3434+3535+looking-glass-client -f ${IVSHMEM} -c ${SPICE} -p 0 win:size=2880x1620