dotfiles/.config/shell/profile
PowerUser64 f5e15cacde BIG UPDATE: shell: add profile, move calc and mkcd to files, move
shell-independent config (aliases, functions, env vars, options) to
.config/shell/shrc, make bashrc and zshrc use the same shrc, add TTY
detection for changing caps lock to escape in a TTY, add option for
skipping plugin loading, and maybe a few other things

If this goes well, I'll be tempted to call this version 1.0.  Things
have been very stable for the last few months.  Although, since it's the
first really big change in a while, that might make it version 2.0?
Should dotfiles have big version numbers at all? Probably not.
2022-04-08 13:36:29 -07:00

84 lines
2.9 KiB
Bash

#!/bin/sh
# shellcheck disable=SC2155
export PROFILE_LOADED=false
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
export SHELL_CONFIG_DIR="${SHELL_CONFIG_DIR:-"${XDG_CONFIG_HOME:-"$HOME/.config"}/shell"}"
# Locales
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
# Remove programs from root of home directory
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_CACHE_HOME="$HOME/.cache"
export XDG_RUNTIME_DIR="/run/user/$(id -u)"
export XINITRC="${XDG_CONFIG_HOME:-$HOME/.config}/x11/xinitrc"
#export XAUTHORITY="$XDG_RUNTIME_DIR/Xauthority" # This line will break some DMs.
export GTK2_RC_FILES="${XDG_CONFIG_HOME:-$HOME/.config}/gtk-2.0/gtkrc-2.0"
export LESSHISTFILE="-"
export ALSA_CONFIG_PATH="$XDG_CONFIG_HOME/alsa/asoundrc"
# export GNUPGHOME="${XDG_DATA_HOME:-$HOME/.local/share}/gnupg"
export WINEPREFIX="${XDG_DATA_HOME:-$HOME/.local/share}/wineprefixes/default"
export KODI_DATA="${XDG_DATA_HOME:-$HOME/.local/share}/kodi"
# export TMUX_TMPDIR="$XDG_RUNTIME_DIR"
# export ANDROID_SDK_HOME="${XDG_CONFIG_HOME:-$HOME/.config}/android"
# export CARGO_HOME="${XDG_DATA_HOME:-$HOME/.local/share}/cargo"
export GOPATH="${XDG_DATA_HOME:-$HOME/.local/share}/go"
[ -f "$HOME/.cargo/env" ] && . "$HOME/.cargo/env"
# Other programs
export FZF_DEFAULT_OPTS="--layout=reverse --height 33%"
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')"
export MOZ_USE_XINPUT2="1" # Mozilla smooth scrolling/touchpads.
export VDPAU_DRIVER=va_gl # Fix steam remote play black screen
# shellcheck disable=SC2046
export $(dbus-launch)
# If running in a TTY…
if [ "$(tty | sed 's-[0-9]$--g')" = /dev/tty ]; then
export IS_TTY=true
# 1- Swap caps and escape
TMP_KEYMAP=/tmp/keymap_tmp.kmap
cat <<-EOF >> "$TMP_KEYMAP"
keycode 1 = Caps_Lock
keycode 58 = Escape
EOF
sudo -n loadkeys "$TMP_KEYMAP" 2>/dev/null
rm "$TMP_KEYMAP"
# 2- Change the prompt theme to one that doesn't use nerdfonts
export P10K_CONFIG_LOCATION="$HOME/.config/shell/p10k/simple.p10k.zsh"
else
export IS_TTY=false
# gnome likes to reset the keymap settings I make and I hate it
# if… gnome is the desktop, the profile is unloaded, we are not in tmux, and gsettings is a valid command
if [ "$DESKTOP_SESSION" = "gnome" ] && [ -z "${PROFILE_LOADED+foo}" ] && [ -z "${TMUX+foo}" ] && command -v gsettings > /dev/null; then
(
sleep 1 &&
gsettings set org.gnome.desktop.input-sources xkb-options "['caps:escape', 'compose:sclk']"
) &
fi
fi
export PROFILE_LOADED=true
# vim:ft=sh:sw=3:ts=3:nospell