2024-06-15 18:37:00 +01:00
|
|
|
{ config, ... }: {
|
2024-05-17 10:54:53 +01:00
|
|
|
|
|
|
|
programs.zsh = {
|
|
|
|
enable = true;
|
|
|
|
enableCompletion = true;
|
|
|
|
autosuggestion.enable = true;
|
|
|
|
syntaxHighlighting.enable = true;
|
2024-06-02 14:30:14 +01:00
|
|
|
|
2024-05-17 10:54:53 +01:00
|
|
|
shellAliases = {
|
|
|
|
ll = "ls -l";
|
2024-07-27 11:13:19 +01:00
|
|
|
src = "cd ~/.local/share/src";
|
2024-10-14 16:57:01 +01:00
|
|
|
no = "cd /etc/nixos";
|
|
|
|
cat = "bat --decorations=never";
|
|
|
|
ls = "eza";
|
2024-05-17 10:54:53 +01:00
|
|
|
};
|
|
|
|
history.size = 10000;
|
|
|
|
history.path = "${config.xdg.dataHome}/zsh/history";
|
|
|
|
|
2024-06-02 14:30:14 +01:00
|
|
|
initExtra = ''
|
|
|
|
bindkey -v
|
2024-05-17 10:54:53 +01:00
|
|
|
bindkey "^H" backward-delete-char
|
|
|
|
bindkey "^?" backward-delete-char
|
|
|
|
set -o vi
|
2024-05-24 21:23:56 +01:00
|
|
|
export TERM=xterm-256color
|
|
|
|
|
|
|
|
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
|
|
|
|
SESSION_TYPE="(ssh) "
|
|
|
|
fi
|
2024-06-02 14:30:14 +01:00
|
|
|
|
2024-05-24 21:23:56 +01:00
|
|
|
####
|
|
|
|
# Format prompt
|
|
|
|
####
|
2024-06-02 14:30:14 +01:00
|
|
|
|
2024-05-24 21:23:56 +01:00
|
|
|
# Define colors
|
|
|
|
COLOR_RED="red"
|
|
|
|
COLOR_MAGENTA="92"
|
|
|
|
COLOR_YELLOW="3"
|
|
|
|
COLOR_GREEN="36"
|
|
|
|
COLOR_BLUE="4"
|
|
|
|
COLOR_WHITE="7"
|
2024-06-02 14:30:14 +01:00
|
|
|
|
2024-05-24 21:23:56 +01:00
|
|
|
# Format git colors
|
|
|
|
autoload -Uz compinit && compinit
|
|
|
|
autoload -Uz add-zsh-hook
|
|
|
|
autoload -Uz vcs_info
|
|
|
|
add-zsh-hook precmd vcs_info
|
2024-06-02 14:30:14 +01:00
|
|
|
|
2024-05-24 21:23:56 +01:00
|
|
|
zstyle ':vcs_info:*' enable git
|
|
|
|
zstyle ':vcs_info:*' formats " %F{cyan}%c%u(%b)%f"
|
|
|
|
zstyle ':vcs_info:*' actionformats " %F{cyan}%c%u(%b)%f %a"
|
|
|
|
zstyle ':vcs_info:*' stagedstr "%F{$COLOR_RED}"
|
|
|
|
zstyle ':vcs_info:*' unstagedstr "%F{$COLOR_RED}"
|
|
|
|
zstyle ':vcs_info:*' check-for-changes true
|
2024-06-02 14:30:14 +01:00
|
|
|
|
2024-05-24 21:23:56 +01:00
|
|
|
zstyle ':vcs_info:git*+set-message:*' hooks git-untracked
|
|
|
|
+vi-git-untracked() {
|
|
|
|
if git --no-optional-locks status --porcelain 2> /dev/null | grep -q "^??"; then
|
|
|
|
hook_com[staged]+="%F{$COLOR_RED}"
|
|
|
|
elif git --no-optional-locks status --porcelain 2> /dev/null | grep -q "^A"; then
|
|
|
|
hook_com[staged]+="%F{$COLOR_YELLOW}"
|
|
|
|
else
|
|
|
|
hook_com[staged]+="%F{$COLOR_GREEN}"
|
|
|
|
fi
|
|
|
|
}
|
2024-06-02 14:30:14 +01:00
|
|
|
|
2024-05-24 21:23:56 +01:00
|
|
|
# Format prompt
|
|
|
|
setopt PROMPT_SUBST
|
|
|
|
PROMPT='%F{'$COLOR_GREEN'}'$(echo "$SESSION_TYPE")'''
|
|
|
|
PROMPT+='%F{'$COLOR_RED'}['
|
|
|
|
PROMPT+='%F{'$COLOR_GREEN'}%n'
|
|
|
|
PROMPT+='%F{red}@'
|
|
|
|
PROMPT+='%F{'$COLOR_YELLOW'}%m'
|
|
|
|
PROMPT+='%F{'$COLOR_RED'}] '
|
|
|
|
PROMPT+='%F{'$COLOR_WHITE'}['
|
|
|
|
PROMPT+='%F{'$COLOR_YELLOW'}%1~'
|
|
|
|
PROMPT+='%F{'$COLOR_WHITE'}]'
|
|
|
|
PROMPT+='$'
|
|
|
|
PROMPT+='vcs_info_msg_0_'
|
|
|
|
PROMPT+=' > '
|
|
|
|
export PROMPT
|
|
|
|
setopt autocd # Automatically cd into typed directory.
|
|
|
|
stty stop undef # Disable ctrl-s to freeze terminal.
|
|
|
|
setopt interactive_comments
|
2024-06-02 14:30:14 +01:00
|
|
|
|
2024-05-24 21:23:56 +01:00
|
|
|
# General opts
|
|
|
|
HISTSIZE=10000000
|
|
|
|
SAVEHIST=10000000
|
|
|
|
setopt appendhistory
|
2024-06-02 14:30:14 +01:00
|
|
|
|
|
|
|
# Change cursor shape for different vi modes.
|
|
|
|
function zle-keymap-select () {
|
|
|
|
case $KEYMAP in
|
|
|
|
vicmd) echo -ne '\e[1 q';; # block
|
|
|
|
viins|main) echo -ne '\e[5 q';; # beam
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
zle -N zle-keymap-select
|
|
|
|
zle-line-init() {
|
|
|
|
zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere)
|
|
|
|
echo -ne "\e[5 q"
|
|
|
|
}
|
|
|
|
zle -N zle-line-init
|
|
|
|
echo -ne '\e[5 q' # Use beam shape cursor on startup.
|
|
|
|
preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt.
|
|
|
|
|
2024-05-17 10:54:53 +01:00
|
|
|
'';
|
|
|
|
};
|
2024-06-02 14:30:14 +01:00
|
|
|
}
|