mirror of
https://codeberg.org/hyperreal/dotfiles
synced 2024-11-01 16:53:07 +01:00
Add zsh-server
This commit is contained in:
parent
1d4e2a3e77
commit
3fd2076664
@ -64,7 +64,7 @@ max_width = 100
|
||||
# An empty value means the code will find the default downloads folder for your system.
|
||||
# If the path does not exist it will be created.
|
||||
# Note the use of single quotes, so that backslashes will not be escaped.
|
||||
downloads = '/var/home/jas/downloads'
|
||||
downloads = '/home/jas/downloads'
|
||||
|
||||
# Max size for displayable content in bytes - after that size a download window pops up
|
||||
page_max_size = 2097152 # 2 MiB
|
||||
|
28
zsh-server/.zpath
Normal file
28
zsh-server/.zpath
Normal file
@ -0,0 +1,28 @@
|
||||
# PATH variable declaration as array
|
||||
# -U means unique, which tells the shell not to add anything to the array if it's
|
||||
# already there.
|
||||
typeset -U PATH path
|
||||
|
||||
# Add /usr/local dirs to PATH
|
||||
path=("/usr/local/bin" "/usr/local/sbin")
|
||||
path+=("/bin" "/sbin" "/usr/bin" "/usr/sbin")
|
||||
|
||||
# Set Go path if it exists
|
||||
[ -d "${HOME}/go" ] && GOPATH="${HOME}/go" && path+=("${GOPATH}/bin")
|
||||
|
||||
# Set Cargo path for Rust binaries
|
||||
[ -d "${HOME}/.cargo/bin" ] && path+=("${HOME}/.cargo/bin")
|
||||
|
||||
# Add ~/bin to PATH
|
||||
[ -d "${HOME}/bin" ] && path+=("${HOME}/bin")
|
||||
|
||||
# Add ~/.local/bin to PATH
|
||||
[ -d "${HOME}/.local/bin" ] && path+=("${HOME}/.local/bin")
|
||||
|
||||
# Add /snap/bin to PATH
|
||||
[ -d "/snap/bin" ] && path+=("/snap/bin")
|
||||
|
||||
export PATH
|
||||
|
||||
# Automatically remove duplicates from these arrays
|
||||
typeset -gU path cdpath manpath fpath
|
23
zsh-server/.zshenv
Normal file
23
zsh-server/.zshenv
Normal file
@ -0,0 +1,23 @@
|
||||
#
|
||||
# Generic .zshenv file for zsh
|
||||
#
|
||||
# .zshenv is sourced on ALL invocations of the shell, unless the -f option is
|
||||
# set. It should NOT normally contain commands to set the command search path,
|
||||
# or other common environment variables unless you really know what you're
|
||||
# doing. E.g. running "PATH=/custom/path gdb program" sources this file (when
|
||||
# gdb runs the program via $SHELL), so you want to be sure not to override a
|
||||
# custom environment in such cases. Note also that .zshenv should not contain
|
||||
# commands that produce output or assume the shell is attached to a tty.
|
||||
#
|
||||
|
||||
# Some people insist on setting their PATH here to affect things like ssh.
|
||||
# Those that do should probably use $SHLVL to ensure that this only happens
|
||||
# the first time the shell is started (to avoid overriding a customized
|
||||
# environment). Also, the various profile/rc/login files all get sourced
|
||||
# *after* this file, so they will override this value. One solution is to
|
||||
# put your path-setting code into a file named .zpath, and source it from
|
||||
# both here (if we're not a login shell) and from the .zprofile file (which
|
||||
# is only sourced if we are a login shell).
|
||||
if [[ $SHLVL == 1 ]]; then
|
||||
source ~/.zpath
|
||||
fi
|
162
zsh-server/.zshrc
Normal file
162
zsh-server/.zshrc
Normal file
@ -0,0 +1,162 @@
|
||||
# Filename : ~/.zshrc
|
||||
# Purpose : setup file for zsh
|
||||
# Author : Jeffrey Serio <hyperreal@fedoraproject.org>
|
||||
# Homepage : https://hyperreal.coffee
|
||||
#
|
||||
# Zsh Manual - https://zsh-manual.netlify.app
|
||||
# Zsh Guide - https://zsh-guide.netlify.app
|
||||
#
|
||||
# ,----[ man -k zsh ]
|
||||
# |
|
||||
# | zsh (1) - the Z shell
|
||||
# | zshall (1) - the Z shell meta-man page
|
||||
# | zshbuiltins (1) - zsh builtin commands
|
||||
# | zshcalsys (1) - zsh calendar system
|
||||
# | zshcompctl (1) - zsh programmable completion
|
||||
# | zshcompsys (1) - zsh completion system
|
||||
# | zshcompwid (1) - zsh completion widgets
|
||||
# | zshcontrib (1) - user contributions to zsh
|
||||
# | zshexpn (1) - zsh expansion and substitution
|
||||
# | zshmisc (1) - everything and then some
|
||||
# | zshmodules (1) - zsh loadable modules
|
||||
# | zshoptions (1) - zsh options
|
||||
# | zshparam (1) - zsh parameters
|
||||
# | zshroadmap (1) - informal introduction to the zsh manual
|
||||
# | zshtcpsys (1) - zsh tcp system
|
||||
# | zshzftpsys (1) - zftp function front-end
|
||||
# | zshzle (1) - zsh command line editor
|
||||
# `----
|
||||
#
|
||||
# Zsh startup sequence
|
||||
# 1) /etc/zshenv -> Always run for every zsh. (login + interactive + other)
|
||||
# 2) ~/.zshenv -> Usually run for every zsh. (login + interactive + other)
|
||||
# 3) /etc/zprofile -> Run for login shells. (login)
|
||||
# 4) ~/.zprofile -> Run for login shells. (login)
|
||||
# 5) /etc/zshrc -> Run for interactive shells. (login + interactive)
|
||||
# 6) ~/.zshrc -> Run for interactive shells. (login + interactive)
|
||||
# 7) /etc/zlogin -> Run for login shells. (login)
|
||||
# 8) ~/.zlogin -> Run for login shells. (login)
|
||||
#
|
||||
# This file is based on Christian Schneider's zsh configuration
|
||||
# https://www.strcat.de/dotfiles
|
||||
|
||||
# Plugins
|
||||
if ! test -f ~/.zplug/init.zsh; then
|
||||
export ZPLUG_HOME=~/.zplug
|
||||
git clone https://github.com/zplug/zplug $ZPLUG_HOME
|
||||
fi
|
||||
|
||||
source ~/.zplug/init.zsh
|
||||
|
||||
# Use autosuggestions when typing commands
|
||||
zplug "zsh-users/zsh-autosuggestions"
|
||||
|
||||
# Use a keybinding to complete parts of command from the history file
|
||||
zplug "zsh-users/zsh-history-substring-search"
|
||||
|
||||
# Use syntax highlighting when typing commands
|
||||
zplug "zsh-users/zsh-syntax-highlighting", defer:2
|
||||
|
||||
# Press escape twice to prepend `sudo` to the command line
|
||||
zplug "plugins/sudo", from:oh-my-zsh
|
||||
|
||||
# extract archives
|
||||
zplug "plugins/extract", from:oh-my-zsh
|
||||
|
||||
# LXD completions
|
||||
zplug "plugins/lxd", from:oh-my-zsh
|
||||
|
||||
# systemd aliases
|
||||
zplug "plugins/systemd", from:oh-my-zsh
|
||||
|
||||
# Load file from ~/.zshrc.d
|
||||
zplug "~/.zshrc.d", from:local, use:'*'
|
||||
|
||||
# starship.rs
|
||||
eval "$(starship init zsh)"
|
||||
|
||||
if ! zplug check; then
|
||||
zplug install;
|
||||
exec $SHELL $SHELL_ARGS "$@"
|
||||
fi
|
||||
|
||||
zplug load
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# ENVIRONMENT VARS
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
export LS_COLORS=$(cat ~/.lscolors.sh)
|
||||
export PAGER="less -X"
|
||||
export MANWIDTH="88"
|
||||
export MANROFFOPT="-c"
|
||||
export MANPAGER="less -X"
|
||||
|
||||
export EDITOR="vim"
|
||||
|
||||
# Have less display colours
|
||||
# from: https://wiki.archlinux.org/index.php/Color_output_in_console#man
|
||||
export LESS_TERMCAP_mb=$'\e[1;31m' # begin bold
|
||||
export LESS_TERMCAP_md=$'\e[1;34m' # begin blink
|
||||
export LESS_TERMCAP_so=$'\e[01;0;33m' # begin reverse video
|
||||
export LESS_TERMCAP_us=$'\e[01;31m' # begin underline
|
||||
export LESS_TERMCAP_me=$'\e[0m' # reset bold/blink
|
||||
export LESS_TERMCAP_se=$'\e[0m' # reset reverse video
|
||||
export LESS_TERMCAP_ue=$'\e[0m' # reset underline
|
||||
export GROFF_NO_SGR=1 # for konsole and gnome-terminal
|
||||
|
||||
# Cargo/Rust
|
||||
[[ -f "${HOME}/.cargo/env" ]] && source "${HOME}/.cargo/env"
|
||||
|
||||
# Format of process time reports with 'time'
|
||||
# %% A '%'
|
||||
# %U CPU seconds spent in user mode
|
||||
# %S CPU seconds spent in kernel mode
|
||||
# %E Elapsed time in seconds
|
||||
# %P CPU percentage, computed as (%U+%S)/%E
|
||||
# %J The name of this job
|
||||
# Default is:
|
||||
# %E real %U user %S system %P %J
|
||||
TIMEFMT="\
|
||||
|
||||
The name of this job : %J
|
||||
CPU seconds spent in user mode : %U
|
||||
CPU seconds spent in kernel mode : %S
|
||||
Elapsed time in seconds : %E
|
||||
CPU percentage : %P"
|
||||
|
||||
# HISTSIZE is the number of lines of history that is kept within any given
|
||||
# running zsh instance. SAVEHIST is the number of lines of history that is
|
||||
# written out to the HISTFILE when that event occurs. If you use the
|
||||
# HIST_EXPIRE_DUPS_FIRST option, setting this value larger than the SAVEHIST
|
||||
# size will give you the difference as a cushion for saving duplicated history
|
||||
# events.
|
||||
HISTSIZE=100000
|
||||
SAVEHIST=65536
|
||||
|
||||
# Name of the file used to store command history
|
||||
HISTFILE=~/.zsh_history
|
||||
|
||||
# If nonnegative, commands whose combined user and system execution times
|
||||
# (measured in seconds) are greater than this value have timing stats printed
|
||||
# for them.
|
||||
REPORTTIME=10
|
||||
|
||||
# reply-to email address
|
||||
export REPLYTO="hyperreal@fedoraproject.org"
|
||||
|
||||
# Language
|
||||
export LANG="en_US.UTF-8"
|
||||
|
||||
# Manpages
|
||||
export MANPATH="${MANPATH:-/usr/share/man:/usr/local/share/man}"
|
||||
|
||||
if [ -d "${HOME}/.fzf/man" ]; then
|
||||
export MANPATH="${MANPATH}:${HOME}/.fzf/man"
|
||||
fi
|
||||
|
||||
# Bat theme
|
||||
export BAT_THEME="Catppuccin-mocha"
|
||||
|
||||
# Automatically remove duplicates from these arrays
|
||||
typeset -gU path cdpath manpath fpath
|
145
zsh-server/.zshrc.d/aliases.zsh
Normal file
145
zsh-server/.zshrc.d/aliases.zsh
Normal file
@ -0,0 +1,145 @@
|
||||
# Get top 10 shell commands
|
||||
alias top10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
|
||||
|
||||
# history mechanism
|
||||
alias h='history'
|
||||
|
||||
# Aliases for APT
|
||||
if [ -e "/etc/debian_version" ]; then
|
||||
alias acs="sudo apt-cache search"
|
||||
alias acp="sudo apt-cache policy"
|
||||
alias afs="sudo apt-file search"
|
||||
alias afu="sudo apt-file update"
|
||||
alias aac="sudo apt autoclean"
|
||||
alias agc="sudo apt clean"
|
||||
alias agi="sudo apt install"
|
||||
alias agli="sudo apt list --installed"
|
||||
alias agp="sudo apt purge"
|
||||
alias agr="sudo apt remove"
|
||||
alias agu="sudo apt update"
|
||||
alias agud="sudo apt update && sudo apt dist-upgrade"
|
||||
alias agar="sudo apt autoremove"
|
||||
fi
|
||||
|
||||
if [ -e "/etc/redhat-release" ]; then
|
||||
alias dnfc='sudo dnf clean all'
|
||||
alias dnfgi='sudo dnf groupinstall'
|
||||
alias dnfgl='dnf grouplist'
|
||||
alias dnfgr='sudo dnf groupremove'
|
||||
alias dnfi='sudo dnf install'
|
||||
alias dnfl='dnf list'
|
||||
alias dnfli='dnf list installed'
|
||||
alias dnfmc='dnf makecache'
|
||||
alias dnfp='dnf info'
|
||||
alias dnfr='sudo dnf remove'
|
||||
alias dnfs='dnf search'
|
||||
alias dnfu='sudo dnf update'
|
||||
fi
|
||||
|
||||
# Convert UPPER to lower (or back)
|
||||
alias UP2low='for i in *(.); mv $i ${i:l}'
|
||||
alias low2UP='for i in *(.); mv $i ${i:u}'
|
||||
|
||||
# The ls family
|
||||
if test -x "$(command -v exa)"; then
|
||||
alias ls='exa'
|
||||
else
|
||||
alias ls='ls --color=auto'
|
||||
fi
|
||||
|
||||
alias l='ls -lFhg'
|
||||
alias la='ls -a'
|
||||
alias ll='ls -l'
|
||||
alias lal='ls -al'
|
||||
alias ldot='ls -gld .*'
|
||||
alias lse='/bin/ls -lZ'
|
||||
|
||||
# greps
|
||||
alias grep='grep --color'
|
||||
alias sgrep='grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS}'
|
||||
|
||||
# Copy SSH public key to clipboard (requires xclip or xsel)
|
||||
if test -x "$(command -v xclip)"; then
|
||||
alias pubkey='more ~/.ssh/id_ed25519.pub | xclip -selection clipboard | echo "SSH public key copied"'
|
||||
fi
|
||||
|
||||
# Prompt user before overwriting files
|
||||
alias cp='cp -i'
|
||||
alias mv='mv -i'
|
||||
alias rm='trash'
|
||||
alias del='rm -i'
|
||||
|
||||
# Display zsh functions with bat
|
||||
alias zfun='functions | bat -l zsh'
|
||||
|
||||
# Assorted global aliases
|
||||
alias -g H='| head'
|
||||
alias -g T='| tail'
|
||||
alias -g G='| grep'
|
||||
alias -g L='| less -X'
|
||||
alias -g B='| bat'
|
||||
alias -g LL='2>&1 | less'
|
||||
alias -g NE='2> /dev/null'
|
||||
alias -g NUL='> /dev/null 2>&1'
|
||||
alias -g P='2>&1| pygmentize -l pytb'
|
||||
alias -g J='| jq'
|
||||
alias -g CC='| xclip -selection clipboard'
|
||||
alias -g C='| wc -l'
|
||||
alias -g SS='| sort'
|
||||
alias -g Su='| sort -u'
|
||||
alias -g Sn='| sort -n'
|
||||
alias -g Snr='| sort -nr'
|
||||
|
||||
# Get public IP address
|
||||
alias pubip='curl ipinfo.io'
|
||||
|
||||
# List apps with network connections
|
||||
alias netCons='lsof -i'
|
||||
|
||||
# List ports
|
||||
alias tulp='ss -tulp'
|
||||
|
||||
# List open ports
|
||||
alias openPorts='sudo lsof -i | grep LISTEN'
|
||||
|
||||
# Ping google.com
|
||||
alias pong='ping -c 3 www.google.com'
|
||||
|
||||
# List sockets in use
|
||||
alias lsock='sudo lsof -i -P'
|
||||
|
||||
# List UDP sockets in use
|
||||
alias lsockU='sudo lsof -nP | grep UDP'
|
||||
|
||||
# List TCP sockets in use
|
||||
alias lsockT='sudo lsof -nP | grep TCP'
|
||||
|
||||
# Reboot / Poweroff
|
||||
alias rbt='sudo systemctl reboot'
|
||||
alias shut='sudo systemctl poweroff'
|
||||
|
||||
# GPG
|
||||
alias gpgs='gpg --search-keys'
|
||||
alias gpgl='gpg --list-keys --with-fingerprint'
|
||||
|
||||
# firewalld
|
||||
if test -x "$(command -v firewall-cmd)"; then
|
||||
alias fw='sudo firewall-cmd'
|
||||
alias fwp='sudo firewall-cmd --permanent'
|
||||
alias fwr='sudo firewall-cmd --reload'
|
||||
alias fwrp='sudo firewall-cmd --runtime-to-permanent'
|
||||
fi
|
||||
|
||||
# git
|
||||
alias ga='git add'
|
||||
alias gcl='git clone'
|
||||
alias gcmsg='git commit -m'
|
||||
alias gd='git diff'
|
||||
alias gl='git pull'
|
||||
alias gp='git push'
|
||||
alias gr='git remote'
|
||||
alias grbi='git rebase -i'
|
||||
alias grm='git rm'
|
||||
alias grv='git remote -v'
|
||||
alias gst='git status'
|
||||
|
32
zsh-server/.zshrc.d/bindings.zsh
Normal file
32
zsh-server/.zshrc.d/bindings.zsh
Normal file
@ -0,0 +1,32 @@
|
||||
typeset -g -A key
|
||||
|
||||
key[Home]="${terminfo[khome]}"
|
||||
key[End]="${terminfo[kend]}"
|
||||
|
||||
[[ -n "${key[Home]}" ]] && bindkey -- "${key[Home]}" beginning-of-line
|
||||
[[ -n "${key[End]}" ]] && bindkey -- "${key[End]}" end-of-line
|
||||
|
||||
if (( ${+terminfo[smkx]} && ${+terminfo[rmkx]} )); then
|
||||
autoload -Uz add-zle-hook-widget
|
||||
function zle_application_mode_start { echoti smkx }
|
||||
function zle_application_mode_stop { echoti rmkx }
|
||||
add-zle-hook-widget -Uz zle-line-init zle_application_mode_start
|
||||
add-zle-hook-widget -Uz zle-line-finish zle_application_mode_stop
|
||||
fi
|
||||
|
||||
## keybinding for convenient viewing of man pages
|
||||
if test -x "${HOME}/bin/split_man"; then
|
||||
split_man-widget() { "${HOME}/bin/split_man"}
|
||||
zle -N split_man-widget
|
||||
|
||||
bindkey '^[m' split_man-widget
|
||||
fi
|
||||
|
||||
## gumssh
|
||||
if test -x "${HOME}/bin/gumssh"; then
|
||||
bindkey -s '^[s' 'gumssh^M'
|
||||
fi
|
||||
|
||||
## history substring search
|
||||
bindkey '^[[1;5A' history-substring-search-up
|
||||
bindkey '^[[1;5B' history-substring-search-down
|
@ -0,0 +1,74 @@
|
||||
# Catppuccin Mocha Theme (for zsh-syntax-highlighting)
|
||||
#
|
||||
# Paste this files contents inside your ~/.zshrc before you activate zsh-syntax-highlighting
|
||||
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main cursor)
|
||||
typeset -gA ZSH_HIGHLIGHT_STYLES
|
||||
|
||||
# Main highlighter styling: https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/main.md
|
||||
#
|
||||
## General
|
||||
### Diffs
|
||||
### Markup
|
||||
## Classes
|
||||
## Comments
|
||||
ZSH_HIGHLIGHT_STYLES[comment]='fg=#585b70'
|
||||
## Constants
|
||||
## Entitites
|
||||
## Functions/methods
|
||||
ZSH_HIGHLIGHT_STYLES[alias]='fg=#a6e3a1'
|
||||
ZSH_HIGHLIGHT_STYLES[suffix-alias]='fg=#a6e3a1'
|
||||
ZSH_HIGHLIGHT_STYLES[global-alias]='fg=#a6e3a1'
|
||||
ZSH_HIGHLIGHT_STYLES[function]='fg=#a6e3a1'
|
||||
ZSH_HIGHLIGHT_STYLES[command]='fg=#a6e3a1'
|
||||
ZSH_HIGHLIGHT_STYLES[precommand]='fg=#a6e3a1,italic'
|
||||
ZSH_HIGHLIGHT_STYLES[autodirectory]='fg=#fab387,italic'
|
||||
ZSH_HIGHLIGHT_STYLES[single-hyphen-option]='fg=#fab387'
|
||||
ZSH_HIGHLIGHT_STYLES[double-hyphen-option]='fg=#fab387'
|
||||
ZSH_HIGHLIGHT_STYLES[back-quoted-argument]='fg=#cba6f7'
|
||||
## Keywords
|
||||
## Built ins
|
||||
ZSH_HIGHLIGHT_STYLES[builtin]='fg=#a6e3a1'
|
||||
ZSH_HIGHLIGHT_STYLES[reserved-word]='fg=#a6e3a1'
|
||||
ZSH_HIGHLIGHT_STYLES[hashed-command]='fg=#a6e3a1'
|
||||
## Punctuation
|
||||
ZSH_HIGHLIGHT_STYLES[commandseparator]='fg=#f38ba8'
|
||||
ZSH_HIGHLIGHT_STYLES[command-substitution-delimiter]='fg=#cdd6f4'
|
||||
ZSH_HIGHLIGHT_STYLES[command-substitution-delimiter-unquoted]='fg=#cdd6f4'
|
||||
ZSH_HIGHLIGHT_STYLES[process-substitution-delimiter]='fg=#cdd6f4'
|
||||
ZSH_HIGHLIGHT_STYLES[back-quoted-argument-delimiter]='fg=#f38ba8'
|
||||
ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]='fg=#f38ba8'
|
||||
ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]='fg=#f38ba8'
|
||||
## Serializable / Configuration Languages
|
||||
## Storage
|
||||
## Strings
|
||||
ZSH_HIGHLIGHT_STYLES[command-substitution-quoted]='fg=#f9e2af'
|
||||
ZSH_HIGHLIGHT_STYLES[command-substitution-delimiter-quoted]='fg=#f9e2af'
|
||||
ZSH_HIGHLIGHT_STYLES[single-quoted-argument]='fg=#f9e2af'
|
||||
ZSH_HIGHLIGHT_STYLES[single-quoted-argument-unclosed]='fg=#e64553'
|
||||
ZSH_HIGHLIGHT_STYLES[double-quoted-argument]='fg=#f9e2af'
|
||||
ZSH_HIGHLIGHT_STYLES[double-quoted-argument-unclosed]='fg=#e64553'
|
||||
ZSH_HIGHLIGHT_STYLES[rc-quote]='fg=#f9e2af'
|
||||
## Variables
|
||||
ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]='fg=#cdd6f4'
|
||||
ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument-unclosed]='fg=#e64553'
|
||||
ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]='fg=#cdd6f4'
|
||||
ZSH_HIGHLIGHT_STYLES[assign]='fg=#cdd6f4'
|
||||
ZSH_HIGHLIGHT_STYLES[named-fd]='fg=#cdd6f4'
|
||||
ZSH_HIGHLIGHT_STYLES[numeric-fd]='fg=#cdd6f4'
|
||||
## No category relevant in spec
|
||||
ZSH_HIGHLIGHT_STYLES[unknown-token]='fg=#e64553'
|
||||
ZSH_HIGHLIGHT_STYLES[path]='fg=#cdd6f4,underline'
|
||||
ZSH_HIGHLIGHT_STYLES[path_pathseparator]='fg=#f38ba8'
|
||||
ZSH_HIGHLIGHT_STYLES[path_prefix]='fg=#cdd6f4,underline'
|
||||
ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]='fg=#f38ba8'
|
||||
ZSH_HIGHLIGHT_STYLES[globbing]='fg=#cdd6f4'
|
||||
ZSH_HIGHLIGHT_STYLES[history-expansion]='fg=#cba6f7'
|
||||
#ZSH_HIGHLIGHT_STYLES[command-substitution]='fg=?'
|
||||
#ZSH_HIGHLIGHT_STYLES[command-substitution-unquoted]='fg=?'
|
||||
#ZSH_HIGHLIGHT_STYLES[process-substitution]='fg=?'
|
||||
#ZSH_HIGHLIGHT_STYLES[arithmetic-expansion]='fg=?'
|
||||
ZSH_HIGHLIGHT_STYLES[back-quoted-argument-unclosed]='fg=#e64553'
|
||||
ZSH_HIGHLIGHT_STYLES[redirection]='fg=#cdd6f4'
|
||||
ZSH_HIGHLIGHT_STYLES[arg0]='fg=#cdd6f4'
|
||||
ZSH_HIGHLIGHT_STYLES[default]='fg=#cdd6f4'
|
||||
ZSH_HIGHLIGHT_STYLES[cursor]='fg=#cdd6f4'
|
127
zsh-server/.zshrc.d/functions.zsh
Normal file
127
zsh-server/.zshrc.d/functions.zsh
Normal file
@ -0,0 +1,127 @@
|
||||
# Create a bookmark.
|
||||
function mark() {
|
||||
|
||||
if ! test -f "${HOME}/.shellmarks"; then
|
||||
touch "${HOME}/.shellmarks"
|
||||
fi
|
||||
|
||||
mark_to_add="$(pwd)"
|
||||
|
||||
if grep -qxFe "${mark_to_add}" "${HOME}/.shellmarks"; then
|
||||
gum style \
|
||||
--foreground 210 \
|
||||
--margin "1 2" \
|
||||
"This bookmark already exists: ${mark_to_add}"
|
||||
else
|
||||
echo "${mark_to_add}" >> "${HOME}/.shellmarks"
|
||||
gum style \
|
||||
--foreground "#73F59F" \
|
||||
--margin "1 2" \
|
||||
"${mark_to_add} added to shellmarks file"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Remove bookmarks.
|
||||
function delmark() {
|
||||
selection=$(cat "${HOME}/.shellmarks" | gum choose --no-limit)
|
||||
|
||||
if test -n "${selection}"; then
|
||||
while read -r line; do
|
||||
perl -n -i -e "print unless /^\\Q${line//\//\\/}\\E\$/" "${HOME}/.shellmarks"
|
||||
done <<< "${selection}"
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
|
||||
gum format -t markdown -- \
|
||||
"# The following bookmarks were deleted:" \
|
||||
"$(printf "%s\n" "${selection}")"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Goto a bookmark.
|
||||
function gotomark() {
|
||||
if ! test -f "${HOME}/.shellmarks"; then
|
||||
echo "No bookmarks exist yet. Add some!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo
|
||||
builtin cd $(cat "${HOME}/.shellmarks" | gum choose --limit=1)
|
||||
|
||||
local precmd
|
||||
for precmd in $precmd_functions; do
|
||||
$precmd
|
||||
done
|
||||
zle && zle reset-prompt
|
||||
}
|
||||
zle -N gotomark
|
||||
bindkey '^[g' gotomark
|
||||
|
||||
# Choose a directory from the directory stack.
|
||||
function dstack() {
|
||||
echo "# Choose a directory" | gum format -t markdown
|
||||
selection=$(dirs -lp | gum choose --limit=1)
|
||||
cd $selection
|
||||
}
|
||||
|
||||
# Print timestamp as %Y-%m-%d %H:%M:%S.
|
||||
function tstamp() {
|
||||
emulate -L zsh
|
||||
date '+%Y-%m-%d %H:%M:%S'
|
||||
}
|
||||
|
||||
# Print timestamp as %Y-%m-%dT%H:%M:%S%:z
|
||||
function tstampz() {
|
||||
emulate -L zsh
|
||||
date '+%Y-%m-%dT%H:%M:%S%:z'
|
||||
}
|
||||
|
||||
# Create a /overview/ of all available function()'s; the description for
|
||||
# each funtion() *must* be the first line above the string `function'!
|
||||
# Otherwise it wont work.
|
||||
# Display all function()'s with their descriptions.
|
||||
function funlist() {
|
||||
grep -B 1 "^function" $HOME/.zshrc.d/functions.zsh | \
|
||||
grep -v "^\-\-$" | \
|
||||
awk '{ if(/^#/) { gsub(/^#[:space:]*/, ""); ht=$0 }; getline; gsub(/ ?\(\)/, ":"); printf("-> %-20s %s\n", $2, ht); }' | \
|
||||
sort -u -k 3
|
||||
}
|
||||
|
||||
# zrmcomp() remove *.zwc files.
|
||||
function zrmcomp() {
|
||||
local i
|
||||
for i in ${HOME}/*.zwc(N); do
|
||||
printf "Removing $i\n"
|
||||
command rm -f $i
|
||||
done
|
||||
}
|
||||
|
||||
# Invoke this every time you change .zshrc to recompile it.
|
||||
function src() {
|
||||
autoload -U zrecompile
|
||||
[ -f ~/.zshrc ] && zrecompile -p ~/.zshrc
|
||||
[ -f ~/.zcompdump ] && zrecompile -p ~/.zcompdump
|
||||
[ -f ~/.zcompdump ] && zrecompile -p ~/.zcompdump
|
||||
[ -f ~/.zshrc.zwc.old ] && command rm -f ~/.zshrc.zwc.old
|
||||
[ -f ~/.zcompdump.zwc.old ] && command rm -f ~/.zcompdump.zwc.old
|
||||
source ~/.zshrc
|
||||
}
|
||||
|
||||
# Do an ls after cd.
|
||||
function cd() { builtin cd "$@" && ls; }
|
||||
|
||||
# Create new directory and enter it.
|
||||
function mkd() { mkdir -p "$@" && cd "$_"; }
|
||||
|
||||
# Display pids of commands.
|
||||
function pids() { pgrep -a "$@"; }
|
||||
|
||||
# Restart zsh.
|
||||
function restart() { exec $SHELL $SHELL_ARGS "$@"; }
|
||||
|
||||
# cd to ~, clear screen, and restart zsh.
|
||||
function rsrc() { cd && clear && restart; }
|
12
zsh-server/.zshrc.d/fzf.zsh
Normal file
12
zsh-server/.zshrc.d/fzf.zsh
Normal file
@ -0,0 +1,12 @@
|
||||
# ~/.zshrc.d/fzf.zsh
|
||||
|
||||
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
|
||||
|
||||
## default opts uses Catppuccin (mocha) color palette
|
||||
export FZF_DEFAULT_OPTS='--color=bg+:#302D41,bg:#1E1E2E,spinner:#F8BD96,hl:#F28FAD --color=fg:#D9E0EE,header:#F28FAD,info:#DDB6F2,pointer:#F8BD96 --color=marker:#F8BD96,fg+:#F2CDCD,prompt:#DDB6F2,hl+:#F28FAD'
|
||||
|
||||
## completion trigger
|
||||
export FZF_COMPLETION_TRIGGER="~~"
|
||||
|
||||
## default source for fzf
|
||||
export FZF_DEFAULT_COMMAND="fd --type f --hidden --follow --exclude .git"
|
151
zsh-server/.zshrc.d/options.zsh
Normal file
151
zsh-server/.zshrc.d/options.zsh
Normal file
@ -0,0 +1,151 @@
|
||||
## General shell options
|
||||
# See https://zsh-manual.netlify.app/options
|
||||
|
||||
# This is a multiple move based on zsh pattern matching (like "mmv").
|
||||
# Read ``less ${^fpath}/zmv(N)'' for more details.
|
||||
autoload zmv
|
||||
|
||||
# A builtin that can clone a running shell onto another terminal.
|
||||
zmodload -e zsh/clone
|
||||
|
||||
# When listing options (by 'setopt', 'unsetopt', 'set -o', or 'set +o'),
|
||||
# those turned on by default appear in the list prefixed with 'no'.
|
||||
# Hence (unless KSH_OPTION_PRINT is set), 'setopt' shows all options whose
|
||||
# settings are changed from default.
|
||||
#
|
||||
# Report the status of background jobs immediately, rather than waiting until
|
||||
# just before printing a prompt.
|
||||
setopt notify
|
||||
|
||||
# Allow comments even in interactive shells.
|
||||
setopt interactivecomments
|
||||
|
||||
# Send *not* a HUP signal to running jobs when the shell exits.
|
||||
setopt nohup
|
||||
|
||||
# If a pattern for filename generation has no matches, delete the pattern from
|
||||
# the argument list instead of reporting an error.
|
||||
# Overrides NOMATCH
|
||||
setopt nullglob
|
||||
|
||||
# Perform =filename access
|
||||
# $ setopt EQUALS
|
||||
# $ echo =ls
|
||||
# /bin/ls
|
||||
# $ unsetopt EQUALS
|
||||
# $ echo =ls
|
||||
# =ls
|
||||
# NOTE: It's not really needed because zsh sets the per default.
|
||||
setopt equals
|
||||
|
||||
# Try to make completion list smaller by printing the matches in columns with
|
||||
# different widths.
|
||||
setopt list_packed
|
||||
|
||||
# Expands single letters and ranges of letters between braces
|
||||
# $ print 1{abw-z}2
|
||||
# $ 1a2 1b2 1w2 1y2 1z2
|
||||
setopt braceccl
|
||||
|
||||
# If the argument to a cd command (or an implied cd with the AUTO_CD option
|
||||
# set) is not a directory, and does not begin with a slash, try to expand the
|
||||
# expression as if it were preceded by a '~' (See section 14.7 Filename
|
||||
# Expansion).
|
||||
setopt cdablevars
|
||||
|
||||
# Report the status of background and suspended jobs before exiting a shell
|
||||
# with job control; a second attempt to exit the shell will succeed.
|
||||
setopt checkjobs
|
||||
|
||||
# Make cd push the old directory onto the directory stack.
|
||||
setopt autopushd
|
||||
|
||||
# Change to directory without cd
|
||||
setopt autocd
|
||||
|
||||
# Query the user before executing 'rm *' or 'rm path/*'
|
||||
setopt normstarsilent
|
||||
setopt no_rm_star_wait
|
||||
|
||||
# Shaddapa you face
|
||||
setopt nobeep
|
||||
|
||||
# When writing out the history file, older commands that duplicate newer ones
|
||||
# are omitted.
|
||||
set histsavenodups
|
||||
|
||||
# When searching for history entries in the line editor, do not display
|
||||
# duplicates of a line previously found, even if the duplicates are not
|
||||
# contiguous.
|
||||
setopt histfindnodups
|
||||
|
||||
# If the internal history needs to be trimmed to add the current command line,
|
||||
# setting this option will cause the oldest history event that has a duplicate
|
||||
# to be lost before losing a unique event from the list.
|
||||
setopt hist_expire_dups_first
|
||||
|
||||
# If a new command line being added to the history list duplicates an older
|
||||
# one, the older command is removed from the list (even if it is not the
|
||||
# previous event).
|
||||
setopt hist_ignore_all_dups
|
||||
|
||||
# Do not enter command lines into the history list if they are duplicates of
|
||||
# the previous event.
|
||||
setopt hist_ignore_dups
|
||||
|
||||
# Remove superfluous blanks from each command line being added to history.
|
||||
setopt hist_reduce_blanks
|
||||
|
||||
# Whenever the user enters a line with history expansion, don't execute the
|
||||
# line directly; instead, perform history expansion and reload the line into
|
||||
# the editing buffer.
|
||||
setopt hist_verify
|
||||
|
||||
# Do not remove function definitions from the history list.
|
||||
unsetopt hist_no_functions
|
||||
|
||||
# Remove the history (fc -l) command from the history list when invoked.
|
||||
# Note that the command lingers in the internal history until the next command
|
||||
# is entered before it vanishes, allowing you to briefly reuse or edit the
|
||||
# line.
|
||||
setopt hist_no_store
|
||||
|
||||
# If this is set, zsh sessions will append their history list to the history
|
||||
# file, rather than overwrite it. Thus, multiple parallel zsh sessions will all
|
||||
# have their history lists added to the history file, in the order they are
|
||||
# killed.
|
||||
setopt appendhistory
|
||||
|
||||
# If unset, the cursor is set to the end of the word if completion is started.
|
||||
# Otherwise, it stays there and completion is done from both ends.
|
||||
unsetopt completeinword
|
||||
|
||||
# When listing files that are possible completions, show the type of each file
|
||||
# with a trailing identifying mark.
|
||||
setopt listtypes
|
||||
|
||||
# Do not require a leading '.' in a filename to be matched explicitly.
|
||||
setopt globdots
|
||||
|
||||
# List jobs in long format by default
|
||||
setopt longlistjobs
|
||||
|
||||
# Don't push multiple copies of the same directory onto the directory staack.
|
||||
setopt pushdignoredups
|
||||
|
||||
# This option both imports new commands from the history file, and also causes
|
||||
# your typed commands to be appended to the history file (the latter is like
|
||||
# specifying INC_APPEND_HISTORY).
|
||||
# The history lines are also output with timestamps ala EXTENDED_HISTORY
|
||||
# (which makes it easier to find the spot where we left off reading the file
|
||||
# after it gets re-written).
|
||||
setopt sharehistory
|
||||
|
||||
# Save each command's beginning timestamp (in seconds since the epoch)
|
||||
# and the duration (in seconds) to the history file. The format of this
|
||||
# prefixed data is:
|
||||
# ':<beginning time>:<elapsed seconds>;<command>'
|
||||
setopt extendedhistory
|
||||
|
||||
# Do *not* run all background jobs at a lower nice priority
|
||||
unsetopt bgnice
|
Loading…
Reference in New Issue
Block a user