2022-05-27 21:07:07 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Default programs:
|
|
|
|
export BROWSER=firefox
|
|
|
|
export EDITOR=vim
|
|
|
|
export FILE=ranger
|
|
|
|
export IMAGES=feh
|
|
|
|
export PAGER=less
|
2023-08-29 13:53:53 +02:00
|
|
|
export TERMINAL=kitty
|
2022-05-27 21:07:07 +02:00
|
|
|
export VISUAL=code
|
|
|
|
|
2023-09-15 14:19:58 +02:00
|
|
|
# Misc vars
|
|
|
|
export CHROME_EXECUTABLE=chromium # For Flutter
|
|
|
|
|
2022-05-27 21:07:07 +02:00
|
|
|
# Clean home:
|
|
|
|
export XDG_CACHE_HOME="$HOME/.cache"
|
|
|
|
export XDG_CONFIG_HOME="$HOME/.config"
|
|
|
|
export XDG_DATA_HOME="$HOME/.local/share"
|
2023-09-15 14:19:58 +02:00
|
|
|
export ANDROID_HOME="${XDG_DATA_HOME:-$HOME/.local/share}/Android/Sdk"
|
2022-05-27 21:07:07 +02:00
|
|
|
export CARGO_HOME="${XDG_DATA_HOME:-$HOME/.local/share}/cargo"
|
2023-09-15 13:41:56 +02:00
|
|
|
export KREW_ROOT="${XDG_DATA_HOME:-$HOME/.local/share}/krew"
|
2023-09-15 13:44:37 +02:00
|
|
|
export FLUTTER_HOME="${XDG_DATA_HOME:-$HOME/.local/share}/flutter"
|
2022-05-27 21:07:07 +02:00
|
|
|
export GOPATH="${XDG_DATA_HOME:-$HOME/.local/share}/go"
|
|
|
|
export HISTFILE="${XDG_DATA_HOME:-$HOME/.local/share}/history"
|
|
|
|
export XINITRC="${XDG_CONFIG_HOME:-$HOME/.config}/x11/xinitrc"
|
|
|
|
export ZDOTDIR="${XDG_CONFIG_HOME:-$HOME/.config}/zsh"
|
2022-09-07 16:38:31 +02:00
|
|
|
export NVM_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/nvm"
|
2022-05-27 21:07:07 +02:00
|
|
|
export NUGET_PACKAGES="${XDG_DATA_HOME:-$HOME/.local/share}/nuget"
|
|
|
|
|
|
|
|
# Color man pages:
|
|
|
|
export LESS=-r
|
|
|
|
export LESS_TERMCAP_mb=$'\E[01;32m'
|
|
|
|
export LESS_TERMCAP_md=$'\E[01;32m'
|
|
|
|
export LESS_TERMCAP_me=$'\E[0m'
|
|
|
|
export LESS_TERMCAP_se=$'\E[0m'
|
|
|
|
export LESS_TERMCAP_so=$'\E[01;47;34m'
|
|
|
|
export LESS_TERMCAP_ue=$'\E[0m'
|
|
|
|
export LESS_TERMCAP_us=$'\E[01;36m'
|
|
|
|
|
|
|
|
# Other program settings:
|
|
|
|
export DISPLAY_DPI=96
|
|
|
|
|
2022-12-15 16:01:39 +01:00
|
|
|
# Remove an entry from PATH
|
|
|
|
rm_path_entry() {
|
|
|
|
local shell="${SHELL##*/}" rm_entry="${1:?Entry not set}" new_path path_arr
|
|
|
|
|
|
|
|
if [[ "$shell" == "zsh" ]]; then
|
|
|
|
IFS=" " read -A path_arr <<<"${PATH//:/ }"
|
|
|
|
else
|
|
|
|
IFS=" " read -a path_arr <<<"${PATH//:/ }"
|
|
|
|
fi
|
|
|
|
|
|
|
|
for path_entry in "${path_arr[@]}"; do
|
|
|
|
grep -Eq "^$rm_entry$" <<<"$path_entry" && continue
|
|
|
|
new_path="$new_path:$path_entry"
|
|
|
|
done
|
|
|
|
|
|
|
|
PATH="${new_path#:}"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Remove one or more entries from PATH
|
|
|
|
rm_path_entries() {
|
|
|
|
local rm_entry
|
|
|
|
|
|
|
|
for rm_entry in "$@"; do
|
|
|
|
rm_path_entry "$rm_entry"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# Prepend one or more entries to PATH.
|
|
|
|
# The order of the supplied args will be kept, e.g. PATH="$1:$2:$PATH"
|
|
|
|
prepend_path_with_entries() {
|
|
|
|
local addl_paths entry
|
|
|
|
|
|
|
|
for entry in "$@"; do
|
|
|
|
! [ -d "$entry" ] && continue
|
|
|
|
addl_paths="$addl_paths:$entry"
|
|
|
|
done
|
|
|
|
|
|
|
|
PATH="${addl_paths#:}:$PATH"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Append one or more entries to PATH.
|
|
|
|
# The order of the supplied args will be kept, e.g. PATH="$PATH:$1:$2"
|
|
|
|
append_path_with_entries() {
|
|
|
|
local addl_paths entry
|
|
|
|
|
|
|
|
for entry in "$@"; do
|
|
|
|
! [ -d "$entry" ] && continue
|
|
|
|
addl_paths="$addl_paths:$entry"
|
|
|
|
done
|
|
|
|
|
|
|
|
PATH="$PATH:${addl_paths#:}"
|
|
|
|
}
|
|
|
|
|
|
|
|
prepend_paths=(
|
2022-05-27 21:07:07 +02:00
|
|
|
"$HOME/.local/bin"
|
|
|
|
"$HOME/.cargo/bin"
|
2023-09-15 13:44:37 +02:00
|
|
|
"$FLUTTER_HOME/bin"
|
2024-02-16 13:18:18 +01:00
|
|
|
"$GOPATH/bin"
|
2023-09-15 13:41:56 +02:00
|
|
|
"$KREW_ROOT/bin"
|
2022-05-27 21:07:07 +02:00
|
|
|
)
|
2022-12-15 16:01:39 +01:00
|
|
|
append_paths=()
|
2022-05-27 21:07:07 +02:00
|
|
|
|
2024-04-11 12:15:19 +02:00
|
|
|
HOMEBREW_PREFIX="$XDG_DATA_HOME/homebrew"
|
|
|
|
if [ -x "$HOMEBREW_PREFIX/bin/brew" ]; then
|
|
|
|
eval "$("$HOMEBREW_PREFIX/bin/brew" shellenv)"
|
|
|
|
append_paths+=("$HOMEBREW_PREFIX/bin" "$HOMEBREW_PREFIX/sbin")
|
|
|
|
fi
|
2022-12-15 16:01:39 +01:00
|
|
|
|
|
|
|
rm_path_entries "${prepend_paths[@]}" "${append_paths[@]}" # Ensure we clean up first
|
|
|
|
prepend_path_with_entries "${prepend_paths[@]}"
|
|
|
|
append_path_with_entries "${append_paths[@]}"
|
2022-05-28 23:00:55 +02:00
|
|
|
|
|
|
|
# Add the profile-extras file yourself if you wish to override anything:
|
|
|
|
PROFILE_EXTRAS="${XDG_CONFIG_HOME:-$HOME/.config}/shell/profile-extras"
|
|
|
|
[ -f "$PROFILE_EXTRAS" ] && . "$PROFILE_EXTRAS"
|