From d448a66cef95deb0323c5906ad4335f3f30758f7 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 20 Jul 2021 23:10:46 +0200 Subject: [PATCH 1/6] Use ternary conditionals --- home/.config/shell/functions | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/home/.config/shell/functions b/home/.config/shell/functions index ae08476..ac35195 100755 --- a/home/.config/shell/functions +++ b/home/.config/shell/functions @@ -272,11 +272,12 @@ function anonymize { OLD_LINE="%F{047}%n%f %F{027}" - if [ -z "$MACHINE" ]; then - NEW_LINE="${NAME_COLOR}${NAME}%f ${DIR_COLOR}" - else - NEW_LINE="${NAME_COLOR}${NAME}${AT_COLOR}@${MACHINE_COLOR}${MACHINE}%f ${DIR_COLOR}" - fi + + [ -n "$NAME" ] && NEW_LINE="${NAME_COLOR}${NAME}" + [ -n "$NAME" ] && [ -n "$MACHINE" ] && NEW_LINE="${NEW_LINE}${AT_COLOR}@" + [ -n "$MACHINE" ] && NEW_LINE="${NEW_LINE}${MACHINE_COLOR}${MACHINE}" + [ -n "$NAME" ] || [ -n "$MACHINE" ] && NEW_LINE="${NEW_LINE}%f " + NEW_LINE="${NEW_LINE}${DIR_COLOR}" # Use new anonymized name, machine and colors in PS1 PS1=${PS1/"$OLD_LINE"/"$NEW_LINE"} From 1005ca83562f9f92f36283f9dd150fc6d80e7093 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 20 Jul 2021 23:11:18 +0200 Subject: [PATCH 2/6] Update kybinds --- home/.config/shell/keybinds | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/.config/shell/keybinds b/home/.config/shell/keybinds index 8b10f0a..284df26 100755 --- a/home/.config/shell/keybinds +++ b/home/.config/shell/keybinds @@ -51,7 +51,7 @@ bindkey '^[[1;5C' forward-word bindkey '^[[1;5D' backward-word # [Ctrl-r] - Search backward incrementally for a specified string. The string may begin with ^ to anchor the search to the beginning of the line. -bindkey '^r' history-incremental-search-backward +bindkey '^r' history-incremental-search-backward # [PageUp] - Up a line of history [[ -n "${terminfo[kpp]}" ]] && bindkey "${terminfo[kpp]}" up-line-or-history # [PageDown] - Down a line of history From 8566d2cfc9c061f910680d03875f16115ce8ae39 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 20 Jul 2021 23:18:50 +0200 Subject: [PATCH 3/6] Use .zshenv to define env vars, not .zprofile --- home/.config/shell/aliases | 7 ++-- home/.config/shell/environment | 64 ++++++++++++++++++++++++++++++ home/.config/shell/profile | 72 +++------------------------------- home/.config/zsh/.zprofile | 1 + home/.config/zsh/.zshenv | 1 + home/.zprofile | 1 - home/.zshenv | 1 + 7 files changed, 76 insertions(+), 71 deletions(-) create mode 100755 home/.config/shell/environment create mode 120000 home/.config/zsh/.zprofile create mode 120000 home/.config/zsh/.zshenv delete mode 120000 home/.zprofile create mode 120000 home/.zshenv diff --git a/home/.config/shell/aliases b/home/.config/shell/aliases index ac28d7e..0c32987 100755 --- a/home/.config/shell/aliases +++ b/home/.config/shell/aliases @@ -56,12 +56,13 @@ fi # Config access shortcuts alias cfzsh='vim ~/.config/zsh/.zshrc' -alias cfvim='vim ~/.config/nvim/init.vim' -alias cfnvim='cfvim' +alias cfnvim='vim ~/.config/nvim/init.vim' +alias cfvim='cfnvim' alias cfalias='vim ~/.config/shell/aliases' alias cffunctions='vim ~/.config/shell/functions' alias cfprofile='vim ~/.config/shell/profile' -alias cfxdg='cfenviron' +alias cfenvironment='vim ~/.config/shell/environment' +alias cfenv='cfenvironment' alias cfhandlers='vim ~/.config/shell/handlers' alias cfprompt='vim ~/.config/shell/prompt' alias cfkeybinds='vim ~/.config/shell/keybinds' diff --git a/home/.config/shell/environment b/home/.config/shell/environment new file mode 100755 index 0000000..776f34d --- /dev/null +++ b/home/.config/shell/environment @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Environmental variable definitions. +# This file is only sourced once after login, unlike .zshrc/.bashrc +# +# NOTE: This file shouldn't be defined for root account. Sudo +# will not source it (and neither will it source .zshrc/.zprofile), +# which means the XDG definitions will be ignored anyway, and +# defining them may break programs when root is actually logged in. + + +# Default programs +export EDITOR="nvim" +export BROWSER="firefox" +export TERMINAL="Alacrity" + +# Add all ~/.local/bin folders to PATH +PATH+=":${$(find ~/.local/bin -type d | tr '\n' ':')%%:}" + +# XDG Standard paths +export XDG_CONFIG_HOME="$HOME/.config" +export XDG_CACHE_HOME="$HOME/.cache" +export XDG_DATA_HOME="$HOME/.local/share" +export XDG_RUNTIME_DIR="/run/user/$UID" + +# Pre-Application XDG settings +export ZDOTDIR="$XDG_CONFIG_HOME/zsh" +export XINITRC="$XDG_CONFIG_HOME/x11/xinitrc" +#export XAUTHORITY="$XDG_RUNTIME_DIR/Xauthority" # This line will break some DMs. +export LESSHISTFILE="-" +export GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc" +export WGETRC="$XDG_CONFIG_HOME/wget/wgetrc" +export GNUPGHOME="$XDG_DATA_HOME/gnupg" +# Less commonly used applications +export _ZL_DATA="$XDG_DATA_HOME/zlua" +export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME/npm/npmrc" +export SQLITE_HISTORY="$XDG_DATA_HOME/sqlite_history" +export WAKATIME_HOME="$XDG_CONFIG_HOME/wakatime" +export GOPATH="$XDG_DATA_HOME/go" +export IPYTHONDIR="$XDG_CONFIG_HOME/ipython" +#export PYLINTHOME="$XDG_CACHE_HOME/pylint" +#export DOCKER_CONFIG="$XDG_CONFIG_HOME/docker" +#export CUDA_CACHE_PATH="$XDG_CACHE_HOME/nv" +#export _JAVA_OPTIONS="-Djava.util.prefs.userRoot=$XDG_CONFIG_HOME/java" + +# Colorful man pages +# If bat is installed, use it as manpager +if command -v bat > /dev/null; then + export MANPAGER="sh -c 'col -bx | bat -l man -p'" +else + export LESS_TERMCAP_mb="$(printf '%b' '[1;31m')" + export LESS_TERMCAP_md="$(printf '%b' '[1;36m')" + export LESS_TERMCAP_me="$(printf '%b' '[0m')" + export LESS_TERMCAP_so="$(printf '%b' '[01;44;33m')" + export LESS_TERMCAP_se="$(printf '%b' '[0m')" + export LESS_TERMCAP_us="$(printf '%b' '[1;32m')" + export LESS_TERMCAP_ue="$(printf '%b' '[0m')" +fi + +# Other program settings +export SUDO_ASKPASS="$HOME/.local/bin/scripts/dmenu/dmenupass" +export PIPENV_VENV_IN_PROJECT=1 # Force pipenv to create new environments within projects ./.venv +#export QT_QPA_PLATFORMTHEME="gtk2" # Have QT use gtk2 theme. + diff --git a/home/.config/shell/profile b/home/.config/shell/profile index 819729d..8287c3b 100755 --- a/home/.config/shell/profile +++ b/home/.config/shell/profile @@ -1,75 +1,13 @@ -#!/usr/bin/env bash +#!/bin/sh # User .profile definition. -# This file is only sourced after login, whereas .bashrc/.zshrc -# files will run every time a new terminal is open -# -# NOTE: This file shouldn't be defined for root account. Sudo -# will not source it (and neither will it source .zshrc), -# which means the XDG definitions will be ignored anyway, and -# defining them may break programs when root is actually logged in. +# This file is only sourced once, after login, Unlike +# .zshrc/.bashrc, which will run whenever a new terminal +# is opened. -# Default programs -export EDITOR="nvim" -export BROWSER="firefox" -export TERMINAL="Alacrity" - -# Add all ~/.local/bin folders to PATH -PATH+=":${$(find ~/.local/bin -type d | tr '\n' ':')%%:}" - -# XDG Standard paths -export XDG_CONFIG_HOME="$HOME/.config" -export XDG_CACHE_HOME="$HOME/.cache" -export XDG_DATA_HOME="$HOME/.local/share" -export XDG_RUNTIME_DIR="/run/user/$UID" - -# Pre-Application XDG settings -export ZDOTDIR="$XDG_CONFIG_HOME/zsh" -export XINITRC="$XDG_CONFIG_HOME/x11/xinitrc" -#export XAUTHORITY="$XDG_RUNTIME_DIR/Xauthority" # This line will break some DMs. -export LESSHISTFILE="-" -export GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc" -export WGETRC="$XDG_CONFIG_HOME/wget/wgetrc" -export GNUPGHOME="$XDG_DATA_HOME/gnupg" -# Less commonly used applications -export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME/npm/npmrc" -export SQLITE_HISTORY="$XDG_DATA_HOME/sqlite_history" -export WAKATIME_HOME="$XDG_CONFIG_HOME/wakatime" -export GOPATH="$XDG_DATA_HOME/go" -export IPYTHONDIR="$XDG_CONFIG_HOME/ipython" -#export DOCKER_CONFIG="$XDG_CONFIG_HOME/docker" -#export CUDA_CACHE_PATH="$XDG_CACHE_HOME/nv" -#export _JAVA_OPTIONS="-Djava.util.prefs.userRoot=$XDG_CONFIG_HOME/java" -#export PYLINTHOME="$XDG_CACHE_HOME/pylint" -#export MYSQL_HISTFILE="$XDG_DATA_HOME/mysql_history" -#export PSQLRC="$XDG_CONFIG_HOME/pg/psqlrc" -#export PSQL_HISTORY="$XDG_CACHE_HOME/pg/psql_history" -#export PGPASSFILE="$XDG_CONFIG_HOME/pg/pgpass" -#export PGSERVICEFILE="$XDG_CONFIG_HOME/pg/pg_service.conf" -#export NUGET_PACKAGES="$XDG_CACHE_HOME"/NuGetPackages - -# Colorful man pages -# If bat is installed, use it as manpager -if command -v bat > /dev/null; then - export MANPAGER="sh -c 'col -bx | bat -l man -p'" -else - export LESS_TERMCAP_mb="$(printf '%b' '[1;31m')" - export LESS_TERMCAP_md="$(printf '%b' '[1;36m')" - export LESS_TERMCAP_me="$(printf '%b' '[0m')" - export LESS_TERMCAP_so="$(printf '%b' '[01;44;33m')" - export LESS_TERMCAP_se="$(printf '%b' '[0m')" - export LESS_TERMCAP_us="$(printf '%b' '[1;32m')" - export LESS_TERMCAP_ue="$(printf '%b' '[0m')" -fi - -# Other program settings -export SUDO_ASKPASS="$HOME/.local/bin/scripts/dmenu/dmenupass" -export PIPENV_VENV_IN_PROJECT=1 # Force pipenv to create new environments within projects ./.venv -#export QT_QPA_PLATFORMTHEME="gtk2" # Have QT use gtk2 theme. - # Start graphical session automatically on tty1 if startx is aviable -if [ "$(tty)" = "/dev/tty1" ]; then +if [ "$(tty)" = "/dev/tty1" ] && [ "$UID" != 0 ]; then if command -v startx > /dev/null; then ! pidof -s Xorg > /dev/null 2>&1 && exec startx "$XINITRC" fi diff --git a/home/.config/zsh/.zprofile b/home/.config/zsh/.zprofile new file mode 120000 index 0000000..5046066 --- /dev/null +++ b/home/.config/zsh/.zprofile @@ -0,0 +1 @@ +../shell/profile \ No newline at end of file diff --git a/home/.config/zsh/.zshenv b/home/.config/zsh/.zshenv new file mode 120000 index 0000000..d8e764c --- /dev/null +++ b/home/.config/zsh/.zshenv @@ -0,0 +1 @@ +../shell/environment \ No newline at end of file diff --git a/home/.zprofile b/home/.zprofile deleted file mode 120000 index 8486fca..0000000 --- a/home/.zprofile +++ /dev/null @@ -1 +0,0 @@ -.config/shell/profile \ No newline at end of file diff --git a/home/.zshenv b/home/.zshenv new file mode 120000 index 0000000..9fbf4d2 --- /dev/null +++ b/home/.zshenv @@ -0,0 +1 @@ +.config/zsh/.zshenv \ No newline at end of file From 93bde27829ca05618319bef0bd938f6f7f3d9ea4 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 20 Jul 2021 23:19:17 +0200 Subject: [PATCH 4/6] Remove pacman aliases --- home/.config/shell/aliases | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/home/.config/shell/aliases b/home/.config/shell/aliases index 0c32987..75ed8d6 100755 --- a/home/.config/shell/aliases +++ b/home/.config/shell/aliases @@ -195,36 +195,6 @@ alias gundo='git reset HEAD~' alias gredo="git reset 'HEAD@{1}'" alias gundopush="git push -f origin HEAD^:master" -# Pacman aliases (using pacman directly would be faster, but I have goldfish memory) -alias pac-pkgs='pacman -Q' # List all packages on the system -alias pac-installed-pkgs='pacman -Qe' # Only list explicitly installed packages -alias pac-aur-pkgs='pacman -Qm' # Not necessarely AUR, but generally foreign (not in sync db) -alias pac-orphan-pkgs='pacman -Qdt' # Packages without any packages that depend on them -alias pac-rm-orphans='pacman -Rns $(pacman -Qdtq)' # Remove all orphaned packages -alias pac-search='pacman -Ss' # Lookup package by name from sync database -alias pac-search-local='pacman -Qs' # Lookup package by name from local database -alias pac-info='pacman -Qi' # Show detailed info about a local package -alias pac-info-remote='pacman -Si' # Show detailed info about a package in sync db -alias pac-download-upgrades='pacman -Syyuw' # Download all upgradeable packages, but don't upgrade -alias pac-extract='pacman -Syw --cachedir .' # Download given package to current directory -alias pac-cache-clean='pacman -Sc' # Remove all old packages in pacman cache -alias pac-file-owner='pacman -F' # Look in the sync db and check what package owns given filei -alias pac-file-owner-regex='pacman -Fx' # Same as above, but works with partial names or regex patterns -alias pac-file-owner-local='pacman -Qo' # Look in the local index and find which packge given file belongs to -alias pac-owned-files='pacman -Fl' # Show all files owned by given package from sync db -alias pac-owned-files-local='pacman -Ql' # Same as above, but for locally installed packages -alias pac-count-files='pacman -Qk' # Print amount of owned files, with the amount of missing files -alias pac-group-packages='pacman -Sg' # List all packages which will be installed with a group -alias pac-group-packages-local='pacman -Qg' # Only list locally installed packages from given group -alias vuln='arch-audit' # Show vulnerable packages that can be upgraded (Arch Linux) -alias vuln-upgrade="pacman -Sy \"\$(arch-audit --upgradable --quiet | awk '{sub(/>=.+/, \"\"); print}' | paste -s -d ' ')\"" # Upgrade all vulnerable packages, with released fixes - -# Get fastest mirrors (using reflector) -alias mirror="sudo reflector -f 30 -l 30 --number 10 --verbose --save /etc/pacman.d/mirrorlist" -alias mirrord="sudo reflector --latest 50 --number 20 --sort delay --save /etc/pacman.d/mirrorlist" -alias mirrors="sudo reflector --latest 50 --number 20 --sort score --save /etc/pacman.d/mirrorlist" -alias mirrora="sudo reflector --latest 50 --number 20 --sort age --save /etc/pacman.d/mirrorlist" - # Youtube-dl aliases alias ytv-best='youtube-dl -f bestvideo+bestaudio' alias yta-best='youtube-dl --extract-audio --audio-format best' From 54742fcd93670cf356e12e8c438b0cc5c997481f Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 20 Jul 2021 23:19:46 +0200 Subject: [PATCH 5/6] Add kernel aliases --- home/.config/shell/aliases | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/home/.config/shell/aliases b/home/.config/shell/aliases index 75ed8d6..8f94f85 100755 --- a/home/.config/shell/aliases +++ b/home/.config/shell/aliases @@ -132,6 +132,11 @@ alias iptlistout='iptables -L OUTPUT -n -v --line-numbers' # OUT rules alias iptlistfw='iptables -L FORWARD -n -v --line-numbers' # FORWARD rules alias ufw-log='journalctl -f -n 100 -g ufw' # Show UFW log entries in system journal +# Kernel actions +alias kernel-recompile='cd /usr/src/linux && make -j7 && make -j7 modules_install && make install' +alias kernel-oldconfig='cd /usr/src/linux && make oldconfig' +alias kernel-configure='cd /usr/src/linux && make menuconfig' + # System actions alias sv='systemctl' alias backup="rsync -avHAXS --delete --filter='dir-merge /.rsync-filter'" # Make full rsync backup, respecting .rsync-filter files for exclusions From 36fc25b4ee6833ec4b8c4842bab142eac1899341 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 20 Jul 2021 23:20:18 +0200 Subject: [PATCH 6/6] Add z.lua aliases --- home/.config/shell/aliases | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/home/.config/shell/aliases b/home/.config/shell/aliases index 8f94f85..6cd5c21 100755 --- a/home/.config/shell/aliases +++ b/home/.config/shell/aliases @@ -17,6 +17,11 @@ alias .2='cd ../../' alias .3='cd ../../../' alias .4='cd ../../../../' alias .5='cd ../../../../../' +# z.lua script +alias zz='z -c' # restrict matches to subdirs of $PWD +alias zb='z -b' # restrict matches to parent directories +alias zi='z -I' # cd with interactive fzf selection +alias zbi='z -b -I' # pick parent directory to cd into with fzf # Files/Directories utilities alias mkdir='mkdir -p'