infra/nix/home-manager/programs/zsh.nix

121 lines
3 KiB
Nix
Raw Normal View History

2023-02-07 18:24:28 +01:00
{pkgs}: {...}: let
2022-10-31 11:04:38 +01:00
just-plugin = let
plugin_file = pkgs.writeText "_just" ''
#compdef just
#autload
alias justl="\just --list"
alias juste="\just --evaluate"
local subcmds=()
while read -r line ; do
if [[ ! $line == Available* ]] ;
then
subcmds+=(''${line/[[:space:]]*\#/:})
fi
done < <(just --list)
_describe 'command' subcmds
'';
2023-02-07 18:24:28 +01:00
in
pkgs.stdenv.mkDerivation {
name = "just-completions";
version = "0.1.0";
phases = "installPhase";
installPhase = ''
PLUGIN_PATH=$out/share/oh-my-zsh/plugins/just
mkdir -p $PLUGIN_PATH
cp ${plugin_file} $PLUGIN_PATH/_just
chmod --recursive a-w $out
'';
};
in {
programs.zsh = {
enable = true;
# will be called again by oh-my-zsh
enableCompletion = false;
enableAutosuggestions = true;
2023-02-07 18:24:28 +01:00
initExtra = let
inNixShell = ''$([[ -n "$IN_NIX_SHELL" ]] && printf " 🐚")'';
2021-03-27 10:48:27 +01:00
in ''
PROMPT='%F{%(!.red.green)}%n%f@%m %(?.%F{green}%f.%F{red} ($?%))%f %F{blue}%~%f${inNixShell}%F{magenta}$(git_prompt_info)%f$prompt_newline%_%F{%(!.red.green)}$(prompt_char)%f '
RPROMPT=""
# Automatic rehash
zstyle ':completion:*' rehash true
if [ -f $HOME/.shrc.d/sh_aliases ]; then
. $HOME/.shrc.d/sh_aliases
fi
2023-02-07 18:24:28 +01:00
${
if builtins.hasAttr "homeshick" pkgs
then ''
source ${pkgs.homeshick}/homeshick.sh
fpath=(${pkgs.homeshick}/completions $fpath)
''
else ""
}
# Disable intercepting of ctrl-s and ctrl-q as flow control.
stty stop ''' -ixoff -ixon
# don't cd into directories when executed
unsetopt AUTO_CD
export NIX_PATH="${pkgs.nixPath}"
2019-07-12 20:01:11 +02:00
# print lines without termination
setopt PROMPT_CR
setopt PROMPT_SP
export PROMPT_EOL_MARK=""
'';
sessionVariables = {
# Add more envrionment variables here
};
plugins = [
{
# will source zsh-autosuggestions.plugin.zsh
name = "zsh-autosuggestions";
src = pkgs.fetchFromGitHub {
owner = "zsh-users";
repo = "zsh-autosuggestions";
2019-07-12 20:18:17 +02:00
rev = "v0.6.3";
2020-11-25 21:50:56 +01:00
sha256 = "1h8h2mz9wpjpymgl2p7pc146c1jgb3dggpvzwm9ln3in336wl95c";
};
}
{
name = "enhancd";
file = "init.sh";
src = pkgs.fetchFromGitHub {
owner = "b4b4r07";
repo = "enhancd";
2019-07-12 20:18:17 +02:00
rev = "v2.2.4";
sha256 = "1smskx9vkx78yhwspjq2c5r5swh9fc5xxa40ib4753f00wk4dwpp";
};
}
{
name = "pass";
src = "${pkgs.oh-my-zsh}/share/oh-my-zsh/plugins/pass";
}
{
name = "minikube";
src = "${pkgs.oh-my-zsh}/share/oh-my-zsh/plugins/minikube";
}
2019-07-24 22:14:14 +02:00
{
name = "just";
src = "${just-plugin}/share/oh-my-zsh/plugins/just";
}
];
oh-my-zsh = {
enable = true;
theme = "tjkirch";
2023-02-07 18:24:28 +01:00
plugins = ["git" "sudo"];
};
};
}