Nix-Configs/configs/programs/fish.nix

153 lines
4.8 KiB
Nix
Raw Normal View History

2022-12-18 15:15:15 +00:00
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'";
2024-02-23 21:44:13 +00:00
lonk = "qrencode -t utf8i (kitten clipboard -g)";
2022-12-18 15:15:15 +00:00
s = "kitty +kitten ssh";
weather = "curl wttr.in/43.0844,-77.6749";
};
2023-04-08 16:13:34 +00:00
shellAbbrs = rec {
2023-12-18 16:08:25 +00:00
tab = "clone-in-kitty --type=tab";
win = "clone-in-kitty --type=os-window";
2023-01-25 15:59:52 +00:00
ns = "nix-shell --run fish -p";
2022-12-30 16:29:41 +00:00
unlock-rclone = "set -x RCLONE_CONFIG_PASS (pass rclone)";
2023-01-11 19:10:32 +00:00
":qa" = "exit";
":q" = "exit";
2023-02-09 19:22:41 +00:00
"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}";
2023-04-08 16:13:34 +00:00
"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 /";
2023-02-19 22:34:40 +00:00
"dl" = "wget (kitty +kitten clipboard --get-clipboard)";
2024-02-23 21:45:30 +00:00
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)";
2022-12-30 16:29:41 +00:00
};
2022-12-18 15:15:15 +00:00
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 = {
2024-04-05 22:05:43 +00:00
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
2024-04-11 21:58:08 +00:00
cd -
umount $UWU_DIR
rm -d $UWU_DIR
2024-04-05 22:05:43 +00:00
'';
};
2022-12-18 15:15:15 +00:00
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
2023-03-09 13:30:21 +00:00
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
2022-12-18 15:15:15 +00:00
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
2023-03-09 13:30:21 +00:00
__venv
2022-12-18 15:15:15 +00:00
__git_status
echo -e '''
echo (set_color white)""(set_color --bold white)"\$ "(set_color normal)
'';
};
2023-01-11 19:10:46 +00:00
}