refactor: simplify fish prompt and configs

This commit is contained in:
mitchell 2026-04-13 14:33:48 -04:00
parent fddae3ba36
commit 7da5ead1ed
32 changed files with 139 additions and 1156 deletions

View file

@ -1,4 +0,0 @@
function aisearch --wraps aichat
set -lx AICHAT_PATCH_GEMINI_CHAT_COMPLETIONS '{".*":{"body":{"tools":[{"google_search":{}}]}}}'
aichat -r search -s $argv
end

View file

@ -1,6 +0,0 @@
function back -d 'A shortcut for backgrounding a command using nohup and named log file'
set log_name (string join _ $argv)
echo "log file: $log_name.out"
nohup $argv >"$log_name.out" &
end

View file

@ -1,34 +0,0 @@
function btre -a device -d 'Reconnect to a known bluetooth device'
set -l devices CC:98:8B:3E:6B:9D 00:1B:66:E3:07:3A
set -l index 1
switch device
case sony
set index 1
return
case senn
set index 2
return
case '*'
test -n "$device"; and set index $device
end
bluetoothctl power on
and bluetoothctl remove $devices[$index]
echo \n"--- Press enter to continue ---"\n
bluetoothctl scan on &
read -P ''
bluetoothctl pair $devices[$index]
or return $status
read -p 'echo \n"--- Press enter to continue ---"\n'
bluetoothctl trust $devices[$index]
and bluetoothctl connect $devices[$index]
or return $status
read -p 'echo \n"--- Press enter to continue ---"\n'
kill %1
end

View file

@ -1,60 +0,0 @@
function define_aliases -a uname -d 'Defines aliases for commonly used commands'
alias q exit
alias cl clear
alias ls lsd
alias rcp 'rsync -aP'
alias vg vagrant
alias tf terraform
alias gco 'gcloud compute'
alias tocb 'xclip -in -selection clipboard'
alias fromcb 'xclip -out -selection clipboard'
alias ssh-rm 'ssh-keygen -f ~/.ssh/known_hosts -R'
alias age-p 'age --armor --passphrase'
alias age-d 'age --decrypt --identity ~/.secrets/id_ed25519'
alias age-e 'age --armor --recipient (cat ~/.secrets/id_ed25519.pub)'
alias age-k 'age --decrypt --identity ~/.secrets/id_ed25519 ~/.secrets/age_keys.age'
alias kp 'keepassxc-cli show -k ~/.secrets/mjfs_keepass_key_file ~/.passwords/mjfs.kdbx'
alias bb 'bun --bun'
alias pn pnpm
alias nv 'neovide --fork; and clear'
alias hx helix
alias fwl 'sudo firewall-cmd'
alias o 'opencode run --thinking'
switch "$uname"
case Linux
alias goland 'command goland'
alias rider 'command rider'
alias webstorm 'command webstorm'
alias sctl 'sudo systemctl'
alias uctl 'systemctl --user'
alias bctl bluetoothctl
case Darwin
alias goland 'open -a Goland'
alias rider 'open -a Rider'
alias webstorm 'open -a Webstorm'
alias pkm 'brew search'
alias pkmi 'brew install'
alias pkmf 'brew update'
alias pkmu 'brew upgrade'
alias pkmr 'brew uninstall'
end
# Linux distro specific aliases below
#set -l distro
#for line in (cat /etc/os-release)
# set -l items (string split --max 1 '=' $line)
# if test $items[1] = 'ID'
# set distro $items[2]
# end
#end
#switch "$distro"
# case 'arch'
# case 'debian'
#end
end

View file

@ -1,41 +0,0 @@
function define_global_variables -d 'Defines all and exclusively globally exported variables'
set -gx AWS_SDK_LOAD_CONFIG true
set -gx DOTNET_ENVIRONMENT Development
set -gx DOTNET_CLI_TELEMETRY_OPTOUT true
set -gx EDITOR nvim
set -gx BROWSER firefox
set -gx DIFFPROG delta
set -gx FZF_CTRL_T_COMMAND 'fd --type f --type d --hidden --exclude ".git/"'
set -gx FZF_DEFAULT_COMMAND 'fd --type f --type d --hidden --exclude ".git/"'
set -gx FZF_ALT_C_COMMAND 'fd --type d --hidden --exclude ".git/"'
set -gx GOPATH $HOME/code/go
set -gx GOBIN $GOPATH/bin
set -gx BUN_INSTALL $HOME/.bun
set -gx LIBVIRT_DEFAULT_URI 'qemu:///system'
if test (uname) = "Darwin"
set -gx ANDROID_HOME $HOME/Library/Android/Sdk
else
set -gx ANDROID_HOME $HOME/Android/Sdk
end
set -gx PYENV_ROOT $HOME/.pyenv
fish_add_path $GOBIN \
$HOME/.local/bin \
$HOME/.pub-cache/bin \
$HOME/code/scripts \
$HOME/code/flutter/bin \
$HOME/.cargo/bin \
$HOME/.dotnet/tools \
$BUN_INSTALL/bin \
$PYENV_ROOT/bin \
$ANDROID_HOME/emulator \
$ANDROID_HOME/platform-tools
end

View file

@ -1,3 +0,0 @@
function dm-env -d 'Shortcut for setting your shell env for a docker-machine'
eval (docker-machine env $argv)
end

View file

@ -1,9 +0,0 @@
function do -d 'Repeat the command for each given argument'
set command (string split ' ' $argv[1])
and set args $argv[2..]
or return 1
for arg in $args
$command $arg
end
end

View file

@ -1,6 +1,5 @@
function fish_prompt --description 'Write out the prompt'
set -l last_status $status
set -l color_cwd
set -l suffix
set -l user_prefix
set -l git_branch
@ -19,83 +18,34 @@ function fish_prompt --description 'Write out the prompt'
end
# Set cwd color and prompt suffix, based on current user and fish_bind_mode.
switch "$USER"
case root toor
if set -q fish_color_cwd_root
set color_cwd $fish_color_cwd_root
else
set color_cwd $fish_color_cwd
end
set suffix '#'
if test $fish_key_bindings = 'fish_vi_key_bindings'
switch "$fish_bind_mode"
case 'insert'
set suffix (set_color brblue) $suffix (set_color normal)
case 'visual'
set suffix (set_color bryellow) $suffix (set_color normal)
end
end
case '*'
set color_cwd $fish_color_cwd
set suffix '>'
if test $fish_key_bindings = 'fish_vi_key_bindings'
switch "$fish_bind_mode"
case 'insert'
set suffix (set_color brblue) $suffix (set_color normal)
case 'default'
set suffix '^'
case 'visual'
set suffix (set_color bryellow) 'v' (set_color normal)
end
end
set suffix '>'
if test $fish_key_bindings = fish_vi_key_bindings
switch "$fish_bind_mode"
case insert
set suffix (set_color brblue) $suffix (set_color normal)
case default
set suffix '<'
case visual
set suffix (set_color bryellow) v (set_color normal)
end
end
# Set user_prefix, based on whether or not inside of ssh session.
if test -n "$SSH_CLIENT"
set user_prefix $USER @ (prompt_hostname) ' '
end
# Show current git branch, based on git commands only.
if git status >/dev/null 2>&1
set -l branch_color green
set -l git_status (git status)
if string match 'Changes not staged for commit:' $git_status >/dev/null
or string match 'Untracked files:' $git_status >/dev/null
set branch_color red
else if string match 'Changes to be committed:' $git_status >/dev/null
set branch_color yellow
# Show current git branch.
if set -l cur_branch (git branch --show-current 2>/dev/null)
if test -z "$cur_branch"
set cur_branch detached
end
set -l cur_branch (string sub -s 3 (string match -r '^\* .*$' (git branch)))
if string match -q '(HEAD detached*' $cur_branch
set cur_branch 'detached'
end
if test -n "$cur_branch"
set -l cur_branch_len (string length $cur_branch)
if test $cur_branch_len -gt 21
set -l sub_str (string sub -l 18 $cur_branch)
set cur_branch "$sub_str..."
end
end
if string match 'Your branch is ahead of*' $git_status >/dev/null
set cur_branch $cur_branch \u21A5
else if string match 'Your branch is behind*' $git_status >/dev/null
set cur_branch $cur_branch \u21A7
end
set git_branch ' on ' (set_color $branch_color) $cur_branch (set_color normal)
set git_branch ' on ' (set_color $fish_color_cwd) $cur_branch (set_color normal)
end
# Combine all prompt variables
set -l cwd (set_color $color_cwd) (prompt_pwd) (set_color normal)
set -l cwd (set_color $fish_color_cwd) (prompt_pwd) (set_color normal)
set -l top_prompt $cwd $git_branch
set -l bottom_prompt $user_prefix $jobs_num $exit_code $suffix ' '

View file

@ -1,18 +1,12 @@
# Some functions borrowed from bobthefish theme (https://github.com/oh-my-fish/theme-bobthefish).
# Copyright (c) 2013-2014 Justin Hileman.
#
# You can override some default right prompt options in your config.fish:
# set -g theme_date_format "+%a %H:%M"
function __bobthefish_cmd_duration -S -d 'Show command duration'
[ "$theme_display_cmd_duration" = "no" ]
and return
[ -z "$CMD_DURATION" -o "$CMD_DURATION" -lt 100 ]
and return
if [ "$CMD_DURATION" -lt 5000 ]
echo -ns $CMD_DURATION 'ms'
echo -ns $CMD_DURATION ms
else if [ "$CMD_DURATION" -lt 60000 ]
__bobthefish_pretty_ms $CMD_DURATION s
else if [ "$CMD_DURATION" -lt 3600000 ]
@ -26,8 +20,7 @@ function __bobthefish_cmd_duration -S -d 'Show command duration'
set_color $fish_color_normal
set_color $fish_color_autosuggestion
[ "$theme_display_date" = "no" ]
or echo -ns ' ' $__bobthefish_left_arrow_glyph
echo -ns ' ' $__bobthefish_left_arrow_glyph
end
function __bobthefish_pretty_ms -S -a ms -a interval -d 'Millisecond formatting for humans'
@ -44,28 +37,13 @@ function __bobthefish_pretty_ms -S -a ms -a interval -d 'Millisecond formatting
set scale 2
end
switch $FISH_VERSION
case 2.0.\* 2.1.\* 2.2.\* 2.3.\*
# Fish 2.3 and lower doesn't know about the -s argument to math.
math "scale=$scale;$ms/$interval_ms" | string replace -r '\\.?0*$' $interval
case 2.\*
# Fish 2.x always returned a float when given the -s argument.
math -s$scale "$ms/$interval_ms" | string replace -r '\\.?0*$' $interval
case \*
math -s$scale "$ms/$interval_ms"
echo -ns $interval
end
math -s$scale "$ms/$interval_ms"
echo -ns $interval
end
function __bobthefish_timestamp -S -d 'Show the current timestamp'
[ "$theme_display_date" = "no" ]
and return
set -q theme_date_format
or set -l theme_date_format "+%c"
echo -n ' '
date $theme_date_format
date "+%c"
end
function fish_right_prompt -d 'bobthefish is all about the right prompt'

View file

@ -1,11 +0,0 @@
function fish_user_key_bindings
bind --mode insert comma,a 'ssh_add; commandline -f repaint'
bind --mode insert .,comma 'nvim; commandline -f repaint'
bind --mode insert comma,s 'sysz; commandline -f repaint'
bind --mode insert comma,z 'zi; commandline -f repaint'
bind --mode insert comma,t 'fzf-file-widget'
bind --mode insert comma,r 'fzf-history-widget'
bind --mode insert comma,c 'fzf-cd-widget'
bind --mode insert comma,l 'clear; commandline -f repaint'
bind --mode insert comma,o 'opencode; commandline -f repaint'
end

View file

@ -1,24 +0,0 @@
function import_sources -a uname -d 'Loads any additional fish files needed at init.'
test -f ~/.asdf/plugins/dotnet-core/set-dotnet-home.fish; and source ~/.asdf/plugins/dotnet-core/set-dotnet-home.fish
# ASDF configuration code
if test -z $ASDF_DATA_DIR
set _asdf_shims "$HOME/.asdf/shims"
else
set _asdf_shims "$ASDF_DATA_DIR/shims"
end
fish_add_path $_asdf_shims
set --erase _asdf_shims
test -e /opt/homebrew/bin/brew
and /opt/homebrew/bin/brew shellenv | source -
command -q starship; and starship init fish | source
command -q zoxide; and zoxide init fish | source
command -q fzf; and fzf --fish | source
command -q pyenv; and pyenv init - | source
# The next line updates PATH for the Google Cloud SDK.
# if test -f '/Users/m/Documents/google-cloud-sdk/path.fish.inc'; source '/Users/m/Documents/google-cloud-sdk/path.fish.inc'; end
end

View file

@ -1,23 +0,0 @@
function pastoggle -d 'Toggle the pulseaudio server between pc.lan and laptop.lan'
set -l host 'pc.lan'
set -l remote 'laptop.lan'
set -l config $HOME/.config/pulse/client.conf
if test (hostname) = 'm-laptop'
set host 'laptop.lan'
set remote 'pc.lan'
end
ssh $remote true
or return $status
if test -f "$config"
rm $config
and systemctl --user restart pulseaudio.service
and ssh $remote "echo \"default-server = $host\" >$config; and systemctl --user restart pulseaudio.service"
else
ssh $remote "rm $config; and systemctl --user restart pulseaudio.service"
and echo "default-server = $remote" >$config
and systemctl --user restart pulseaudio.service
end
end

View file

@ -1,78 +0,0 @@
function pkm -a command -d 'Shortcuts for pacman and apt'
set -l distro
for line in (cat /etc/os-release)
set -l items (string split --max 1 '=' $line)
if test $items[1] = ID
set distro $items[2]
break
end
end
set -l pkm
switch $distro
case arch
if command -q pikaur
_pacman_commander pikaur $argv
else
_pacman_commander 'sudo pacman' $argv
end
case debian
_apt_commander 'sudo apt' $argv
end
end
function _pacman_commander -a pkm command
set -l args $argv[3..]
set pkm (string split ' ' $pkm)
switch $command
case i install
$pkm --sync $args
case f fetch
argparse r/reflector -- $args
sudo true
if set -q _flag_reflector
reflector --latest 50 --fastest 3 --sort age --protocol https --thread 4 |
sudo tee /etc/pacman.d/mirrorlist
end
and $pkm --sync --refresh
case u update
$pkm --sync --sysupgrade $args
and sudo env DIFFPROG='nvim -d' checkservices
case r remove
$pkm --remove --recursive --unneeded $args
case s search
$pkm $args
case '*'
$pkm $command $args
end
end
function _apt_commander -a pkm command
set -l args $argv[3..]
set pkm (string split ' ' $pkm)
switch $command
case i install
$pkm install $args
case f fetch
$pkm update
case u update
$pkm upgrade $args
and $pkm autoremove
and $pkm autoclean
case r remove
$pkm purge $args
and $pkm autoremove
case s search
$pkm search $args
case '*'
$pkm $command $args
end
end

View file

@ -1,25 +0,0 @@
function push -a message -d 'Send a push notification to your phone via pushover (optional delay as second arg)'
argparse 'u/url=' 'p/priority=' -- $argv
set -l host (cat /etc/hostname)
if test -z "$_flag_p"
set _flag_p '0'
end
set payload \
"{
\"token\": \"$pushover_token\",
\"user\": \"$pushover_user\",
\"title\": \"Push from $host\",
\"url\": \"$_flag_u\",
\"priority\": $_flag_p,
\"message\": \"$message\"
}"
curl \
-X POST \
-H 'Content-Type: application/json' \
-d "$payload" \
https://api.pushover.net/1/messages.json
end

View file

@ -1,8 +0,0 @@
function push_tasks -d 'Push tasks as a notification to your phone'
set tasks (task +READY export |
jq 'sort_by(.urgency) |
reverse |
map(@text "\(.description)\nLink: \(.link)\nWiki: http://wiki.m/\(.wiki)\nDue: \(.due)") |
join("\n\n")')
send_push $tasks
end

View file

@ -1,5 +0,0 @@
function rebar
pkill -fi polybar; and pkill -fi -9 polybar
bspc config top_padding -10
nohup polybar m-bar &> /dev/null & disown
end

View file

@ -1,20 +0,0 @@
function redisco
set -l to_kill discord
if test -n "$argv"
set to_kill $argv
end
pgrep -fia $to_kill
or return
read -P 'continue? [Y/n]> ' -l confirm
if test "$confirm" = 'n'
return
end
pkill -fi $to_kill
nohup $to_kill &> /dev/null & disown
end

View file

@ -1,7 +0,0 @@
function refresh
while true
sleep 1
clear
$argv
end
end

View file

@ -1,5 +0,0 @@
function repeat -a count -d 'Repeat the given action the given number of times'
for i in (seq $count)
$argv[2..-1]
end
end

View file

@ -1,7 +0,0 @@
function start_x_at_login
if status is-login
if test -z "$DISPLAY" -a "$XDG_VTNR" = 1
startx -- -keeptty
end
end
end

View file

@ -1,14 +0,0 @@
function toglpulse
killall slack Discord DiscordCanary
if test -e ~/.config/pulse/client.conf
rm -rf ~/.config/pulse/client.conf
systemctl --user start pipewire.socket
rebar
else
killall easyeffects pavucontrol; or killall -9 easyeffects pavucontrol
echo "default-server = 192.168.1.155" >~/.config/pulse/client.conf
systemctl --user stop pipewire.socket pipewire pipewire-pulse wireplumber
rebar
end
end

View file

@ -1,4 +0,0 @@
function vban -d 'Default VBAN startup script'
tmux new -s vban vban_emitter --ipaddress=192.168.1.155 --port=6980 --streamname=Main --backend=pulseaudio --device=alsa_output.pci-0000_05_00.6.analog-stereo.monitor
or tmux attach-session -t vban
end