Add backup script

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2025-01-12 13:20:31 +00:00
parent fca554dbd4
commit 8e18ca20a9
12 changed files with 160 additions and 51 deletions

View File

@@ -16,34 +16,38 @@
zsh = {
shellAliases.nde = "nix-direnv";
initExtra = let
devShells = lib.strings.concatStringsSep " " (lib.attrsets.mapAttrsToList (key: _: key) inputs.self.devShells);
in ''
nix-direnv() {
if [ -z "$1" ]; then
echo "use flake" > .envrc
else
echo "use flake self#$1" > .envrc
fi
if git rev-parse --is-inside-work-tree &> /dev/null && ! grep -q "^\.envrc$" .gitignore .git/info/exclude; then
echo "Do you want to hide the .envrc file from git? (y/N)"
read -r answer
if [[ "$answer" =~ ^[Yy]$ ]]; then
echo ".envrc" >> .git/info/exclude
initExtra =
let
devShells = lib.strings.concatStringsSep " " (
lib.attrsets.mapAttrsToList (key: _: key) inputs.self.devShells
);
in
''
nix-direnv() {
if [ -z "$1" ]; then
echo "use flake" > .envrc
else
echo "use flake self#$1" > .envrc
fi
fi
direnv allow
}
if git rev-parse --is-inside-work-tree &> /dev/null && ! grep -q "^\.envrc$" .gitignore .git/info/exclude; then
echo "Do you want to hide the .envrc file from git? (y/N)"
read -r answer
if [[ "$answer" =~ ^[Yy]$ ]]; then
echo ".envrc" >> .git/info/exclude
fi
fi
_nix-direnv-completion() {
local shells=(${devShells})
compadd -- $shells
}
direnv allow
}
compdef _nix-direnv-completion nix-direnv
'';
_nix-direnv_completion() {
local shells=(${devShells})
compadd -- $shells
}
compdef _nix-direnv_completion nix-direnv
'';
p10k.extraRightPromptElements = [ "direnv" ];
};