Migrate zsh config

This commit is contained in:
2023-01-02 23:45:01 +00:00
parent 71b5eee6ed
commit 903cbdc9da
4 changed files with 20 additions and 19 deletions

106
modules/shell/zsh/.zshrc Normal file
View File

@ -0,0 +1,106 @@
####
## zsh configuration
####
## Environment
export GPG_TTY=$TTY
## Aliases
source "$ZDOTDIR/aliases.zsh"
## Colors
autoload -U colors && colors
## Completion
setopt HASH_LIST_ALL
unsetopt AUTO_NAME_DIRS
autoload -Uz compinit
zstyle ':completion:*' menu select
zmodload zsh/complist
compinit
_comp_options+=(globdots) # Include hidden files
## Directories
setopt AUTO_CD
setopt AUTO_PUSHD
setopt CDABLE_VARS
setopt PUSHD_IGNORE_DUPS
setopt PUSHD_SILENT
setopt PUSHD_TO_HOME
## Expansion and globbing
setopt EXTENDED_GLOB
unsetopt GLOB_DOTS
unsetopt NOMATCH
## History
setopt APPEND_HISTORY
setopt BANG_HIST
setopt EXTENDED_HISTORY
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_SAVE_NO_DUPS
setopt HIST_VERIFY
setopt INC_APPEND_HISTORY_TIME
HISTFILE="${XDG_CACHE_HOME:-${HOME}/.cache}/zsh/history"
HISTSIZE=1000000
SAVEHIST=1000000
[[ !( -f "${HISTFILE}" ) ]] && mkdir -p $(dirname ${HISTFILE})
## I/O
setopt INTERACTIVE_COMMENTS
setopt MULTIOS
unsetopt CLOBBER
## Jobs
setopt LONG_LIST_JOBS
setopt AUTO_RESUME
unsetopt BG_NICE
unsetopt NOTIFY
unsetopt HUP
unsetopt CHECK_JOBS
## Shell emulation
setopt APPEND_CREATE
## Prompt
PS1="%B%{$fg[magenta]%}%~%{$reset_color%} $%b "
## Vi mode
bindkey -v
export KEYTIMEOUT=1
## Zsh line editor
unsetopt BEEP
####
## Plugins
####
## Autosuggest
# source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh 2>/dev/null
# ## History substring search
# source /usr/share/zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh 2>/dev/null
# bindkey -M vicmd 'k' history-substring-search-up
# bindkey -M vicmd 'j' history-substring-search-down
# ## Highlighting
# source /usr/share/zsh/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh 2>/dev/null
# ## Enhanced vim mode
# MODE_INDICATOR=""
# MODE_CURSOR_VIINS="#b77ee0 blinking bar"
# MODE_CURSOR_REPLACE="$MODE_CURSOR_VIINS #ff3334"
# MODE_CURSOR_VICMD="#b77ee0 block"
# MODE_CURSOR_SEARCH="#e7c547 steady underline"
# MODE_CURSOR_VISUAL="$MODE_CURSOR_VICMD steady bar"
# MODE_CURSOR_VLINE="$MODE_CURSOR_VISUAL #54ced6"
# source /usr/share/zsh/plugins/zsh-vim-mode/zsh-vim-mode.plugin.zsh 2>/dev/null
####
## Keybindings
####
stty stop undef
bindkey -s '^f' 'cd "$(dirname "$(fzf)")"\n'

View File

@ -0,0 +1,25 @@
#!/bin/sh
# Verbose file operations
alias \
cp="cp -iv" \
mv="mv -iv" \
rm="rm -v" \
mkdir="mkdir -v"
# Colorize commands
alias \
ls="ls -h --color=auto --group-directories-first"
# Abbreviations
alias \
e="$EDITOR" \
f="$FILE" \
g="git" \
m="neomutt" \
n="$FILE" \
v="$EDITOR"
# XDG fixes
alias \
mbsync="mbsync -c $XDG_CONFIG_HOME/isync/mbsyncrc -a"

View File

@ -0,0 +1,42 @@
{ config, lib, pkgs, ... }:
with lib;
with lib.my;
let cfg = config.modules.shell.zsh;
in {
options.modules.shell.zsh = {
enable = mkBoolOpt false;
};
config = mkIf cfg.enable {
users.defaultUserShell = pkgs.zsh;
programs.zsh = {
enable = true;
enableCompletion = true;
};
user.packages = with pkgs; [
fd
fzf
jq
nix-zsh-completions
nnn
ripgrep
zsh
zsh-autosuggestions
zsh-fast-syntax-highlighting
zsh-history-substring-search
];
env = {
ZDOTDIR = "$XDG_CONFIG_HOME/zsh";
ZSH_CACHE = "$XDG_CACHE_HOME/zsh";
};
home.configFile = {
"zsh/.zshrc" = { source = ./.zshrc; };
"zsh/aliases.zsh" = { source = ./aliases.zsh };
};
};
}