···
zplug "plugins/systemd", from:oh-my-zsh
export SHELL=/usr/bin/zsh
···
# Automatically remove duplicates from these arrays
typeset -gU path cdpath manpath fpath
+
##############################################################################
+
##############################################################################
+
if [ -e "/etc/debian_version" ]; then
+
alias acs='sudo apt-cache search'
+
alias acp='sudo apt-cache policy'
+
alias agu='sudo apt update'
+
alias agud='sudo apt update && sudo apt dist-upgrade'
+
alias agi='sudo apt install'
+
alias afs='sudo apt-file search'
+
alias afu='sudo apt-file update'
+
alias aac='sudo apt autoclean'
+
alias agc='sudo apt clean'
+
alias agli='sudo apt list --installed'
+
alias agp='sudo apt purge'
+
alias agr='sudo apt remove'
+
alias agar='sudo apt autoremove'
+
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 dnfli='dnf list installed'
+
alias dnfmc='dnf makecache'
+
alias dnfr='sudo dnf remove'
+
alias dnfs='dnf search'
+
alias dnfu='sudo dnf update'
+
if test -f /bin/lsd; then
+
alias ls='ls --color=auto'
+
alias grep='grep --color'
+
# Prompt user before overwriting files
+
# Display zsh functions with bat
+
alias zfun='functions | bat -l zsh'
+
if command -v bat >/dev/null; then
+
# Assorted global aliases
+
alias -g L='| less -FRX'
+
alias -g CC='| xclip -selection clipboard'
+
# Get public IP address
+
alias pubip4='curl -s -m 5 ipv4.icanhazip.com'
+
alias pubip6='curl -s -m 5 ipv6.icanhazip.com'
+
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'
+
alias gcmsg='git commit -m'
+
alias grbi='git rebase -i'
+
alias grv='git remote -v'
+
##############################################################################
+
##############################################################################
+
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
+
## 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
+
if test -x "$(command -v gumssh)"; then
+
bindkey -s '^[s' 'gumssh^M'
+
if test -x "$(command -v yazi)"; then
+
bindkey -s '^[f' 'yazi^M'
+
## history substring search
+
bindkey '^[[1;5A' history-substring-search-up
+
bindkey '^[[1;5B' history-substring-search-down
+
##############################################################################
+
##############################################################################
+
# Command checker helper
+
test -x "$(command -v $1)"
+
## Nushell and jc functions
+
nu -c 'jc df | from json'
+
nu -c 'jc free | from json'
+
nu -c 'jc lsof -i | from json'
+
nu -c 'jc ss -tulp | from json'
+
nu -c 'sudo jc lsof -i | from json | find "LISTEN"'
+
# nushell: list sockets in use
+
nu -c 'sudo jc lsof -i -P | from json'
+
nu -c 'jc ping -c 3 $1 | from json'
+
nu -c 'jc ping -c 3 www.google.com | from json'
+
nu -c 'jc uptime | from json'
+
function os-release() {
+
cat /etc/os-release | nu -c 'jc --os-release | from json'
+
nu -c 'date now | format date "%FT%T%:z"'
+
# watch directory listing, update every 0.1s
+
watch -n0,1 "ls -lh $1/ | tail"
+
continent=$(find /usr/share/zoneinfo -maxdepth 1 -mindepth 1 -type d -not -name "posix" -not -name "right" -exec basename {} \; | gum choose --limit=1)
+
city=$(find "/usr/share/zoneinfo/$continent" -type f -exec basename {} \; | gum choose --limit=1)
+
TZ="$continent/$city" date
+
# Generate a pseudo-random 16-character string.
+
openssl rand -base64 16
+
# Remove ~/.ssh/known_hosts*
+
function rmknownhosts() {
+
rm -v "${HOME}/.ssh/known_hosts"*
+
# Copy SSH public key to clipboard (requires xclip -selection clipboard)
+
cat "${HOME}/.ssh/id_ed25519.pub" | tr -d '\n' | xclip -selection clipboard
+
echo "--> SSH public key copied to clipboard"
+
# Remove all .jpeg .jpg .png .svg .webp files from downloads
+
find "${HOME}/downloads" \
+
\( -name "*.jpg" -o -name "*.jpg_original" -o -name "*.jpeg" -o -name "*.svg" -o -name "*.png" -o -name "*.webp" \) \
+
# Remove all ISOs and disc images from downloads
+
find "${HOME}/downloads" \
+
\( -name "*.iso" -o -name "*.img" \) \
+
ansible-playbook -i inventory.yml "$@"
+
if ! test -f "${HOME}/.shellmarks"; then
+
touch "${HOME}/.shellmarks"
+
if grep -qxFe "${mark_to_add}" "${HOME}/.shellmarks"; then
+
"This bookmark already exists: ${mark_to_add}"
+
echo "${mark_to_add}" >> "${HOME}/.shellmarks"
+
--foreground "#73F59F" \
+
"${mark_to_add} added to shellmarks file"
+
/bin/cat "${HOME}/.shellmarks" | sort | tee "${HOME}/.shellmarks" >/dev/null
+
echo "# Shellmarks" | gum format
+
while IFS= read -r line; do
+
done < "${HOME}/.shellmarks" | gum format
+
selection=$(cat "${HOME}/.shellmarks" | gum choose --no-limit)
+
if test -n "${selection}"; then
+
perl -n -i -e "print unless /^\\Q${line//\//\\/}\\E\$/" "${HOME}/.shellmarks"
+
done <<< "${selection}"
+
gum format -t markdown -- \
+
"# The following bookmarks were deleted:" \
+
"$(printf "%s\n" "${selection}")"
+
if ! test -f "${HOME}/.shellmarks"; then
+
echo "No bookmarks exist yet. Add some!"
+
builtin cd $(cat "${HOME}/.shellmarks" | gum choose --limit=1 --height=20)
+
for precmd in $precmd_functions; do
+
zle && zle reset-prompt
+
# Choose a directory from the directory stack.
+
echo "# Choose a directory" | gum format -t markdown
+
selection=$(dirs -lp | gum choose --limit=1)
+
# Print timestamp as %Y-%m-%d %H:%M:%S.
+
date '+%Y-%m-%d %H:%M:%S' | tr -d '\n'
+
# Print timestamp as %Y-%m-%dT%H:%M:%S%:z
+
date '+%Y-%m-%dT%H:%M:%S%:z' | tr -d '\n'
+
# zrmcomp() remove *.zwc files.
+
for i in ${HOME}/*.zwc(N); do
+
# Invoke this every time you change .zshrc to recompile it.
+
[ -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
+
function cd() { builtin cd "$@" && ls; }
+
# Create new directory and enter it.
+
function mkd() { mkdir -p "$@" && cd "$_"; }
+
# Display pids of commands.
+
function pids() { pgrep -a "$@"; }
+
function restart() { exec $SHELL $SHELL_ARGS "$@"; }
+
# cd to ~, clear screen, and restart zsh.
+
function rsrc() { cd && clear && restart; }
+
# Usage: newfeelslog <tag0> <tag1> ... <tagN>
+
function newfeelslog() {
+
DATE=$(date '+%Y-%m-%d')
+
FEELSDIR="${HOME}/Nextcloud/sites/feels.hyperreal.coffee"
+
PREV_ENTRY=$(find "$FEELSDIR/src" -name "*.md" -exec basename {} \; | sort | tail -1 | cut -c 18-21)
+
NEXT_ENTRY="00$(echo "$PREV_ENTRY" + "1" | bc)"
+
NEXT_ENTRY_FILENAME="${FEELSDIR}/src/${DATE}-entry-${NEXT_ENTRY}.md"
+
cat <<EOF >"$NEXT_ENTRY_FILENAME"
+
title: Entry $NEXT_ENTRY
+
date: $(date '+%Y-%m-%d %H:%M:%S %z')
+
slug: entry-$NEXT_ENTRY
+
$EDITOR "$NEXT_ENTRY_FILENAME"
+
##############################################################################
+
##############################################################################
+
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
+
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'
+
export FZF_COMPLETION_TRIGGER="~~"
+
## default source for fzf
+
export FZF_DEFAULT_COMMAND="fd --type f --hidden --follow --exclude .git"
+
# CTRL-Y to copy the command into clipboard using wl-copy
+
export FZF_CTRL_R_OPTS="
+
--bind 'ctrl-y:execute-silent(echo -n {2..} | wl-copy)+abort'
+
--header 'Press CTRL-Y to copy command into clipboard'"
+
##############################################################################
+
##############################################################################
+
## 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.
+
# A builtin that can clone a running shell onto another terminal.
+
# 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.
+
# Allow comments even in interactive shells.
+
setopt interactivecomments
+
# Send *not* a HUP signal to running jobs when the shell exits.
+
# If a pattern for filename generation has no matches, delete the pattern from
+
# the argument list instead of reporting an error.
+
# Perform =filename access
+
# NOTE: It's not really needed because zsh sets the per default.
+
# Try to make completion list smaller by printing the matches in columns with
+
# Expands single letters and ranges of letters between braces
+
# $ 1a2 1b2 1w2 1y2 1z2
+
# 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
+
# Report the status of background and suspended jobs before exiting a shell
+
# with job control; a second attempt to exit the shell will succeed.
+
# Make cd push the old directory onto the directory stack.
+
# Change to directory without cd
+
# Query the user before executing 'rm *' or 'rm path/*'
+
# When writing out the history file, older commands that duplicate newer ones
+
# When searching for history entries in the line editor, do not display
+
# duplicates of a line previously found, even if the duplicates are not
+
# 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
+
setopt hist_ignore_all_dups
+
# Do not enter command lines into the history list if they are duplicates of
+
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
+
# 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
+
# 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
+
# 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.
+
# Do not require a leading '.' in a filename to be matched explicitly.
+
# List jobs in long format by default
+
# Don't push multiple copies of the same directory onto the directory staack.
+
# 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).
+
# Save each command's beginning timestamp (in seconds since the epoch)
+
# and the duration (in seconds) to the history file. The format of this
+
# ':<beginning time>:<elapsed seconds>;<command>'
+
# Do *not* run all background jobs at a lower nice priority
+
##############################################################################
+
# CATPPUCCIN SYNTAX HIGHLIGHTING
+
##############################################################################
+
# 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
+
ZSH_HIGHLIGHT_STYLES[comment]='fg=#585b70'
+
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'
+
ZSH_HIGHLIGHT_STYLES[builtin]='fg=#a6e3a1'
+
ZSH_HIGHLIGHT_STYLES[reserved-word]='fg=#a6e3a1'
+
ZSH_HIGHLIGHT_STYLES[hashed-command]='fg=#a6e3a1'
+
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
+
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=#eba0ac'
+
ZSH_HIGHLIGHT_STYLES[double-quoted-argument]='fg=#f9e2af'
+
ZSH_HIGHLIGHT_STYLES[double-quoted-argument-unclosed]='fg=#eba0ac'
+
ZSH_HIGHLIGHT_STYLES[rc-quote]='fg=#f9e2af'
+
ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]='fg=#cdd6f4'
+
ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument-unclosed]='fg=#eba0ac'
+
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=#eba0ac'
+
ZSH_HIGHLIGHT_STYLES[path]='fg=#cdd6f4,underline'
+
ZSH_HIGHLIGHT_STYLES[path_pathseparator]='fg=#f38ba8,underline'
+
ZSH_HIGHLIGHT_STYLES[path_prefix]='fg=#cdd6f4,underline'
+
ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]='fg=#f38ba8,underline'
+
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=#eba0ac'
+
ZSH_HIGHLIGHT_STYLES[redirection]='fg=#cdd6f4'
+
ZSH_HIGHLIGHT_STYLES[arg0]='fg=#cdd6f4'
+
ZSH_HIGHLIGHT_STYLES[default]='fg=#cdd6f4'
+
ZSH_HIGHLIGHT_STYLES[cursor]='fg=#cdd6f4'