os/programs/fish.nix
2024-10-29 08:12:05 +01:00

74 lines
1.9 KiB
Nix

{ config , pkgs , ... } : {
programs.fish = {
enable = true ;
functions = {
fish_prompt = ''
# get status to set colour later
set -f s $status
# nix shell component
set pkgs (echo $PATH | tr ' ' "\n" | grep '^/nix/store' \
| sed 's#^[^-]*-##;s#-[^-]*$##' | xargs)
if test -n "$pkgs"
set_color yellow
echo -n "nix: $pkgs "
end
# ssh component
if test -n "$SSH_CLIENT$SSH_TTY$SSH_CONNECTION"
set_color blue
echo -n (whoami)@(hostname)' '
end
# pwd
test $s -eq 0 && set_color magenta || set_color red
echo -n (prompt_pwd)
# git component
set_color green
set branch (git branch 2> /dev/null | grep '^*' \
| cut -d'*' -f 2)
set_color green
echo -n $branch
# prompt component
set_color brwhite
echo -n ' $ '
set_color normal
'' ;
fish_greeting = ''
source /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.fish
'' ;
mkcd = "mkdir -p $argv && cd $argv" ;
xv = "touch $argv && chmod +x $argv && hx $argv" ;
clwy = ''
curl -s -X POST -H "Content-Type: text/plain" -d "$argv" \
'https://jerl.zone/contact' > /dev/null
'' ;
} ;
shellAbbrs = {
gs = "git status" ;
gc = "git commit" ;
gca = "git commit --amend" ;
ga = "git add" ;
gaa = "git add -A" ;
gse = "git send-email HEAD^ --to=\"\"" ;
gd = "git diff" ;
gP = "git push" ;
gp = "git pull" ;
gl = "git log '@{push}..'" ;
gla = "git log" ;
} ;
shellAliases = {
l = "ls -CB" ;
la = "ls -CAB" ;
ll = "ls -CBlh" ;
lla = "ls -CABlh" ;
cl = "clear" ;
"c." = "cd .." ;
":q" = "exit" ;
v = "hx" ;
sv = "sudo hx" ;
} ;
} ;
}