Nix-Configs/configs/programs/fish.nix

150 lines
4.8 KiB
Nix

pkgs: {
enable = true;
plugins = [
{
name = "bang-bang";
src = pkgs.fetchFromGitHub {
owner = "oh-my-fish";
repo = "plugin-bang-bang";
rev = "816c66d";
hash = "sha256-35xXBWCciXl4jJrFUUN5NhnHdzk6+gAxetPxXCv4pDc=";
};
}
];
shellAliases = {
clip = "kitty +kitten clipboard";
l = "ls -lah --hyperlink=auto";
icat = "kitty +kitten icat";
rust-musl-builder = "fish -c 'docker run --rm -it -v (pwd):/home/rust/src ekidd/rust-musl-builder cargo build --release'";
lonk = "qrencode -t utf8i (kitten clipboard -g)";
s = "kitty +kitten ssh";
weather = "curl wttr.in/43.0844,-77.6749";
};
shellAbbrs = rec {
tab = "clone-in-kitty --type=tab";
win = "clone-in-kitty --type=os-window";
ns = "nix-shell --run fish -p";
unlock-rclone = "set -x RCLONE_CONFIG_PASS (pass rclone)";
":qa" = "exit";
":q" = "exit";
"rmount" = "rclone --rc --rc-web-gui --rc-no-auth --cache-dir /tmp/rclone-cache mount --vfs-cache-mode full --vfs-cache-max-size 8Gi";
"backup" = "eval (pass backblaze/backup-bucket) && restic -r s3:s3.us-west-000.backblazeb2.com/ember-restic-backups/(hostname | sed \"s/\\(.\\)/\\u\\1/\") -p (pass backups | psub) backup ~/ --exclude-caches --exclude-file=${import ./restic.nix}";
"diary" = "bwrap --bind ~/Diary/gate/ / --bind ~/Diary/store /store --ro-bind /nix /nix --bind /run /run -- (whereis -b restic | cut -c 9-) -r /store -p (pass diary | psub) backup -H 'diary' -e /nix -e /run -e /store -e /home /";
"dl" = "wget (kitty +kitten clipboard --get-clipboard)";
yt = "yt-dlp -o '%(release_date>%Y-%m-%d,upload_date>%Y-%m-%d|???)s.%(title)s.%(ext)s' -f bestvideo+bestaudio --embed-subs --embed-thumbnail --embed-metadata --embed-chapters --embed-info-json (kitten clipboard -g)";
};
shellInit = ''
set fish_color_command magenta
set fish_color_normal white
set fish_color_param ffffff
set fish_color_quote blue
set fish_color_redirection green
set fish_color_end b4a8c8
set fish_color_comment black
set fish_color_operator green
set fish_color_escape yellow
set fish_color_autosuggestion 91889b
set fish_greeting ""
# echo "You're cute and loved <3"
# echo "You seriously are incredibly wonderful and you mean so much to me, you've made my life so much brighter and i never wanna let you go <3"
'';
functions = {
editm4b = {
description = "Edit the chapters in an m4b file";
body = "tone tag --meta-chapters-file=(tone dump --format ChptFmtNative \$argv[1] | vipe | psub) \$argv[1]";
argumentNames = ["Audiobook"];
};
uwu = {
description = "notices your fish function";
body = ''
set UWU_DIR (mktemp -d /tmp/uwu.XXX)
encfs -i 60 ~/Pictures/uwu/ $UWU_DIR --extpass 'pass storage-encryption/annex-fs'
cd $UWU_DIR
fish --private
'';
};
n = {
description = "support nnn quit and change directory";
wraps = "nnn";
body = ''
# Block nesting of nnn in subshells
if test -n "$NNNLVL"
if [ (expr $NNNLVL + 0) -ge 1 ]
echo "nnn is already running"
return
end
end
set -x NNN_TMPFILE '.nnn.tmp'
nnn $argv
if test -e $NNN_TMPFILE
source $NNN_TMPFILE
rm $NNN_TMPFILE
end
'';
};
fish_prompt = ''
# Theme based on Bira theme from oh-my-zsh: https://github.com/robbyrussell/oh-my-zsh/blob/master/themes/bira.zsh-theme
# Some code stolen from oh-my-fish clearance theme: https://github.com/bpinto/oh-my-fish/blob/master/themes/clearance/
# Further modification by Ember, to make the colors cooler
function __user_host
set -l content
echo -n (set_color --bold cyan)
echo -n $USER@(hostname|cut -d . -f 1) (set color normal)
end
function __current_path
echo -n (set_color --bold red) (pwd) (set_color normal)
end
function __venv
function __prompt_name
cat $VIRTUAL_ENV/pyvenv.cfg | head -n4 | tail -n 1 | cut -b 11- | head -c -2
end
if [ $VIRTUAL_ENV ]
echo -n (set_color white) '['(__prompt_name)']' (set_color normal)
end
end
function _git_branch_name
echo (command git symbolic-ref HEAD 2> /dev/null | sed -e 's|^refs/heads/||')
end
function _git_is_dirty
echo (command git status -s --ignore-submodules=dirty 2> /dev/null)
end
function __git_status
if [ (_git_branch_name) ]
set -l git_branch (_git_branch_name)
if [ (_git_is_dirty) ]
set git_info '['$git_branch"*"']'
else
set git_info '['$git_branch']'
end
echo -n (set_color white) $git_info (set_color normal)
end
end
function fish_right_prompt
set -l st $status
if [ $st != 0 ];
echo (set_color red) $st(set_color normal)
end
end
echo -n (set_color white)""(set_color normal)
__user_host
__current_path
__venv
__git_status
echo -e '''
echo (set_color white)""(set_color --bold white)"\$ "(set_color normal)
'';
};
}