diff options
author | Benjamin Chausse <benjamin@chausse.xyz> | 2024-05-12 03:27:14 -0400 |
---|---|---|
committer | Benjamin Chausse <benjamin@chausse.xyz> | 2024-05-12 03:27:14 -0400 |
commit | e53ab0e7e1f4b04e2339b5452e13df7081f0d189 (patch) | |
tree | 0b68d696a0fb98ed86b38e6e6ec664794052ae00 | |
parent | f9e97c28c63f0a47922defb4b99765ea381fb35c (diff) |
POSIX profile
-rwxr-xr-x | .config/lf/lfrc | 2 | ||||
-rw-r--r-- | .config/wget/wgetrc | 1 | ||||
-rw-r--r-- | .config/x11/xinitrc (renamed from .xinitrc) | 0 | ||||
-rw-r--r-- | .config/zsh/.zshrc | 18 | ||||
-rwxr-xr-x | .local/bin/shortcutgen | 75 | ||||
-rw-r--r-- | .profile | 103 |
6 files changed, 120 insertions, 79 deletions
diff --git a/.config/lf/lfrc b/.config/lf/lfrc index bc2c0e0..b6c80a8 100755 --- a/.config/lf/lfrc +++ b/.config/lf/lfrc @@ -16,6 +16,7 @@ # called directly instead of normal lf. # Basic vars +set sixel true set shellopts '-eu' set ifs "\n" set scrolloff 10 @@ -26,6 +27,7 @@ set cleaner '~/.config/lf/cleaner' set previewer '~/.config/lf/scope' set autoquit true + # cmds/functions cmd open ${{ case $(file --mime-type "$(readlink -f $f)" -b) in diff --git a/.config/wget/wgetrc b/.config/wget/wgetrc new file mode 100644 index 0000000..4fd7999 --- /dev/null +++ b/.config/wget/wgetrc @@ -0,0 +1 @@ +hsts-file=~/.cache/wget-hsts diff --git a/.xinitrc b/.config/x11/xinitrc index 5e0df62..5e0df62 100644 --- a/.xinitrc +++ b/.config/x11/xinitrc diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index d0cd6a7..53b582a 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -57,9 +57,6 @@ preexec() { echo -ne '\e[4 q' ;} # Lines configured by zsh-newuser-install -HISTFILE=~/.cache/zsh-history -HISTSIZE=1000 -SAVEHIST=10000 setopt appendhistory autocd extendedglob nomatch unsetopt beep notify bindkey -v @@ -83,12 +80,7 @@ mkcd() { cd -P -- "$1" } -# Loading shortcuts made by aliasgen and shortcutgen -source $HOME/.cache/zsh-aliases -source $HOME/.cache/zsh-shortcuts -source $HOME/.cache/shell-vars - -lfcd () { +f() { tmp="$(mktemp -uq)" trap 'rm -f $tmp >/dev/null 2>&1 && trap - HUP INT QUIT TERM PWR EXIT' HUP INT QUIT TERM PWR EXIT lf -single -last-dir-path="$tmp" "$@" @@ -97,11 +89,13 @@ lfcd () { [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir" fi } -alias f='lfcd' + +# Commonly used shortcuts +[ -f "${XDG_CACHE_HOME:-$HOME/.cache}/zsh-aliases" ] && source "${XDG_CACHE_HOME:-$HOME/.cache}/zsh-aliases" +[ -f "${XDG_CACHE_HOME:-$HOME/.cache}/zsh-shortcuts" ] && source "${XDG_CACHE_HOME:-$HOME/.cache}/zsh-shortcuts" # Git Root alias gr='cd $(git rev-parse --show-cdup)' # Load zsh-syntax-highlighting; should be last. -source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh 2>/dev/null - +source /usr/share/zsh/site-functions/zsh-syntax-highlighting.zsh 2>/dev/null diff --git a/.local/bin/shortcutgen b/.local/bin/shortcutgen index fe5ed75..4701655 100755 --- a/.local/bin/shortcutgen +++ b/.local/bin/shortcutgen @@ -1,23 +1,56 @@ #!/bin/sh - -# raw (basic processing before converting to specific formats) -# - remove comments -# - remove empty lines -# - remove spacing (keep commas between columns) -# - remove trailing whitespace - -# Strip comments, remove empty lines, condense spacing, remove trailing whitespace -raw="$(sed 's/#.*//g;s/,[[:space:]]*/,/g;/^$/d;s/[[:space:]]*$//g' <"${XDG_CONFIG_HOME:-$HOME/.config}/shortcutrc")" - -# lf (sourced by lfrc) -echo "$raw" | sed 's/\(.*\),\(.*\),\(.*\)/map g\2 cd \3/' >"${XDG_CONFIG_HOME:-$HOME/.config}/lf/shortcuts" - -# Shell aliases (read by zshrc) -echo "$raw" | sed 's/\(.*\),\(.*\),\(.*\)/alias g\2="cd \3"/' >"${XDG_CACHE_HOME:-$HOME/.cache}/zsh-shortcuts" - -# Environment variables (read by .profile) -echo "$raw" | sed 's/^\(.*\),\(.*\),/export G\U\2=,/;s/,\(.*\)/\1/' >"${XDG_CACHE_HOME:-$HOME/.cache}/env-shortcuts" - - - +# Quit if a valid configuration source doesn't exist +[ -f "$XDG_CONFIG_HOME/shortcutrc" ] && src="$XDG_CONFIG_HOME/shortcutrc" || exit 1 + +# If you do not want to create a specific file, replace it's variable with /dev/null +awk -v lf_filepath="${XDG_CONFIG_HOME:-$HOME/.config}/lf/shortcuts" \ + -v zsh_filepath="${XDG_CACHE_HOME:-$HOME/.cache}/zsh-shortcuts" \ + -v env_filepath="${XDG_CACHE_HOME:-$HOME/.cache}/env-shortcuts" \ +' +BEGIN { + FS="," + OFS="," +} + +# Function to remove whitespaces from a string +function remove_whitespace(str) { + gsub(/[[:space:]]/, "", str) + return str +} + +{ + # Remove comments + gsub(/#.*/, "") + + # Remove whitespaces from column 2 + $2 = remove_whitespace($2) + + # Remove leading and trailing whitespaces from column 3 + gsub(/^[[:space:]]+|[[:space:]]+$/, "", $3) + + # whenever a line contains only commas, replace it with an empty string + # so that we can check if a line is empty or not + gsub(/^,+$|^,+|,+$|,+,/, "", $0) + + # Check if line is empty or contains only whitespace + if (NF) { + + # Convert column 2 to lowercase + lc_col2 = tolower($2) + + # Convert column 2 to uppercase + uc_col2 = toupper($2) + + # Write to $XDG_CONFIG_HOME/lf/shortcuts + print "map g" lc_col2 " cd " $3 > ENVIRON["XDG_CONFIG_HOME"] "/lf/shortcuts" + + # Write to $XDG_CACHE_HOME/zsh-shortcuts + # print "alias g" lc_col2 "=\"cd " $3 "\"" > ENVIRON["XDG_CACHE_HOME"] "/zsh-shortcuts" + print "g" lc_col2 "() {cd " $3 "}" > ENVIRON["XDG_CACHE_HOME"] "/zsh-shortcuts" + + # Write to $XDG_CACHE_HOME/env-shortcuts + print "export G" uc_col2 "=\"" $3 "\"" > ENVIRON["XDG_CACHE_HOME"] "/env-shortcuts" + } +} +' "$src" @@ -1,60 +1,71 @@ -# Path -export SCRIPTS=$HOME/.local/bin -export PATH=$PATH$(find "$SCRIPTS/" -type d -printf ":%p") -export GOPATH=$HOME/.go -export PATH=$PATH:$GOPATH/bin -export PATH=$PATH:$HOME/.cargo/bin -export PATH=$PATH:/root/.local/bin -export PATH=$PATH:$HOME/.local/bin -export PATH=$PATH:/usr/local/go/bin -export PATH=$PATH:/usr/local/go/bin - -# QT & GTK -export QT_QPA_PLATFORMTHEME="qt5ct" -export GTK2_RC_FILES="$HOME/.gtkrc-2.0" -export QT_QPA_PLATFORMTHEME="qt5ct" +#!/bin/sh +# shellcheck disable=SC2155 + +unsetopt PROMPT_SP 2>/dev/null + +# Applications +export EDITOR=nvim +export TERMINAL=st +export TERMINAL_PROG=st +export BROWSER=firefox # Misc +export XDG_CONFIG_HOME="$HOME/.config" +export XDG_DATA_HOME="$HOME/.local/share" +export XDG_CACHE_HOME="$HOME/.cache" +export XINITRC="$XDG_CONFIG_HOME/x11/xinitrc" + +# Path +export PATH="$PATH:$(find $HOME/.local/bin -type d | paste -sd ":" -)" +export PATH="$PATH:$GOPATH/bin" +export PATH="$PATH:$HOME/.cargo/bin" +export PATH="$PATH:/root/.local/bin" +export PATH="$PATH:$HOME/.local/bin" +export PATH="$PATH:/usr/local/go/bin" +export PATH="$PATH:/usr/local/go/bin" + export DISTRIB_ID=arch -export DISTRIB_RELEASE=$(uname -r) -export XDG_CONFIG_HOME=$HOME/.config -export XDG_DATA_HOME=$HOME/.local/share -export XDG_CACHE_HOME=$HOME/.cache -export R_PROFILE_USER=$HOME/.config/R/Rprofile -export ZDOTDIR=$XDG_CONFIG_HOME/zsh -export TEXMFHOME=$XDG_DATA_HOME/texmf -export TEXSRC=$HOME/.local/src/sherbrooke-tex +export DISTRIB_RELEASE="$(uname -r)" +export R_PROFILE_USER="$XDG_CONFIG_HOME/R/Rprofile" +export ZDOTDIR="$XDG_CONFIG_HOME/zsh" +export TEXMFHOME="$XDG_DATA_HOME/texmf" +export GOPATH="$XDG_DATA_HOME/go" +export GOMODCACHE="$XDG_CACHE_HOME/go/mod" +export CARGO_HOME="$XDG_DATA_HOME/cargo" +export TMUX_TMPDIR="$XDG_RUNTIME_DIR" +export GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc" +export QT_QPA_PLATFORMTHEME="gtk2" +export MOZ_USE_XINPUT2=1 # Mozilla smooth scrolling/touchpad +export AWT_TOOLKIT="MToolkit wmname LG3D" # Fix for Java applications in dwm +export _JAVA_AWT_WM_NONREPARENTING=1 # (this too) +export WINEPREFIX="$XDG_DATA_HOME/wineprefixes/default" +export HISTFILE="$XDG_CACHE_HOME/zsh_history" +export HISTSIZE=1000 +export SAVEHIST=10000 -# Applications -export EDITOR=/usr/bin/nvim -export READER=/usr/bin/zathura -export TERMINAL=/usr/local/bin/st -export TERM=/usr/local/bin/st -export BROWSER=/usr/bin/firefox +# Set st as the default terminal when not connected via SSH +# or xterm when connected via SSH +[ -z "$SSH_CONNECTION" ] && export TERM=st || export TERM=xterm # less/man colors -export LESS=-R -export LESS_TERMCAP_md=$'\e[01;36;74m' # begin bold -export LESS_TERMCAP_mb=$'\e[01;31;4m' # begin blinking -export LESS_TERMCAP_us=$'\e[04;32;146m' # begin underline -export LESS_TERMCAP_so=$'\e[30;42;146m' # begin reverse video -export LESS_TERMCAP_se=$'\e[0m' # end reverse video -export LESS_TERMCAP_me=$'\e[0m' # end mode -export LESS_TERMCAP_ue=$'\e[0m' # end underline +export LESS="R" +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')" # Generate shortcuts and aliases -shortcutgen -aliasgen - -# Import shortcut ENV variables -source "$XDG_CACHE_HOME/env-shortcuts" +shortcutgen >/dev/null 2>&1 +aliasgen >/dev/null 2>&1 +[ -f "$XDG_CACHE_HOME/env-shortcuts" ] && source "$XDG_CACHE_HOME/env-shortcuts" # Ensure XDG_RUNTIME_DIR is set if test -z "$XDG_RUNTIME_DIR"; then - export XDG_RUNTIME_DIR=$(mktemp -d /tmp/$(id -u)-runtime-dir.XXX) + export XDG_RUNTIME_DIR="$(mktemp -d /tmp/$(id -u)-runtime-dir.XXX)" fi # Start Desktop Environment if on the main TTY -if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then - startx -fi +[ "$(tty)" = "/dev/tty1" ] && ! pidof Xorg >/dev/null 2>&1 && exec startx "$XINITRC" |