shell.nix: split zsh to zsh.nix

This commit is contained in:
Gerg-L 2024-12-11 20:21:39 -05:00
parent f46ac4cd5b
commit 5aa2328376
Signed by: gerg-l
SSH key fingerprint: SHA256:FPYDHIkvMocr4wdmZXpgpJjsb2Tw6rASs2ISPbOb0KI
2 changed files with 102 additions and 100 deletions

View file

@ -35,107 +35,56 @@
interactiveShellInit = "fetch-rs"; interactiveShellInit = "fetch-rs";
}; };
#zsh stuff programs.starship = {
users.defaultUserShell = pkgs.zsh; enable = true;
programs = { settings = {
zsh = { add_newline = false;
enable = true; format = ''
autosuggestions.enable = true; $cmd_duration$git_metrics$git_state$git_branch
syntaxHighlighting.enable = true; $status$directory$character'';
histSize = 10000; right_format = "$sudo$nix_shell\${custom.direnv} $time";
histFile = "$HOME/.cache/zsh_history"; continuation_prompt = " ";
interactiveShellInit = '' character = {
### zsh-history-substring-search ### success_symbol = "[\\$](#9ece6a bold)";
setopt HIST_IGNORE_ALL_DUPS error_symbol = "[\\$](#db4b4b bold)";
source ${pkgs.zsh-history-substring-search}/share/zsh-history-substring-search/zsh-history-substring-search.zsh };
bindkey '^[[A' history-substring-search-up status = {
bindkey '^[[B' history-substring-search-down disabled = false;
### fzf-tab ### format = "[$status]($style) ";
source ${pkgs.zsh-fzf-tab}/share/fzf-tab/fzf-tab.plugin.zsh };
### transient shell prompt ### nix_shell = {
zle-line-init() { format = "[󱄅 ](#74b2ff)";
emulate -L zsh heuristic = true;
};
[[ $CONTEXT == start ]] || return 0 directory = {
read_only = " ";
while true; do };
zle .recursive-edit git_metrics = {
local -i ret=$? disabled = false;
[[ $ret == 0 && $KEYS == $'\4' ]] || break };
[[ -o ignore_eof ]] || exit 0 git_branch = {
done format = "[$symbol$branch(:$remote_branch)]($style)";
style = "bold red";
local saved_prompt=$PROMPT };
local saved_rprompt=$RPROMPT cmd_duration = {
PROMPT='\$ ' min_time = 5000;
RPROMPT=''' style = "bold #9ece6a";
zle .reset-prompt };
PROMPT=$saved_prompt custom.direnv = {
RPROMPT=$saved_rprompt format = "[\\[direnv\\]]($style)";
style = "#36c692";
if (( ret )); then when = "printenv DIRENV_FILE";
zle .send-break };
else time = {
zle .accept-line
fi
return ret
}
zle -N zle-line-init
'';
};
#starship
starship = {
enable = true;
settings = {
add_newline = false;
format = '' format = ''
$cmd_duration$git_metrics$git_state$git_branch [$time]($style)
$status$directory$character''; '';
right_format = "$sudo$nix_shell\${custom.direnv} $time"; time_format = "%I:%M %p";
continuation_prompt = " "; disabled = false;
character = { };
success_symbol = "[\\$](#9ece6a bold)"; sudo = {
error_symbol = "[\\$](#db4b4b bold)"; format = "[ ](#7aa2f7)";
}; disabled = false;
status = {
disabled = false;
format = "[$status]($style) ";
};
nix_shell = {
format = "[󱄅 ](#74b2ff)";
heuristic = true;
};
directory = {
read_only = " ";
};
git_metrics = {
disabled = false;
};
git_branch = {
format = "[$symbol$branch(:$remote_branch)]($style)";
style = "bold red";
};
cmd_duration = {
min_time = 5000;
style = "bold #9ece6a";
};
custom.direnv = {
format = "[\\[direnv\\]]($style)";
style = "#36c692";
when = "printenv DIRENV_FILE";
};
time = {
format = ''
[$time]($style)
'';
time_format = "%I:%M %p";
disabled = false;
};
sudo = {
format = "[ ](#7aa2f7)";
disabled = false;
};
}; };
}; };
}; };

53
modules/zsh.nix Normal file
View file

@ -0,0 +1,53 @@
{ pkgs }:
{
users.defaultUserShell = pkgs.zsh;
programs = {
zsh = {
enable = true;
autosuggestions.enable = true;
syntaxHighlighting.enable = true;
histSize = 20000;
histFile = "$HOME/.cache/zsh_history";
interactiveShellInit = ''
### zsh-history-substring-search ###
setopt HIST_IGNORE_ALL_DUPS
source ${pkgs.zsh-history-substring-search}/share/zsh-history-substring-search/zsh-history-substring-search.zsh
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
### fzf-tab ###
source ${pkgs.zsh-fzf-tab}/share/fzf-tab/fzf-tab.plugin.zsh
### transient shell prompt ###
zle-line-init() {
emulate -L zsh
[[ $CONTEXT == start ]] || return 0
while true; do
zle .recursive-edit
local -i ret=$?
[[ $ret == 0 && $KEYS == $'\4' ]] || break
[[ -o ignore_eof ]] || exit 0
done
local saved_prompt=$PROMPT
local saved_rprompt=$RPROMPT
PROMPT='\$ '
RPROMPT='''
zle .reset-prompt
PROMPT=$saved_prompt
RPROMPT=$saved_rprompt
if (( ret )); then
zle .send-break
else
zle .accept-line
fi
return ret
}
zle -N zle-line-init
'';
};
};
}