home: configure zsh
This commit is contained in:
parent
2bfb36d80c
commit
4495ee1d3d
4 changed files with 378 additions and 0 deletions
8
nichijou/home/config/zsh/zlogout
Normal file
8
nichijou/home/config/zsh/zlogout
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# ~/.zshlogout: executed by zsh(1) when login shell exits.
|
||||||
|
|
||||||
|
# when leaving the console clear the screen to increase privacy
|
||||||
|
if [ "$SHLVL" = 1 ]; then
|
||||||
|
# XXX: Avoid hard-coding the path?
|
||||||
|
# [ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
|
||||||
|
hash clear_console && clear_console -q
|
||||||
|
fi
|
50
nichijou/home/config/zsh/zprofile
Normal file
50
nichijou/home/config/zsh/zprofile
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
# set PATH so it includes user's private bin if it exists
|
||||||
|
PATH="$PATH:/usr/sbin"
|
||||||
|
|
||||||
|
# set PATH so it includes user's private bin if it exists
|
||||||
|
if [ -d "$HOME/bin" ] ; then
|
||||||
|
PATH="$HOME/bin:$PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# set PATH so it includes user's private bin if it exists
|
||||||
|
if [ -d "$HOME/.local/bin" ] ; then
|
||||||
|
PATH="$HOME/.local/bin:$PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
export LESS_TERMCAP_md=$'\e[01;31m'
|
||||||
|
export LESS_TERMCAP_me=$'\e[0m'
|
||||||
|
export LESS_TERMCAP_se=$'\e[0m'
|
||||||
|
export LESS_TERMCAP_so=$'\e[01;44;33m'
|
||||||
|
export LESS_TERMCAP_ue=$'\e[0m'
|
||||||
|
export LESS_TERMCAP_us=$'\e[01;32m'
|
||||||
|
|
||||||
|
export EDITOR=nvim
|
||||||
|
export VISUAL=nvim
|
||||||
|
export MANPAGER='nvim +Man!'
|
||||||
|
export MANWIDTH=999
|
||||||
|
export GOPATH=$HOME/go
|
||||||
|
|
||||||
|
# set PATH so it includes Golang's private bin if it exists
|
||||||
|
if [ -d "$GOPATH/bin" ] ; then
|
||||||
|
PATH="$GOPATH/bin:$PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# set PATH so it includes Golang's private bin if it exists
|
||||||
|
if [ -d "$HOME/.cargo/bin" ] ; then
|
||||||
|
PATH="$HOME/cargo/bin:$PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Arrange so that ~/.config/guix/current comes first.
|
||||||
|
for profile in "$HOME/.guix-profile" "$HOME/.config/guix/current"
|
||||||
|
do
|
||||||
|
if [ -f "$profile/etc/profile" ]
|
||||||
|
then
|
||||||
|
# Load the user profile's settings.
|
||||||
|
GUIX_PROFILE="$profile" ; \
|
||||||
|
. "$profile/etc/profile"
|
||||||
|
else
|
||||||
|
# At least define this one so that basic things just work
|
||||||
|
# when the user installs their first package.
|
||||||
|
export PATH="$profile/bin:$PATH"
|
||||||
|
fi
|
||||||
|
done
|
300
nichijou/home/config/zsh/zshrc
Normal file
300
nichijou/home/config/zsh/zshrc
Normal file
|
@ -0,0 +1,300 @@
|
||||||
|
# If not running interactively, don't do anything
|
||||||
|
case $- in
|
||||||
|
*i*) ;;
|
||||||
|
*) return;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Allow for substitutions inside prompt, necessary for e.g. git prompts.
|
||||||
|
setopt PROMPT_SUBST
|
||||||
|
|
||||||
|
# Enable zsh's generic vcs info.
|
||||||
|
autoload -Uz vcs_info
|
||||||
|
precmd () { vcs_info }
|
||||||
|
zstyle ':vcs_info:*' formats ' (%F{cyan}%b%f)'
|
||||||
|
PS1='%B%F{green}%n@%m%f%b:%B%F{blue}%~%f$vcs_info_msg_0_%b%(!.#.$) '
|
||||||
|
|
||||||
|
setopt histignorealldups
|
||||||
|
setopt sharehistory
|
||||||
|
# Experimental options.
|
||||||
|
setopt extended_history
|
||||||
|
setopt hist_ignore_all_dups
|
||||||
|
setopt hist_ignore_space
|
||||||
|
setopt hist_reduce_blanks
|
||||||
|
# Writing the directory name only will cd to it.
|
||||||
|
setopt auto_cd
|
||||||
|
# Do not move cursor to the end of line on completion.
|
||||||
|
setopt complete_in_word
|
||||||
|
# Allow comments in interactive shell.
|
||||||
|
setopt interactive_comments
|
||||||
|
# Disable beep.
|
||||||
|
unsetopt beep
|
||||||
|
# Do not autocorrect spelling for arguments.
|
||||||
|
unsetopt correct
|
||||||
|
unsetopt correct_all
|
||||||
|
|
||||||
|
# Remove duplicate paths.
|
||||||
|
typeset -U PATH
|
||||||
|
|
||||||
|
# Keep 10000 lines of history within the shell and save it to ~/.zsh_history.
|
||||||
|
HISTSIZE=10000
|
||||||
|
SAVEHIST=10000
|
||||||
|
HISTFILE=~/.zsh_history
|
||||||
|
|
||||||
|
# Use modern completion system.
|
||||||
|
autoload -Uz compinit
|
||||||
|
compinit
|
||||||
|
# Also complete bash-specific completions.
|
||||||
|
autoload -U bashcompinit
|
||||||
|
bashcompinit
|
||||||
|
|
||||||
|
zstyle ':completion:*' auto-description 'specify: %d'
|
||||||
|
zstyle ':completion:*' completer _expand _complete _correct _approximate
|
||||||
|
zstyle ':completion:*' format 'Completing %d'
|
||||||
|
zstyle ':completion:*' group-name ''
|
||||||
|
zstyle ':completion:*' menu select=2
|
||||||
|
eval "$(dircolors -b)"
|
||||||
|
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
|
||||||
|
zstyle ':completion:*' list-colors ''
|
||||||
|
zstyle ':completion:*' list-prompt \
|
||||||
|
%SAt %p: Hit TAB for more, or the character to insert%s
|
||||||
|
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' \
|
||||||
|
'r:|[._-]=* r:|=* l:|=*'
|
||||||
|
zstyle ':completion:*' menu select=long
|
||||||
|
zstyle ':completion:*' select-prompt \
|
||||||
|
%SScrolling active: current selection at %p%s
|
||||||
|
zstyle ':completion:*' use-compctl false
|
||||||
|
zstyle ':completion:*' verbose true
|
||||||
|
|
||||||
|
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
|
||||||
|
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
|
||||||
|
|
||||||
|
# Source useful defaults.
|
||||||
|
source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||||
|
source /usr/share/doc/fzf/examples/key-bindings.zsh
|
||||||
|
source /usr/share/doc/fzf/examples/completion.zsh
|
||||||
|
source /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
|
||||||
|
|
||||||
|
# Editor and input char assignment.
|
||||||
|
[[ ${TERM} != 'dumb' ]] && () {
|
||||||
|
|
||||||
|
# Use human-friendly identifiers.
|
||||||
|
zmodload -F zsh/terminfo +b:echoti +p:terminfo
|
||||||
|
typeset -gA key_info
|
||||||
|
key_info=(
|
||||||
|
'Control' '\C-'
|
||||||
|
'ControlLeft' '\e[1;5D \e[5D \e\e[D \eOd \eOD'
|
||||||
|
'ControlRight' '\e[1;5C \e[5C \e\e[C \eOc \eOC'
|
||||||
|
'Escape' '\e'
|
||||||
|
'Meta' '\M-'
|
||||||
|
'Backspace' "${terminfo[kbs]}"
|
||||||
|
'BackTab' "${terminfo[kcbt]}"
|
||||||
|
'Left' "${terminfo[kcub1]}"
|
||||||
|
'Down' "${terminfo[kcud1]}"
|
||||||
|
'Right' "${terminfo[kcuf1]}"
|
||||||
|
'Up' "${terminfo[kcuu1]}"
|
||||||
|
'Delete' "${terminfo[kdch1]}"
|
||||||
|
'End' "${terminfo[kend]}"
|
||||||
|
'F1' "${terminfo[kf1]}"
|
||||||
|
'F2' "${terminfo[kf2]}"
|
||||||
|
'F3' "${terminfo[kf3]}"
|
||||||
|
'F4' "${terminfo[kf4]}"
|
||||||
|
'F5' "${terminfo[kf5]}"
|
||||||
|
'F6' "${terminfo[kf6]}"
|
||||||
|
'F7' "${terminfo[kf7]}"
|
||||||
|
'F8' "${terminfo[kf8]}"
|
||||||
|
'F9' "${terminfo[kf9]}"
|
||||||
|
'F10' "${terminfo[kf10]}"
|
||||||
|
'F11' "${terminfo[kf11]}"
|
||||||
|
'F12' "${terminfo[kf12]}"
|
||||||
|
'Home' "${terminfo[khome]}"
|
||||||
|
'Insert' "${terminfo[kich1]}"
|
||||||
|
'PageDown' "${terminfo[knp]}"
|
||||||
|
'PageUp' "${terminfo[kpp]}"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Bind the keys.
|
||||||
|
local key
|
||||||
|
for key (${(s: :)key_info[ControlLeft]}) bindkey ${key} backward-word
|
||||||
|
for key (${(s: :)key_info[ControlRight]}) bindkey ${key} forward-word
|
||||||
|
|
||||||
|
if [[ -n ${key_info[Home]} ]]; then
|
||||||
|
bindkey ${key_info[Home]} beginning-of-line
|
||||||
|
fi
|
||||||
|
if [[ -n ${key_info[End]} ]] bindkey ${key_info[End]} end-of-line
|
||||||
|
|
||||||
|
if [[ -n ${key_info[PageUp]} ]]; then
|
||||||
|
bindkey ${key_info[PageUp]} up-line-or-history
|
||||||
|
fi
|
||||||
|
if [[ -n ${key_info[PageDown]} ]]; then
|
||||||
|
bindkey ${key_info[PageDown]} down-line-or-history
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n ${key_info[Insert]} ]]; then
|
||||||
|
bindkey ${key_info[Insert]} overwrite-mode
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n ${key_info[Backspace]} ]]; then
|
||||||
|
bindkey ${key_info[Backspace]} backward-delete-char
|
||||||
|
fi
|
||||||
|
if [[ -n ${key_info[Delete]} ]] bindkey ${key_info[Delete]} delete-char
|
||||||
|
|
||||||
|
if [[ -n ${key_info[Left]} ]] bindkey ${key_info[Left]} backward-char
|
||||||
|
if [[ -n ${key_info[Right]} ]] bindkey ${key_info[Right]} forward-char
|
||||||
|
|
||||||
|
if [[ -n ${key_info[Up]} ]] bindkey ${key_info[Up]} history-search-backward
|
||||||
|
if [[ -n ${key_info[Down]} ]] bindkey ${key_info[Down]} history-search-forward
|
||||||
|
|
||||||
|
# Expandpace.
|
||||||
|
bindkey ' ' magic-space
|
||||||
|
|
||||||
|
# Clear.
|
||||||
|
bindkey "${key_info[Control]}L" clear-screen
|
||||||
|
|
||||||
|
# Bind <Shift-Tab> to go to the previous menu item.
|
||||||
|
if [[ -n ${key_info[BackTab]} ]]; then
|
||||||
|
bindkey ${key_info[BackTab]} reverse-menu-complete
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use smart URL pasting and escaping.
|
||||||
|
autoload -Uz bracketed-paste-url-magic \
|
||||||
|
&& zle -N bracketed-paste bracketed-paste-url-magic
|
||||||
|
autoload -Uz url-quote-magic && zle -N self-insert url-quote-magic
|
||||||
|
|
||||||
|
if zstyle -t ':zim:input' double-dot-expand; then
|
||||||
|
double-dot-expand() {
|
||||||
|
if [[ ${LBUFFER} == *.. ]]; then
|
||||||
|
LBUFFER+='/..'
|
||||||
|
else
|
||||||
|
LBUFFER+='.'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
zle -N double-dot-expand
|
||||||
|
bindkey '.' double-dot-expand
|
||||||
|
bindkey -M isearch '.' self-insert
|
||||||
|
fi
|
||||||
|
|
||||||
|
autoload -Uz is-at-least && if ! is-at-least 5.3; then
|
||||||
|
# Redisplay after completing, and avoid blank prompt after
|
||||||
|
# <Tab><Tab><Ctrl-C>
|
||||||
|
expand-or-complete-with-redisplay() {
|
||||||
|
print -Pn '...'
|
||||||
|
zle expand-or-complete
|
||||||
|
zle redisplay
|
||||||
|
}
|
||||||
|
zle -N expand-or-complete-with-redisplay
|
||||||
|
bindkey "${key_info[Control]}I" \
|
||||||
|
expand-or-complete-with-redisplay
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Put into application mode and validate ${terminfo}
|
||||||
|
zle-line-init() {
|
||||||
|
if (( ${+terminfo[smkx]} )) echoti smkx
|
||||||
|
}
|
||||||
|
zle-line-finish() {
|
||||||
|
if (( ${+terminfo[rmkx]} )) echoti rmkx
|
||||||
|
}
|
||||||
|
zle -N zle-line-init
|
||||||
|
zle -N zle-line-finish
|
||||||
|
}
|
||||||
|
|
||||||
|
# Color support
|
||||||
|
alias ls='ls --group-directories-first --color=auto'
|
||||||
|
alias grep='grep --color=auto'
|
||||||
|
|
||||||
|
# Grep in a directory
|
||||||
|
alias grepd='grep -rIin'
|
||||||
|
|
||||||
|
# List only directories and symbolic links that point to directories.
|
||||||
|
alias lsd='ls -ld *(-/DN)'
|
||||||
|
|
||||||
|
# List all files.
|
||||||
|
alias l='ls -lhA --time-style=long-iso'
|
||||||
|
alias ll='ls -lh --time-style=long-iso'
|
||||||
|
|
||||||
|
# Colored GCC warnings and errors
|
||||||
|
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;'\
|
||||||
|
'32:locus=01:quote=01'
|
||||||
|
|
||||||
|
# Recursively finds all occurrence that satisfies the given expression
|
||||||
|
f()
|
||||||
|
{
|
||||||
|
find . -iname "*${*}*"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Do not force window, useful for terminal use.
|
||||||
|
# TODO: Can it be turned into a config file instead?
|
||||||
|
alias mpv='mpv --force-window=no'
|
||||||
|
|
||||||
|
# Use clipboard selection instead of default primary.
|
||||||
|
alias xclip='xclip -selection clipboard'
|
||||||
|
|
||||||
|
# Ask before overwriting. Add a character to prove you are sure of your actions.
|
||||||
|
alias mvf=mv
|
||||||
|
alias mv='mv -i'
|
||||||
|
alias rmf=rm
|
||||||
|
alias rm='rm -i'
|
||||||
|
|
||||||
|
# I'd rather use nvim for everything.
|
||||||
|
alias vim=nvim
|
||||||
|
alias vimdiff='nvim -d'
|
||||||
|
|
||||||
|
# Recursively rsync the given path.
|
||||||
|
alias rsyncc='rsync --info=progress2 -avz'
|
||||||
|
|
||||||
|
# Download youtube playlist in a sorted manner
|
||||||
|
# TODO: update
|
||||||
|
alias youtube-dl-ordered='youtube-dl -i -o
|
||||||
|
"%(playlist_index)s-%(title)s.%(ext)s"'
|
||||||
|
|
||||||
|
# Open the todo.txt file
|
||||||
|
# This and track can be updated to use xdg documents path if others find them
|
||||||
|
# useful as well.
|
||||||
|
alias todo='$EDITOR ~/doc/txt/todo.txt'
|
||||||
|
|
||||||
|
# Load keyboard kernel object for colors and brightness control.
|
||||||
|
# TODO: Use the deb instead or dkms.
|
||||||
|
alias keyboard='cd ~/dev/github/tuxedo-keyboard/src; sudo insmod ./*.ko; cd'
|
||||||
|
|
||||||
|
# Switch to games-specific user fast.
|
||||||
|
alias vidya='xhost +si:localuser:vidya && sudo -u vidya -i'
|
||||||
|
|
||||||
|
# Switch 4k monitor resolution to 720p before switching to vidya then switching
|
||||||
|
# back to 4k after gaming is done.
|
||||||
|
alias steam='xrandr --output DP-1 --mode 1280x720 --rate 60; vidya;
|
||||||
|
xrandr --output DP-1 --mode 3840x2160 --rate 60'
|
||||||
|
|
||||||
|
# Prefer cantata-based radio to this
|
||||||
|
# Plays an online stream using mpv and records it.
|
||||||
|
# $1 Stream link.
|
||||||
|
# $2 File path.
|
||||||
|
radio()
|
||||||
|
{
|
||||||
|
curl -l "$1" | tee "$2" | mpv -
|
||||||
|
}
|
||||||
|
|
||||||
|
# Silly tracking.
|
||||||
|
track()
|
||||||
|
{
|
||||||
|
echo "$(date)> $1" >>~/doc/txt/log.txt
|
||||||
|
}
|
||||||
|
|
||||||
|
# Records microphone locally.
|
||||||
|
recordmic()
|
||||||
|
{
|
||||||
|
ffmpeg -f pulse -i alsa_input.pci-0000_00_1f.3.analog-stereo -f pulse \
|
||||||
|
-i alsa_output.pci-0000_00_1f.3.analog-stereo.monitor -map 0:0 \
|
||||||
|
-map 1:0 "$HOME/tv/record/$1.ogg"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Records audio output.
|
||||||
|
record()
|
||||||
|
{
|
||||||
|
ffmpeg -f pulse \
|
||||||
|
-i alsa_output.pci-0000_00_1f.3.analog-stereo.monitor -map 0:0 \
|
||||||
|
"$HOME/tv/record/$1.ogg"
|
||||||
|
}
|
||||||
|
|
||||||
|
# TODO: load dz keyboard layout properly using setxkbmap
|
||||||
|
# Maybe should be somewhere else e.g., .profile? or somewhere system-wide
|
||||||
|
|
||||||
|
export PATH="$HOME/.poetry/bin:$PATH"
|
20
nichijou/home/zsh.scm
Normal file
20
nichijou/home/zsh.scm
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
(define-module (nichijou home zsh)
|
||||||
|
#:use-module (gnu home services shells)
|
||||||
|
#:use-module (gnu services)
|
||||||
|
#:use-module (gnu packages shellutils)
|
||||||
|
#:use-module (gnu packages terminals)
|
||||||
|
#:use-module (guix gexp)
|
||||||
|
#:use-module (ice-9 optargs))
|
||||||
|
|
||||||
|
(define-public packages
|
||||||
|
(list zsh-syntax-highlighting zsh-autosuggestions fzf))
|
||||||
|
|
||||||
|
(define-public services
|
||||||
|
(list (service home-zsh-service-type
|
||||||
|
(home-zsh-configuration (xdg-flavor? #t)
|
||||||
|
(zprofile (list (local-file
|
||||||
|
"config/zsh/zprofile")))
|
||||||
|
(zlogout (list (local-file
|
||||||
|
"config/zsh/zlogout")))
|
||||||
|
(zshrc (list (local-file
|
||||||
|
"config/zsh/zshrc")))))))
|
Loading…
Reference in a new issue