Add aliases and function for managing nix

This commit is contained in:
David Morgan 2022-11-12 16:26:49 +00:00
parent c4b124267d
commit 011c3d5f78
Signed by: djm
GPG Key ID: C171251002C200F2
1 changed files with 19 additions and 0 deletions

View File

@ -53,6 +53,8 @@
pp = "pushbullet push \"Pixel\" link \"\${1}\" \"\${1}\"";
upgrade_emacs = "cp ~/.emacs.d/straight/versions/default.el straight-versions-default-`date \"+%Y-%m-%d-%H%M%S\"`.el && emacs --batch -l \"~/.emacs.d/init.el\" -f \"my/upgrade-packages\"";
diff_emacs = "difft --color always --context 0 $(ls -d1v ~/straight-versions-default-*.el | tail -1) ~/.emacs.d/straight/versions/default.el | grep '\\[9[12]' | egrep -v '(gnu-elpa-mirror|nongnu-elpa|melpa|emacsmirror-mirror)'";
nix-up = "git -C ~/dotfiles pull && doas nix-channel --update && doas nixos-rebuild switch && nix-channel --update && home-manager switch && system-changes-report && hm-changes-report";
home-up = "git -C ~/dotfiles pull && nix-channel --update && home-manager switch && hm-changes-report";
# Git log aliases from the omz git plugin
gl = "git pull";
@ -117,6 +119,23 @@
function generate () { gopass generate -s -p $1 $((RANDOM % 14 + 45)) }
function gcd () {
if [ $# -eq 0 ] ; then
echo "Number of days must be specified" >&2
return 1
fi
if ! [[ $1 =~ '^[0-9]+$' ]] ; then
echo "Number of days must be a number" >&2
return 2
fi
if [ $1 -eq 0 ] ; then
doas nix-collect-garbage -d
else
doas nix-collect-garbage --delete-older-than ''${1}d
fi
}
[[ ! -f ~/.zsh.local ]] || source ~/.zsh.local
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh