diff options
| author | Alejandro Soto <alejandro@34project.org> | 2024-12-03 21:19:39 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2024-12-03 21:49:54 -0600 |
| commit | 61f3db56410f41d5249c88e44db60d9713dae26d (patch) | |
| tree | 49c2d5d5e4da331d139cfdc6034c0dba5980271b /home/baseline/zshrc.nix | |
| parent | 854f5ee287eb66db5a0713e2f4fac56794e3d735 (diff) | |
home: big refactor
Diffstat (limited to 'home/baseline/zshrc.nix')
| -rw-r--r-- | home/baseline/zshrc.nix | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/home/baseline/zshrc.nix b/home/baseline/zshrc.nix new file mode 100644 index 0000000..a82ab7a --- /dev/null +++ b/home/baseline/zshrc.nix @@ -0,0 +1,64 @@ +{ grml-zsh-config, local, ... }: '' + source ${grml-zsh-config}/etc/zsh/zshrc + + export PATH="$PATH:$HOME/.cargo/bin" + + alias reset='tput reset' + alias reload='exec zsh' + alias this-date='date +%b%d | sed "s/^\w/\U&/g"' + + function spawn() { + if [ ! -x "$(command -v $1)" ]; then + echo "spawn: no such command: $1" >&2 + return 1 + fi + + $@ >/dev/null 0>&1 2>&1 & + disown + } + + function xseli() { + T=$(mktemp) + $EDITOR -n $T + xsel -b <$T + rm $T + } + + autoload -Uz up-line-or-beginning-search + zle -N up-line-or-beginning-search + autoload -Uz down-line-or-beginning-search + zle -N down-line-or-beginning-search + bindkey '\eOA' up-line-or-beginning-search + bindkey '\e[A' up-line-or-beginning-search + bindkey '\eOB' down-line-or-beginning-search + bindkey '\e[B' down-line-or-beginning-search + + INSTALLABLES=() + while read -d: PATH_ITEM; do + if [[ "$PATH_ITEM" =~ "^(/nix/store/[a-z0-9]+-([a-zA-Z][a-zA-Z0-9_]*(-[a-zA-Z][a-zA-Z0-9_]*)*)(-[^/]+)?)/" ]]; then + INSTALLABLES+=("''${match[2]}") + fi + done <<<"$PATH" + + if [ "''${#INSTALLABLES[@]}" -gt 0 ]; then + _GRML_NIX_SHELL="{''${INSTALLABLES[@]}} " + fi + + unset INSTALLABLES PATH_ITEM + + function grml_nix_shell() { + REPLY="$_GRML_NIX_SHELL" + } + + grml_theme_add_token nix-shell -f grml_nix_shell '%F{red}' '%f' + + zstyle ':prompt:grml:left:setup' items $([ ''${NO_USERATHOST:-0} -gt 0 ] || echo user at host) path nix-shell percent + zstyle ':prompt:grml:right:setup' items sad-smiley vcs $([ ''${NO_BATTERY:-0} -gt 0 ] || echo battery) time + zstyle ':prompt:grml:right:items:time' pre ' %F{yellow}' + + unsetopt sharehistory + setopt appendhistory + setopt extendedhistory + + source ${local.git-aliases} +'' |
