Nix-Configs/configs/programs/fish.nix

135 lines
3.9 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'";
lonk = "qrencode -t utf8i";
s = "kitty +kitten ssh";
weather = "curl wttr.in/43.0844,-77.6749";
};
2022-12-30 16:29:41 +00:00
shellAbbrs = {
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" = "restic -r rclone:rit:'Restic Backups/'(hostname | sed \"s/\\(.\\)/\\u\\1/\") -p (pass backups | psub) backup ~/ --exclude-caches --exclude-file=${import ./restic.nix}";
2023-02-19 22:34:40 +00:00
"dl" = "wget (kitty +kitten clipboard --get-clipboard)";
2022-12-30 16:29:41 +00:00
};
2022-12-18 15:15:15 +00:00
shellInit = ''
set -x PATH ~/.cargo/bin/ ~/go/bin ~/.local/bin ~/.gem/ruby/*/bin /var/lib/flatpak/exports/bin/ $PATH
set -x KEYFILE ~/.config/void/keyfile
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 = {
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
}