From 3bff2a3234ee23c634a4150035cf1b2f2a79dc16 Mon Sep 17 00:00:00 2001 From: frosty Date: Mon, 29 Jul 2024 04:08:38 -0400 Subject: [PATCH] (zsh): add many aliases, include alias expansion, add extra dirs to PATH, other stuff --- .zprofile | 12 ++++++--- .zshrc | 78 +++++++++++++++++++++++++++++++++++-------------------- 2 files changed, 58 insertions(+), 32 deletions(-) diff --git a/.zprofile b/.zprofile index f606f5e..a235e78 100644 --- a/.zprofile +++ b/.zprofile @@ -1,4 +1,4 @@ -# shellcheck disable=SC2155 +# shellcheck shell=sh disable=SC1091 [ -f "$HOME/.zshrc" ] && . "$HOME/.zshrc" @@ -29,12 +29,16 @@ export CUDA_CACHE_PATH="$XDG_CACHE_HOME/nv" export SVDIR="$XDG_CONFIG_HOME/service" export PIPX_BIN_DIR="$XDG_DATA_HOME/pipx/bin" export _JAVA_OPTIONS="-Djava.util.prefs.userRoot=$XDG_CONFIG_HOME/java" +export XIDLEHOOK_SOCK="$XDG_STATE_HOME/xidlehook.sock" # $PATH additions -export PATH="$PATH:$(find "$HOME/.local/bin/" -type d | paste -sd ':' -)" -export PATH="$PATH:$GOPATH/bin" -export PATH="$PATH:$XDG_DATA_HOME/pipx/bin" +export PATH="$PATH:$HOME/.local/bin" +export PATH="$PATH:$HOME/.local/bin/screenlayouts" +export PATH="$PATH:$HOME/.ghcup/bin" export PATH="$PATH:$HOME/.cabal/bin" +export PATH="$PATH:$PIPX_BIN_DIR" +export PATH="$PATH:$GOPATH/bin" +export PATH="$PATH:$CARGO_HOME/bin" export PATH="$PATH:$XDG_DATA_HOME/npm/bin" # Automatic graphical start on tty1 diff --git a/.zshrc b/.zshrc index 8328980..dc3042f 100644 --- a/.zshrc +++ b/.zshrc @@ -3,48 +3,70 @@ case "$-" in *) return ;; esac -[ -f "$HOME/.ghcup/env" ] && . "$HOME/.ghcup/env" +# Completion options +autoload -Uz compinit && compinit -d "$XDG_CACHE_HOME/zsh/zcompdump" +zstyle ':completion:*' completer _expand_alias _complete _ignored -export HISTFILE="$XDG_STATE_HOME/zsh/history" +## History options ## +HISTSIZE=100000 +HISTFILESIZE="$HISTSIZE" -export HISTSIZE=100000 -export HISTFILESIZE="$HISTSIZE" - -setopt EXTENDED_HISTORY -setopt SHARE_HISTORY -setopt HIST_EXPIRE_DUPS_FIRST -setopt HIST_SAVE_NO_DUPS -setopt HIST_VERIFY -setopt APPEND_HISTORY -setopt HIST_NO_STORE - -alias v='nvim' -alias vim='nvim' - -alias ll='ls -lAF' -alias la='ls -AF' +setopt autocd +setopt promptsubst +# Default options alias cp='cp -iv' alias mv='mv -iv' alias rm='rm -vI' alias mkdir='mkdir -pv' -alias ls='ls --color=auto' +alias ls='ls --color=auto -AF' alias grep='grep --color=auto' -alias wget="wget --hsts-file='$XDG_DATA_HOME/wget-hsts'" +alias wget='wget --no-hsts-file' +cd() { + builtin cd "$@" && ls +} +# Public and private IP addresses alias ipp='curl https://ipinfo.io/ip && echo' alias ipl='monitors local_ip' -## Initialization ## +# Shorthands +alias l='ls' +alias c='cd' +alias v='nvim' +alias vim='nvim' +alias g='git' +alias ff='fastfetch' +alias fetch='fastfetch' -PROMPT=$'%{\e[1;32m%}%n@%M%{\e[1;34m%} %~ %%%{\e[0m%} ' +# Other options or commands +alias ll='ls -l' +alias ga='git add' +alias gc='git commit' +alias gs='git status' +alias gp='git push' +alias gl='git pull' -clear -fastfetch +parse_git_branch() { + command -v git >/dev/null 2>&1 || return -if [ -d "${XDG_DATA_HOME:-$HOME/.local/share}/zsh/plugins" ]; then - for plugin in "${XDG_DATA_HOME:-$HOME/.local/share}"/zsh/plugins/*/*.plugin.zsh; do - . "$plugin" + git_branch=$(git branch --no-color 2>/dev/null) + [ -z "$git_branch" ] && return + is_dirty=$(git status --porcelain 2>/dev/null) + [ -n "$is_dirty" ] && color="red" || color="magenta" + + printf '%s' " %F{${color}}${git_branch#* }" +} + +## Prompts ## +PROMPT=" +%F{green}%n@%M %F{blue}%~\$(parse_git_branch) %F{reset}%% " +RPROMPT='%F{white}%*%F{reset}' + +## External loading ## +if [ -d "$XDG_DATA_HOME/zsh/plugins" ]; then + for p in "$XDG_DATA_HOME"/zsh/plugins/*/*.plugin.zsh; do + . "$p" done - unset plugin + unset p fi