zsh: major reorganization

This commit is contained in:
PowerUser64 2022-03-18 17:50:20 -07:00
parent aa32e9ba63
commit 990f4cd542
4 changed files with 276 additions and 352 deletions

121
.config/shell/aliases Normal file
View file

@ -0,0 +1,121 @@
#!/bin/sh
## Short hand programs (ex: sc = shellcheck) >>>
# use nvim rather than vim if the command exists
alias \
vim='nvim' \
vimdiff='nvim -d'
alias \
vv="$EDITOR" \
e="$EDITOR" \
sedit='sudoedit' \
# I do this too much by accident smh my head
alias :q='exit' \
q='exit' \
# rmdir is long
alias \
rmd='rmdir' \
rd='rmdir' \
alias \
mkd="mkdir -p" \
g=git \
sctl='sudo systemctl' \
# <<<
## Program improvements (ex: ls = ls -h) >>>
alias sudo='sudo ' # allow using aliases in sudo commands
alias df='df -h' # Human-readable sizes
alias free='free -m' # Show sizes in MB
alias bc='bc -ql' # Make bc usable for fast math
[ -z "$VIMRUNTIME" ] &&
alias glow='glow -p' # force Glow to preview with `less` if not in vim
# I hate it when I get ghost script instead of git status. this will be removed
alias gs="echo 'you don'\''t really want ghost script, do you?'"
# tell make to use all cpu cores
alias make='make -j$(nproc)'
# Colors
alias \
ls='ls -hN --color=auto --group-directories-first' \
grep='grep --color=auto' \
diff='diff --color=auto' \
pacman='pacman --color=auto' \
parue='/usr/bin/paru --color=auto --sudoloop --newsonupgrade --pgpfetch --upgrademenu --bottomup --fm nvim' \
paru='parue --skipreview' \
command -v lsd > /dev/null && alias \
ls=lsd \
lsd='lsd --group-dirs=first' \
# <<<
## Mini short-hand scripts (ex: glone = git clone) >>>
# dotfile management
alias dot='git --git-dir="$HOME/git/dotfiles" --work-tree="$HOME"'
alias d='git --git-dir="$HOME/git/dotfiles" --work-tree="$HOME"' # duplicate for auto-complete
# quicker shutdown
alias sdn='shutdown now'
# open a new session called 0, but if there is already a session called 0, connect to it
alias tm='tmux new -As0'
# List available X displays. Useful for finding what display to export when connected over ssh.
alias lsx='ls /tmp/.X11-unix | tr "X" ":"'
# Make ydotool actually usable for short things
alias ydotool='(sudo ydotoold &) && sleep 0.05 && sudo ydotool'
# Update zinit and plugins
alias zup='zinit self-update && zinit update --parallel'
# Edit config files
alias \
nvc='(cd ~/.config/nvim/lua/blake && nvim ../../init.lua)' \
zc='$EDITOR ~/.zshrc' \
fstab='sudoedit /etc/fstab' \
hst='$EDITOR $HISTFILE' \
# Git cLONE
alias glone="git clone"
# Docker
alias \
logs='docker-compose logs --tail=200 -f' \
dupd='docker-compose up -d' \
ddwn='docker-compose down' \
dc='docker-compose' \
occ='docker exec -u www-data nextcloud php occ' \
# file copying with a progress bar
alias cpv="rsync -ah --info=progress2"
# lists all open ports, along with some other info
alias ls-ports='netstat -tulpn'
# list all disks and their mount points
alias mnt="mount | awk -F' ' '{ printf \"%s\t%s\n\",\$1,\$3; }' | column -t | grep -E '^/dev/' | sort"
# backs up list of packages
alias packback='comm -23 <(paru -Qqett | sort) <(paru -Qqg base -g base-devel | sort | uniq) > ~/pkglist.txt'
# thoroughly reset the terminal
alias rce='reset && clear && exec zsh'
# find pretty much any file, quickly
alias fds='fd --hidden --exclude /run'
# smart plug things
SMART_PLUG_IP='192.168.1.250'
alias light='tplink_smartplug.py -t $SMART_PLUG_IP -c'
# Common ls aliases
alias \
l=ls \
la='ls -ah' \
ll='ls -lh' \
lla='ls -lah' \

48
.config/shell/env Normal file
View file

@ -0,0 +1,48 @@
# Blake's environment variables
# This file should be compatible with standard sh
# Intelligently set $EDITOR
if command -v nvim > /dev/null;then
export EDITOR=nvim
elif command -v vim > /dev/null;then
export EDITOR=vim
elif command -v vi > /dev/null;then
export EDITOR=vi
fi
export SHELL_CONFIG_DIR="${SHELL_CONFIG_DIR:-"${XDG_CONFIG_HOME:-$HOME/.config}/shell"}"
export PATH="$PATH:${XDG_DATA_HOME:-$HOME/.local}/bin:$SHELL_CONFIG_DIR/bin"
export SYSTEMD_EDITOR="$EDITOR"
export LSCOLORS="Gxfxcxdxbxegedabagacad"
export ZSH_CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/zsh"
# Don't add extra space to the right side of the prompt
export ZLE_RPROMPT_INDENT=0
export ZINIT_HOME_DIR="${XDG_DATA_HOME:-$HOME/.local}/share/zinit"
# Set documents directory (auto set to the repo the file ~/todo points to is in)
# shellcheck disable=SC2155
[ -h ~/todo ] && export DOCS_DIR="$(git -C "$(dirname "$(realpath ~/todo)" 2>&1)" rev-parse --show-toplevel | head -1)"
WORKING_DIR_SAVE_FILE="${XDG_CACHE_HOME:-$HOME/.cache}/zsh/last-working-dir"
# make the dir for the file if needed
! test -d "$(dirname "$WORKING_DIR_SAVE_FILE")" && mkdir -p "$(dirname "$WORKING_DIR_SAVE_FILE")"
# Plugin setting >>>
# ZSH Vi Mode
export ZVM_VI_HIGHLIGHT_FOREGROUND=#BBC2CF
export ZVM_VI_HIGHLIGHT_BACKGROUND=#515860
# ZVM_VI_HIGHLIGHT_EXTRASTYLE=bold,underline # bold and underline
# OMZ Completion
export COMPLETION_WAITING_DOTS=true
# Powerlevel 10k
export POWERLEVEL9K_DISABLE_CONFIGURATION_WIZARD="${POWERLEVEL9K_DISABLE_CONFIGURATION_WIZARD:-true}"
export POWERLEVEL9K_INSTANT_PROMPT=quiet
export P10K_CONFIG_LOCATION="$SHELL_CONFIG_DIR/p10k/current"
# <<<
# vim:fdm=marker:fmr=>>>,<<<:et:ft=sh:sw=3

9
.config/shell/updates Executable file
View file

@ -0,0 +1,9 @@
#!/bin/sh
# This file is provided to ensure smooth updates between versions of these
# dotfiles. It is to be run after environment variables are set whenever the
# shell starts, and should be compatible with standard `sh`.
# [3-18-22] Move Powerlevel 10k config file out of home directory
if [ -f ~/.p10k.zsh ] && ! [ -f "$P10K_CONFIG_LOCATION" ]; then
mv ~/.p10k.zsh "$P10K_CONFIG_LOCATION"
fi