2024-05-19 00:05:50 +00:00
|
|
|
# File: ~/.zshrc
|
|
|
|
# Description: zsh configuration file
|
|
|
|
|
|
|
|
source ~/.guix-home/profile/bin/z.sh
|
|
|
|
precmd () {
|
|
|
|
z --add "$(pwd -P)"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Use zsh-autosuggestions (requires pacman package)
|
|
|
|
source ~/.guix-home/profile/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
|
|
|
|
|
|
|
|
# TODO: temporary
|
|
|
|
fpath=( ~/.guix-home/profile/share/zsh/site-functions "${fpath[@]}" )
|
|
|
|
|
|
|
|
# The following lines were added by compinstall
|
|
|
|
zstyle ':completion:*' completer _list _expand _complete _ignored _match _correct _approximate _prefix
|
|
|
|
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
|
|
|
|
zstyle ':completion:*' matcher-list '' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'r:|[._-/,+]=** r:|=**' 'l:|=* r:|=*'
|
|
|
|
zstyle ':completion:*' max-errors 5
|
|
|
|
zstyle ':completion:*' preserve-prefix '//[^/]##/'
|
2024-07-22 23:31:10 +00:00
|
|
|
zstyle :compinstall filename "${HOME}/.config/zsh/.zshrc"
|
2024-05-19 00:05:50 +00:00
|
|
|
|
|
|
|
autoload -Uz compinit
|
|
|
|
compinit
|
|
|
|
|
|
|
|
autoload -U promptinit; promptinit
|
|
|
|
prompt spaceship
|
|
|
|
# End of lines added by compinstall
|
|
|
|
|
|
|
|
# Lines for zsh setup
|
|
|
|
|
|
|
|
HISTFILE="$HOME/.zsh_history"
|
|
|
|
HISTSIZE=10000000
|
|
|
|
SAVEHIST=10000000
|
|
|
|
setopt AUTO_CD # Change directories without cd
|
|
|
|
setopt BANG_HIST # Treat the '!' character specially during expansion.
|
|
|
|
setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format.
|
|
|
|
setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits.
|
|
|
|
setopt SHARE_HISTORY # Share history between all sessions.
|
|
|
|
setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history.
|
|
|
|
setopt HIST_IGNORE_DUPS # Don't record an entry that was just recorded again.
|
|
|
|
setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate.
|
|
|
|
setopt HIST_FIND_NO_DUPS # Do not display a line previously found.
|
|
|
|
setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space.
|
|
|
|
setopt HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file.
|
|
|
|
setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry.
|
|
|
|
setopt HIST_VERIFY # Don't execute immediately upon history expansion.
|
|
|
|
setopt HIST_BEEP # Beep when accessing nonexistent history.
|
|
|
|
|
|
|
|
setopt COMPLETE_ALIASES # Complete command line switches for aliases
|
|
|
|
# End of zsh history setup
|
|
|
|
|
|
|
|
# Use emacs keybindings
|
|
|
|
bindkey -e
|
|
|
|
|
|
|
|
# Lines to add fzf fuzzy completion widgets supplied by fzf package
|
|
|
|
source ~/.guix-home/profile/share/fzf/key-bindings.zsh
|
|
|
|
source ~/.guix-home/profile/share/fzf/completion.zsh
|
|
|
|
|
|
|
|
# Rebind C-t for fzf-file-widget to ESC-t
|
|
|
|
bindkey -r '^T'
|
|
|
|
bindkey '\et' fzf-file-widget
|
|
|
|
# Rebind C-r for ffz-history-widget to ESC-r
|
|
|
|
bindkey -r '^R'
|
|
|
|
bindkey '\er' fzf-history-widget
|
|
|
|
|
|
|
|
export FZF_DEFAULT_OPTS='--no-height --no-reverse'
|
|
|
|
export FZF_ALT_C_COMMAND="find -L . -mindepth 1 \\( -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune -o -type d -print 2> /dev/null | cut -b3-"
|
|
|
|
#export FZF_CTRL_T_COMMAND="find -L . -mindepth 1 \\( -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune -o -type f -print -o -type d -print -o -type l -print 2> /dev/null | cut -b3-"
|
|
|
|
export FZF_CTRL_T_COMMAND="ag --hidden --ignore .git -g '' 2> /dev/null"
|
|
|
|
export FZF_CTRL_T_OPTS="--preview '(highlight -O ansi -l {} 2> /dev/null || cat {} || tree -C {}) 2> /dev/null'"
|
|
|
|
export FZF_CTRL_R_OPTS="--preview 'echo {}' --preview-window down:3:hidden --bind '?:toggle-preview'"
|
|
|
|
# End of zsh fzf widget setup
|
|
|
|
|
|
|
|
# Check for a tramp session and set a compatible PS1
|
|
|
|
# See: https://www.emacswiki.org/emacs/TrampMode
|
|
|
|
[[ $TERM == "tramp" ]] && unsetopt zle && PS1='$ ' && return
|
|
|
|
|
|
|
|
# Check for an interactive session
|
|
|
|
[ -z "$PS1" ] && return
|
|
|
|
|
|
|
|
# Preferably, setup of man/info would be automatically be handled by 'guix shell' itself,
|
|
|
|
# however this is not the case, as the profile hook for man/info pages will not be triggered
|
|
|
|
# unless man or info respectively is also explicitly included in the profile.
|
|
|
|
if [ ! -z "$GUIX_ENVIRONMENT" ]; then
|
|
|
|
# When using guix shell (formally environment) command, automatically add the temporary
|
|
|
|
# environments man page directory to MANPATH, if it exists.
|
|
|
|
if [ -d "$GUIX_ENVIRONMENT/share/man" ]; then
|
|
|
|
export MANPATH="$GUIX_ENVIRONMENT/share/man:$MANPATH"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Similarly to man, automatically add the temporary environments info page directory to
|
|
|
|
# INFOPATH, if it exists.
|
|
|
|
if [ -d "$GUIX_ENVIRONMENT/share/info" ]; then
|
|
|
|
export INFOPATH="$GUIX_ENVIRONMENT/share/info:$INFOPATH"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Alias' to make command output prettier (use color with some commands by default)
|
|
|
|
alias ls='ls --color=auto'
|
|
|
|
alias ll='ls -l'
|
|
|
|
alias la='ls -a'
|
|
|
|
alias lla='ls -al'
|
|
|
|
alias grep='grep --color=auto'
|
|
|
|
alias fgrep='fgrep --color=auto'
|
|
|
|
alias egrep='egrep --color=auto'
|
|
|
|
|
|
|
|
alias f='find'
|
|
|
|
compdef f='find'
|
|
|
|
|
|
|
|
alias b='bat'
|
|
|
|
# #compdef b='bat' # No completions for bat installed/available
|
|
|
|
|
|
|
|
alias x='eza'
|
|
|
|
alias xs='eza'
|
|
|
|
alias xl='eza -l'
|
|
|
|
alias xla='eza -la'
|
|
|
|
alias xx='x -alT --git'
|
|
|
|
compdef x='eza'
|
|
|
|
compdef xs='eza'
|
|
|
|
compdef xl='eza'
|
|
|
|
compdef xla='eza'
|
|
|
|
compdef xx='eza'
|
|
|
|
|
|
|
|
alias e='emacsclient -t'
|
|
|
|
alias kssh='kitty +kitten ssh'
|
|
|
|
alias qemu="qemu-system-$(uname -m) -enable-kvm"
|
|
|
|
alias lock='cmatrix; clear; vlock'
|
|
|
|
alias vv="remote-viewer --connect qemu:///session"
|
|
|
|
alias xc="xclip -selection clipboard"
|
|
|
|
# alias mplayer-ascii='mplayer -vo aa:driver=curses -monitorpixelaspect 0.5 -really-quiet'
|
|
|
|
|
|
|
|
alias s='sudo'
|
|
|
|
alias si='sudo -i'
|
|
|
|
compdef s='sudo'
|
|
|
|
compdef si='sudo'
|
|
|
|
|
|
|
|
# Turn off noscroll
|
|
|
|
stty stop undef
|
|
|
|
|
|
|
|
# Setup direnv hook
|
|
|
|
eval "$(direnv hook zsh)"
|
|
|
|
|
|
|
|
# Use zsh-source-highlight
|
|
|
|
source ~/.guix-home/profile/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
|
|
|
|
|
|
|
# Access pem ssh keys from password store
|
|
|
|
pass-ssh() {
|
|
|
|
psw="$1"
|
|
|
|
shift
|
|
|
|
|
|
|
|
key_file="$(mktemp)"
|
|
|
|
|
|
|
|
pass "$psw" > "$key_file"
|
|
|
|
ssh -i "$key_file" $@
|
|
|
|
|
|
|
|
rm "$key_file"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Required for emacs vterm
|
|
|
|
# See: https://github.com/akermu/emacs-libvterm
|
|
|
|
vterm_printf(){
|
|
|
|
if [ -n "$TMUX" ]; then
|
|
|
|
# Tell tmux to pass the escape sequences through
|
|
|
|
# (Source: http://permalink.gmane.org/gmane.comp.terminal-emulators.tmux.user/1324)
|
|
|
|
printf "\ePtmux;\e\e]%s\007\e\\" "$1"
|
|
|
|
elif [ "${TERM%%-*}" = "screen" ]; then
|
|
|
|
# GNU screen (screen, screen-256color, screen-256color-bce)
|
|
|
|
printf "\eP\e]%s\007\e\\" "$1"
|
|
|
|
else
|
|
|
|
printf "\e]%s\e\\" "$1"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Ease message passing to vterm
|
|
|
|
vterm_cmd() {
|
|
|
|
local vterm_elisp
|
|
|
|
vterm_elisp=""
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
vterm_elisp="$vterm_elisp""$(printf '"%s" ' "$(printf "%s" "$1" | sed -e 's|\\|\\\\|g' -e 's|"|\\"|g')")"
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
vterm_printf "51;E$vterm_elisp"
|
|
|
|
}
|
|
|
|
|
|
|
|
if [[ "$INSIDE_EMACS" = 'vterm' ]]; then
|
|
|
|
# Override man to run emacs man
|
|
|
|
man() {
|
|
|
|
vterm_cmd man "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Override info to run emacs info
|
|
|
|
info() {
|
|
|
|
vterm_cmd info "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
find-file() {
|
|
|
|
vterm_cmd find-file "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
message() {
|
|
|
|
vterm_cmd message "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
vterm-clear-scrollback() {
|
|
|
|
vterm_cmd vterm-clear-scrollback "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
# For emacs vterm directory and prompt tracking
|
|
|
|
# https://github.com/akermu/emacs-libvterm#directory-tracking-and-prompt-tracking
|
|
|
|
vterm_prompt_end() {
|
|
|
|
vterm_printf "51;A$(whoami)@$(hostname):$(pwd)";
|
|
|
|
}
|
|
|
|
setopt PROMPT_SUBST
|
|
|
|
PROMPT=$PROMPT'%{$(vterm_prompt_end)%}'
|
|
|
|
fi
|