nixos-config/home-manager/modules/zsh.nix
fleaz dbe1459fb1 zsh: Alias k9s and add indicator for NOHIST mode
Triggered via "unset HISTFILE"
2025-06-02 17:29:41 +02:00

59 lines
1.9 KiB
Nix

{
programs.zsh = {
enable = true;
oh-my-zsh = {
enable = true;
plugins = [ "git" "fzf" ];
theme = "kolo";
};
history = {
share = false; # every terminal has it's own history durring runtime
extended = true;
size = 10000;
};
shellAliases = {
"k" = "kubectl";
"dl" = "ls -lhtr --color=always ~/Downloads | tail -n 10"; # Show the 10 newest Downloads
"buzzer" = "ssh -i Nextcloud/Privat/id_door door@door.cccda.de buzzer";
"beep" = "paplay /usr/share/sounds/freedesktop/stereo/complete.oga"; # play "ding" for long running jobs
"dig" = "dig +short";
"cat" = "bat --theme=TwoDark --style=plain";
"watch" = "watch "; # https://unix.stackexchange.com/a/25329
"kge" = "kubectl get events --sort-by='.lastTimestamp'";
"devcontainer" = "docker compose -f docker-compose.yml -f .devcontainer/docker-compose.yml"; # Poor mans devcontainer
"k9s" = "k9s -c pods --splashless --logoless";
};
initExtra = ''
setopt APPEND_HISTORY # Append history to global histfile on exit
setopt HIST_IGNORE_SPACE # dont save commands starting with a whitespace
autoload -U colors && colors
function is_ssh(){
if [ ! -z $SSH_CLIENT ]; then
echo %{$fg[red]%}SSH-Session on $(hostname -s)%{$reset_color%}
fi
}
function get_k8s_info(){
kubectl config get-contexts| grep "*" | awk '{print $3"/"$5}'
}
function secret_sesion(){
if ! test -v HISTFILE; then
echo %{$fg[red]%}NOHIST%{$reset_color%}
fi
}
RPS1='$(secret_sesion) $(is_ssh) $(get_k8s_info)'
export EDITOR="nvim";
export PATH="$PATH:$HOME/.krew/bin:$HOME/bin:$HOME/go/bin";
source <(kubectl completion zsh)
source ~/bin/ktx
export GOPRIVATE=gitlab.com
export GOAUTH=netrc
eval "$(direnv hook zsh)"
'';
};
}