Add zsh completions
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
34
flake.lock
generated
34
flake.lock
generated
@@ -119,24 +119,6 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"flake-utils": {
|
|
||||||
"inputs": {
|
|
||||||
"systems": "systems"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1731533236,
|
|
||||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"home-manager": {
|
"home-manager": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
@@ -215,7 +197,6 @@
|
|||||||
"ags": "ags",
|
"ags": "ags",
|
||||||
"astal": "astal_2",
|
"astal": "astal_2",
|
||||||
"disko": "disko",
|
"disko": "disko",
|
||||||
"flake-utils": "flake-utils",
|
|
||||||
"home-manager": "home-manager",
|
"home-manager": "home-manager",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"nur": "nur",
|
"nur": "nur",
|
||||||
@@ -264,21 +245,6 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"systems": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"treefmt-nix": {
|
"treefmt-nix": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
|
30
flake.nix
30
flake.nix
@@ -45,10 +45,6 @@
|
|||||||
url = "github:nix-community/NUR";
|
url = "github:nix-community/NUR";
|
||||||
};
|
};
|
||||||
|
|
||||||
flake-utils = {
|
|
||||||
url = "github:numtide/flake-utils";
|
|
||||||
};
|
|
||||||
|
|
||||||
astal = {
|
astal = {
|
||||||
url = "github:aylur/astal";
|
url = "github:aylur/astal";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
@@ -67,39 +63,30 @@
|
|||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
{ self, nixpkgs, ... }@inputs:
|
{ self, nixpkgs, ... }@inputs:
|
||||||
|
let
|
||||||
|
pkgs = nixpkgs.legacyPackages."x86_64-linux";
|
||||||
|
in
|
||||||
{
|
{
|
||||||
nixosConfigurations = {
|
nixosConfigurations = {
|
||||||
installer = nixpkgs.lib.nixosSystem {
|
installer = nixpkgs.lib.nixosSystem {
|
||||||
specialArgs = {
|
specialArgs = { inherit inputs; };
|
||||||
inherit inputs;
|
|
||||||
};
|
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
modules = [ ./hosts/installer ];
|
modules = [ ./hosts/installer ];
|
||||||
};
|
};
|
||||||
|
|
||||||
eirene = nixpkgs.lib.nixosSystem {
|
eirene = nixpkgs.lib.nixosSystem {
|
||||||
specialArgs = {
|
specialArgs = { inherit inputs; };
|
||||||
inherit inputs;
|
|
||||||
};
|
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
modules = [ ./hosts/eirene ];
|
modules = [ ./hosts/eirene ];
|
||||||
};
|
};
|
||||||
|
|
||||||
elara = nixpkgs.lib.nixosSystem {
|
elara = nixpkgs.lib.nixosSystem {
|
||||||
specialArgs = {
|
specialArgs = { inherit inputs; };
|
||||||
inherit inputs;
|
|
||||||
};
|
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
modules = [ ./hosts/elara ];
|
modules = [ ./hosts/elara ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
|
||||||
// inputs.flake-utils.lib.eachDefaultSystem (
|
|
||||||
system:
|
|
||||||
let
|
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
devShells = {
|
devShells = {
|
||||||
bun = import ./hosts/common/shells/bun { inherit pkgs; };
|
bun = import ./hosts/common/shells/bun { inherit pkgs; };
|
||||||
go = import ./hosts/common/shells/go { inherit pkgs; };
|
go = import ./hosts/common/shells/go { inherit pkgs; };
|
||||||
@@ -110,6 +97,5 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
formatter = pkgs.nixfmt-rfc-style;
|
formatter = pkgs.nixfmt-rfc-style;
|
||||||
}
|
};
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,32 @@
|
|||||||
kind
|
kind
|
||||||
];
|
];
|
||||||
|
|
||||||
programs.zsh.p10k.extraRightPromptElements = [ "kubecontext" ];
|
programs.zsh = {
|
||||||
|
initExtra = ''
|
||||||
|
kubeswitch() {
|
||||||
|
local target="$HOME/.kube/$1"
|
||||||
|
local config="$HOME/.kube/config"
|
||||||
|
|
||||||
|
if [[ -f "$target" && "$target" != "$config" ]]; then
|
||||||
|
ln -sf "$target" "$config"
|
||||||
|
echo "Switched kube context to $1"
|
||||||
|
p10k reload
|
||||||
|
else
|
||||||
|
echo "Invalid kube context: $1"
|
||||||
|
echo "Ensure the file exists in ~/.kube"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_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
|
||||||
|
'';
|
||||||
|
|
||||||
|
p10k.extraRightPromptElements = [ "kubecontext" ];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -2,12 +2,14 @@
|
|||||||
user ? throw "user argument is required",
|
user ? throw "user argument is required",
|
||||||
home ? throw "home argument is required",
|
home ? throw "home argument is required",
|
||||||
}:
|
}:
|
||||||
{ ... }:
|
{ lib, inputs, ... }:
|
||||||
{
|
{
|
||||||
home-manager.users.${user}.programs.zsh = {
|
home-manager.users.${user}.programs.zsh = {
|
||||||
shellAliases.nd = "nix-develop";
|
shellAliases.nd = "nix-develop";
|
||||||
|
|
||||||
initExtra = ''
|
initExtra = let
|
||||||
|
devShells = lib.strings.concatStringsSep " " (lib.attrsets.mapAttrsToList (key: _: key) inputs.self.devShells);
|
||||||
|
in ''
|
||||||
nix-develop() {
|
nix-develop() {
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
echo "Usage: nix-develop <shell>"
|
echo "Usage: nix-develop <shell>"
|
||||||
@@ -15,6 +17,13 @@
|
|||||||
fi
|
fi
|
||||||
nix develop self#"$1" -c "$SHELL"
|
nix develop self#"$1" -c "$SHELL"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_nix-develop-completion() {
|
||||||
|
local shells=(${devShells})
|
||||||
|
compadd -- $shells
|
||||||
|
}
|
||||||
|
|
||||||
|
compdef _nix-develop-completion nix-develop
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
user ? throw "user argument is required",
|
user ? throw "user argument is required",
|
||||||
home ? throw "home argument is required",
|
home ? throw "home argument is required",
|
||||||
}:
|
}:
|
||||||
{ inputs, ... }:
|
{ lib, inputs, ... }:
|
||||||
{
|
{
|
||||||
home-manager.users.${user} = {
|
home-manager.users.${user} = {
|
||||||
programs = {
|
programs = {
|
||||||
@@ -16,7 +16,9 @@
|
|||||||
zsh = {
|
zsh = {
|
||||||
shellAliases.nde = "nix-direnv";
|
shellAliases.nde = "nix-direnv";
|
||||||
|
|
||||||
initExtra = ''
|
initExtra = let
|
||||||
|
devShells = lib.strings.concatStringsSep " " (lib.attrsets.mapAttrsToList (key: _: key) inputs.self.devShells);
|
||||||
|
in ''
|
||||||
nix-direnv() {
|
nix-direnv() {
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
echo "use flake" > .envrc
|
echo "use flake" > .envrc
|
||||||
@@ -34,6 +36,13 @@
|
|||||||
|
|
||||||
direnv allow
|
direnv allow
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_nix-direnv-completion() {
|
||||||
|
local shells=(${devShells})
|
||||||
|
compadd -- $shells
|
||||||
|
}
|
||||||
|
|
||||||
|
compdef _nix-direnv-completion nix-direnv
|
||||||
'';
|
'';
|
||||||
|
|
||||||
p10k.extraRightPromptElements = [ "direnv" ];
|
p10k.extraRightPromptElements = [ "direnv" ];
|
||||||
|
@@ -23,7 +23,7 @@ in
|
|||||||
|
|
||||||
wayland.windowManager.hyprland.settings.bind = [
|
wayland.windowManager.hyprland.settings.bind = [
|
||||||
"Ctrl_Alt, r, exec, ${themeBin}"
|
"Ctrl_Alt, r, exec, ${themeBin}"
|
||||||
"Ctrl_Alt, t, exec, ${themeBin} toggle"
|
"Ctrl_Alt, t, exec, ${themeBin} -m toggle"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -532,5 +532,7 @@ in
|
|||||||
}) cfg.template;
|
}) cfg.template;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
programs.zsh.initExtra = builtins.readFile ./theme.completion.sh;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
11
hosts/common/configs/user/gui/theme/theme.completion.sh
Normal file
11
hosts/common/configs/user/gui/theme/theme.completion.sh
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
_theme-completion() {
|
||||||
|
local options=(
|
||||||
|
'-m[set mode: light, dark, or toggle]:mode:(light dark toggle)'
|
||||||
|
'-w[set wallpaper: specify file path]:file:_files'
|
||||||
|
)
|
||||||
|
local curcontext="$curcontext" state line
|
||||||
|
typeset -A opt_args
|
||||||
|
_arguments -s $options
|
||||||
|
}
|
||||||
|
|
||||||
|
compdef _theme-completion theme
|
@@ -10,15 +10,6 @@ set_wallpaper() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
set_mode() {
|
|
||||||
if [[ "$1" = "light" ]] || [[ "$1" = "dark" ]]; then
|
|
||||||
MODE="$1"
|
|
||||||
else
|
|
||||||
echo "Invalid mode: $1. Use 'light' or 'dark'."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
toggle_mode() {
|
toggle_mode() {
|
||||||
if [[ "$(cat "${CONFIG}"/mode)" = "light" ]]; then
|
if [[ "$(cat "${CONFIG}"/mode)" = "light" ]]; then
|
||||||
MODE="dark"
|
MODE="dark"
|
||||||
@@ -28,7 +19,7 @@ toggle_mode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
show_usage() {
|
show_usage() {
|
||||||
echo "Usage: theme {toggle|light|dark|mode <mode>|wallpaper <file> [mode]}"
|
echo "Usage: theme [-m {light|dark|toggle}] [-w <file>]"
|
||||||
}
|
}
|
||||||
|
|
||||||
finish() {
|
finish() {
|
||||||
@@ -39,56 +30,31 @@ finish() {
|
|||||||
"${RELOAD}" > /dev/null
|
"${RELOAD}" > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ $# -eq 0 ]]; then
|
# Parse arguments
|
||||||
finish
|
while getopts "m:w:" opt; do
|
||||||
else
|
case "$opt" in
|
||||||
case "$1" in
|
m)
|
||||||
|
case "$OPTARG" in
|
||||||
|
light|dark)
|
||||||
|
MODE="$OPTARG"
|
||||||
|
;;
|
||||||
toggle)
|
toggle)
|
||||||
if [[ $# -eq 1 ]]; then
|
|
||||||
toggle_mode
|
toggle_mode
|
||||||
else
|
|
||||||
show_usage
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
light)
|
|
||||||
if [[ $# -eq 1 ]]; then
|
|
||||||
set_mode "light"
|
|
||||||
else
|
|
||||||
show_usage
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
dark)
|
|
||||||
if [[ $# -eq 1 ]]; then
|
|
||||||
set_mode "dark"
|
|
||||||
else
|
|
||||||
show_usage
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
mode)
|
|
||||||
if [[ $# -eq 2 ]]; then
|
|
||||||
set_mode "$2"
|
|
||||||
else
|
|
||||||
show_usage
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
wallpaper)
|
|
||||||
if [[ $# -ge 2 ]] && [[ $# -le 3 ]]; then
|
|
||||||
set_wallpaper "$2"
|
|
||||||
[[ $# -eq 3 ]] && set_mode "$3"
|
|
||||||
else
|
|
||||||
show_usage
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
show_usage
|
show_usage
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
;;
|
||||||
|
w)
|
||||||
|
set_wallpaper "$OPTARG"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
show_usage
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
finish
|
finish
|
||||||
fi
|
|
||||||
|
Reference in New Issue
Block a user