Add backup script
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -27,13 +27,13 @@
|
||||
fi
|
||||
}
|
||||
|
||||
_kubeswitch-completion() {
|
||||
_kubeswitch_completion() {
|
||||
local dir="$HOME/.kube"
|
||||
local config="$dir/config"
|
||||
compadd -- ''${(f)"$(find "$dir" -maxdepth 1 \( -type f -o -type l \) -not -name 'config' -exec basename {} \;)"}
|
||||
}
|
||||
|
||||
compdef _kubeswitch-completion kubeswitch
|
||||
compdef _kubeswitch_completion kubeswitch
|
||||
'';
|
||||
|
||||
p10k.extraRightPromptElements = [ "kubecontext" ];
|
||||
|
@@ -7,23 +7,27 @@
|
||||
home-manager.users.${user}.programs.zsh = {
|
||||
shellAliases.nd = "nix-develop";
|
||||
|
||||
initExtra = let
|
||||
devShells = lib.strings.concatStringsSep " " (lib.attrsets.mapAttrsToList (key: _: key) inputs.self.devShells);
|
||||
in ''
|
||||
nix-develop() {
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: nix-develop <shell>"
|
||||
return 1
|
||||
fi
|
||||
nix develop self#"$1" -c "$SHELL"
|
||||
}
|
||||
initExtra =
|
||||
let
|
||||
devShells = lib.strings.concatStringsSep " " (
|
||||
lib.attrsets.mapAttrsToList (key: _: key) inputs.self.devShells
|
||||
);
|
||||
in
|
||||
''
|
||||
nix-develop() {
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: nix-develop <shell>"
|
||||
return 1
|
||||
fi
|
||||
nix develop self#"$1" -c "$SHELL"
|
||||
}
|
||||
|
||||
_nix-develop-completion() {
|
||||
local shells=(${devShells})
|
||||
compadd -- $shells
|
||||
}
|
||||
_nix-develop_completion() {
|
||||
local shells=(${devShells})
|
||||
compadd -- $shells
|
||||
}
|
||||
|
||||
compdef _nix-develop-completion nix-develop
|
||||
'';
|
||||
compdef _nix-develop_completion nix-develop
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
@@ -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" ];
|
||||
};
|
||||
|
@@ -533,6 +533,6 @@ in
|
||||
}
|
||||
);
|
||||
|
||||
programs.zsh.initExtra = builtins.readFile ./theme.completion.sh;
|
||||
programs.zsh.initExtra = builtins.readFile ./theme.completion.zsh;
|
||||
};
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
_theme-completion() {
|
||||
_theme_completion() {
|
||||
local options=(
|
||||
'-m[set mode: light, dark, or toggle]:mode:(light dark toggle)'
|
||||
'-w[set wallpaper: specify file path]:file:_files'
|
||||
@@ -8,4 +8,4 @@ _theme-completion() {
|
||||
_arguments -s $options
|
||||
}
|
||||
|
||||
compdef _theme-completion theme
|
||||
compdef _theme_completion theme
|
@@ -18,8 +18,9 @@ toggle_mode() {
|
||||
fi
|
||||
}
|
||||
|
||||
show_usage() {
|
||||
usage() {
|
||||
echo "Usage: theme [-m {light|dark|toggle}] [-w <file>]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
finish() {
|
||||
@@ -42,8 +43,7 @@ while getopts "m:w:" opt; do
|
||||
toggle_mode
|
||||
;;
|
||||
*)
|
||||
show_usage
|
||||
exit 1
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
@@ -51,8 +51,7 @@ while getopts "m:w:" opt; do
|
||||
set_wallpaper "$OPTARG"
|
||||
;;
|
||||
*)
|
||||
show_usage
|
||||
exit 1
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
Reference in New Issue
Block a user