nix/home-manager/common/software/cli/fish.nix

196 lines
6.3 KiB
Nix
Raw Normal View History

2024-04-29 02:56:26 +02:00
{ ... }: {
programs.kitty.shellIntegration.enableFishIntegration = true;
2024-04-29 05:18:41 +02:00
programs.starship.enableFishIntegration = true;
2024-04-29 02:56:26 +02:00
programs.fish = {
enable = true;
2024-04-30 12:43:03 +02:00
shellInit = ''
set fish_greeting
2024-04-29 05:18:41 +02:00
set EDITOR vim
2024-05-03 06:41:43 +02:00
eval (ssh-agent -c) > /dev/null &> /dev/null
2024-05-03 01:28:38 +02:00
ssh-add > /dev/null &> /dev/null
2024-05-02 00:19:24 +02:00
'';
2024-05-03 01:28:38 +02:00
2024-05-06 05:01:37 +02:00
loginShellInit = ''ssh-add > /dev/null &> /dev/null'';
2024-05-02 00:19:24 +02:00
interactiveShellInit = ''
2024-04-30 11:20:55 +02:00
if not set -q TMUX && not set -q DISABLE_TMUX
2024-04-30 13:33:17 +02:00
if tmux has-session -t Main
exec tmux attach-session -t Main
2024-04-30 11:23:45 +02:00
exit
2024-04-30 11:20:55 +02:00
else
2024-04-30 13:33:17 +02:00
exec tmux new-session -t Main
2024-04-30 11:20:55 +02:00
end
2024-04-29 07:33:58 +02:00
end
2024-04-30 06:09:54 +02:00
'';
2024-04-29 09:57:37 +02:00
2024-04-30 06:09:54 +02:00
functions = {
2024-04-30 05:20:54 +02:00
__fish_command_not_found_handler = {
body = "__fish_default_command_not_found_handler $argv[1]";
onEvent = "fish_command_not_found";
};
2024-05-06 05:01:37 +02:00
# GPG related functions
encrypt = ''
set output $argv-$(ddate).enc
gpg --encrypt --armor --output $output -r $PGP_KEY_ID "$argv" && echo "Encrypted: $argv -> $output"
'';
decrypt = ''
set output $(echo $argv | rev | cut -c16- | rev)
2024-05-06 06:14:24 +02:00
gpg --decrypt -r $PGP_KEY_ID --output $output $argv && echo "Decrypted: $argv -> $output"
2024-05-06 05:01:37 +02:00
'';
2024-04-29 02:56:26 +02:00
update_secrets = ''
pushd /etc/nixos/git
nix develop -c \
find secrets -name "*.yaml" -exec sops updatekeys {} \;
'';
restart-docker = ''
if [ (hostname) = "nuc-server" ]
pushd /Storage/Data/docker-compose/ifargle.com/
else
pushd /Storage/Data/docker-compose/sysctl.io/
end
2024-04-29 05:18:41 +02:00
docker stop $argv
docker rm $argv
2024-04-29 02:56:26 +02:00
git pull
2024-04-29 05:18:41 +02:00
docker compose up -d $argv
2024-04-29 02:56:26 +02:00
popd
2024-09-08 04:57:55 +02:00
'';
# Deploy-RS script
deploy-rs = ''
pushd /etc/nixos/git/
echo -en "Restarting DERP Relays.... "
echo -en "Osaka"
ssh -qA osaka-linode-01 "sudo systemctl restart podman-derp"
echo -en ", Frankfurt"
ssh -qA frankfurt-linode-01 "sudo systemctl restart podman-derp"
echo -en ", Milan"
ssh -qA milan-linode-01 "sudo systemctl restart podman-derp"
echo -e "... Done"
echo -en "Restarting rdesktop containers.... "
ssh -qA warsaw-ovh-01 "sudo systemctl restart container@rdesktop"
ssh -qA framework-server "sudo systemctl restart container@rdesktop"
echo -e "... Done"
deploy -s
popd
2024-04-29 02:56:26 +02:00
'';
# Build ISOs/SD Card Images
nixos-build-all-images = ''
echo "Building Linode image..."
2024-05-06 05:01:37 +02:00
nixos-build-linode-img $argv
2024-04-29 02:56:26 +02:00
echo "Building Raspberry Pi image..."
2024-05-06 05:01:37 +02:00
nixos-build-pi-img $argv
2024-04-29 02:56:26 +02:00
echo "Building ISO Console image..."
2024-05-06 05:01:37 +02:00
nixos-build-console $argv
2024-04-29 02:56:26 +02:00
echo "Building ISO Desktop image..."
2024-05-06 05:01:37 +02:00
nixos-build-desktop $argv
2024-04-29 02:56:26 +02:00
ls -lah ~/ | grep nixos
'';
nixos-build-pi-img = ''
pushd /etc/nixos/git
git pull
2024-05-08 04:12:36 +02:00
nix build .#imageConfigurations.nixos-rpi4-img $argv
2024-04-29 02:56:26 +02:00
cp result/sd-image/nixos-sd-image* ~/.
rm -f result
popd
'';
nixos-build-linode-img = ''
pushd /etc/nixos/git
git pull
2024-05-08 04:12:36 +02:00
nix build .#imageConfigurations.nixos-linode-img $argv
cp result/nixos.img.gz ~/nixos-linode-$(ddate)-$(git rev-parse HEAD | cut -b 32-).img.gz
2024-04-29 02:56:26 +02:00
rm -f result
popd
'';
nixos-build-console = ''
pushd /etc/nixos/git
git pull
2024-05-08 04:12:36 +02:00
nix build .#imageConfigurations.nixos-iso-console $argv
cp result/iso/nixos.iso ~/nixos-console-$(ddate)-$(git rev-parse HEAD | cut -b 32-).iso
2024-04-29 02:56:26 +02:00
rm -f result
popd
'';
nixos-build-desktop = ''
pushd /etc/nixos/git
git pull
2024-05-08 04:12:36 +02:00
nix build .#imageConfigurations.nixos-iso-desktop $argv
cp result/iso/nixos.iso ~/nixos-desktop-$(ddate)-$(git rev-parse HEAD | cut -b 32-).iso
2024-04-29 02:56:26 +02:00
rm -f result
popd
'';
# NixOS Related
nix-clean-all = ''
echo "Optimizing the nix store..."
sudo nix-store --optimize
echo "nix-store: Collecting Garbage..."
sudo nix-store --gc
echo "Collecting garbage..."
sudo nix-collect-garbage -d
'';
};
shellAliases = {
2024-12-03 23:48:00 +01:00
# Tsilcale helpers
ts-dns-disable ="sudo tailscale set --accept-dns=false";
ts-dns-enable ="sudo tailscale set --accept-dns=true";
2024-05-06 05:01:37 +02:00
# GPG Related
2024-06-29 06:31:11 +02:00
sign = "gpg -u $PGP_KEY_ID --armor --detach-sig";
2024-05-06 06:17:30 +02:00
verify = "gpg -u $PGP_KEY_ID --verify";
2024-05-06 05:01:37 +02:00
2024-04-29 02:56:26 +02:00
prime-select = "nvidia-offload";
screenshot = ''grim -g "$(slurp)" | wl-copy -t image/png'';
# Don't use X to open emacs
emacs = "emacs -nw";
# docker
d = "docker";
dc = "docker compose";
de = "docker exec -it";
dl = "docker logs -f ";
dps = ''docker ps --format "table [{{.ID}}] {{.Names}}\t{{.Status}}\t{{.State}}\t{{.Label \"type\"}}"'';
2024-04-29 05:18:41 +02:00
# fish / system
2024-04-29 02:56:26 +02:00
ls = "exa --icons -F --group-directories-first --git";
cp = "rsync -avr";
ll = "exa -lah --icons -F --group-directories-first --git";
rm = "rm -i";
df = "duf";
cat = "bat";
# git
g = "git";
ga = "git add -A";
gb = "git branch";
gc = "git commit";
gca = "git commit -a";
gco = "git checkout";
gd = "git diff";
gp = "git pull --prune";
gpu = "git push origin HEAD";
gs = "git status -sb";
# time / date
tdate = "date +%Y.%m.%d..%H.%M";
ttime = "date +%H.%M";
ddate = "date +%Y.%m.%d";
dday = "date +%A";
# nixos-rebuild
nr = "sudo nixos-rebuild";
nrs = "sudo nixos-rebuild --upgrade switch";
nrt = "sudo nixos-rebuild test";
nrb = "sudo nixos-rebuild build";
# Rebuild everything
rebuild-home = "git -C /etc/nixos/git pull && home-manager switch -b backup --flake /etc/nixos/git";
rebuild-host = "git -C /etc/nixos/git pull && sudo nixos-rebuild switch --flake /etc/nixos/git";
rebuild-all = "rebuild-host && rebuild-home";
rebuild-host-remote = "git -C /etc/nixos/git pull && sudo nixos-rebuild switch --flake /etc/nixos/git -j0";
rebuild-home-remote = "git -C /etc/nixos/git pull && home-manager switch -b backup --flake /etc/nixos/git --max-jobs 0";
rebuild-all-remote = "rebuild-host-remote && rebuild-home-remote";
};
};
}