Common Shell initialization files
Table of Contents
This repository is a collection of common POSIX-compliant shells configuration files that I used.
.shrc
Taken from FreeBSD. This file will be used if the shell is invoked for interactive use and the environment variable ENV is set to this file.
1: # $FreeBSD$ 2: # 3: # .shrc - bourne shell startup file 4: # 5: # This file will be used if the shell is invoked for interactive use and 6: # the environment variable ENV is set to this file. 7: # 8: # see also sh(1), environ(7). 9: # 10: 11: # file permissions: rwxr-xr-x 12: # 13: # umask 022 14: 15: # Uncomment this to enable the builtin vi(1) command line editor in sh(1), 16: # e.g. ESC to go into visual mode. 17: # set -o vi 18: 19: if ([ "${SHELL}" != "/bin/sh" ] && [ "${SHELL}" != "/bin/dash" ]);then 20: return 21: fi 22: 23: alias h='fc -l' 24: alias j=jobs 25: alias m="$PAGER" 26: alias ll='ls -laFo' 27: alias l='ls -l' 28: alias g='egrep -i' 29: 30: # # be paranoid 31: # alias cp='cp -ip' 32: # alias mv='mv -i' 33: # alias rm='rm -i' 34: 35: # set prompt: ``username@hostname:directory $ '' 36: if [ "${DISTRO}" = "freebsd" ]; then 37: PS1="\u@\h:\w \\$ " 38: else 39: PS1="${USER}@${HOSTNAME}:\${PWD} $ " 40: fi 41: 42: # search path for cd(1) 43: # CDPATH=:$HOME
This file itself will only be called from the system / user profile (/etc/profile
or ~/.profile
).
.login
Used by csh
and tcsh
. Read after .cshrc
at login.
1: # -*- mode: sh -*- 2: # $FreeBSD$ 3: # 4: # .login - csh login script, read by login shell, after `.cshrc' at login. 5: # 6: # See also csh(1), environ(7). 7: # 8: 9: # Query terminal size; useful for serial lines. 10: if ( -x /usr/bin/resizewin ) /usr/bin/resizewin -z
.logout
1: # -*- mode: sh -*- 2: # 3: # .logout - csh logout script 4: # 5: 6: if ( -x `which clear` ) clear
.profile
Used by various shells. It is important to keep this script POSIX-compliant since there's more than one shell depends on it.
1: # ~/.profile 2: # Environment and startup programs. 3: # source /etc/profile if exist. 4: # <alexforsale@yahoo.com> 5: # 6: 7: [ -f /etc/profile ] && . /etc/profile 8: 9: # this goes first in case others needs it. 10: if [ -d "${HOME}/bin" ] ; then 11: export PATH="${HOME}/bin:${PATH}" 12: fi 13: if [ -d "$HOME/.local/bin" ];then 14: export PATH="${HOME}/.local/bin:${PATH}" 15: fi 16: 17: # Loads user profiles if exists. Should be in ~/.profile.d 18: # but let's not pollute ~ anymore. 19: 20: if [ -d "${HOME}/.config/profile.d" ]; then 21: for profile in "${HOME}"/.config/profile.d/*.sh; do 22: . "${profile}" 23: done 24: unset profile 25: fi 26: 27: if [ -n "${PATH}" ]; then 28: old_PATH=${PATH}:; PATH= 29: while [ -n "${old_PATH}" ]; do 30: x=${old_PATH%%:*} # the first remaining entry 31: case ${PATH}: in 32: *:"$x":*) ;; # already there 33: *) PATH=${PATH}:$x;; # not there yet 34: esac 35: old_PATH=${old_PATH#*:} 36: done 37: PATH=${PATH#:} 38: unset old_PATH x 39: fi 40: 41: # local ~/.profile 42: if [ -r "${HOME}"/.config/profile.local ];then 43: . "${HOME}"/.config/profile.local 44: elif [ -r "${HOME}"/.profile.local ];then 45: . "${HOME}"/.profile.local 46: fi 47: 48: # if running bash 49: if [ -n "${BASH_VERSION}" ]; then 50: # include .bashrc if it exists 51: if [ -f "${HOME}/.bashrc" ]; then 52: . "${HOME}/.bashrc" 53: fi 54: fi
Modules
Their file names are prefixed with numbers dd-filename
to ensure the order.
distro
This is an easier way for my shell scripts to query the currently running *nix distribution and their version.
# ~/.config/profile.d/00-distro.sh # set distro environment # <alexforsale@yahoo.com> # set DISTRO and DISTROVER if [ -f /etc/os-release ]; then # freedesktop.org and systemd . /etc/os-release DISTRO="${ID}" DISTROVER="${VERSION_ID}" [ -z "${DISTROVER}" ] && DISTROVER="${BUILD_ID}" elif [ "$(command -v lsb_release >/dev/null)" ]; then # linuxbase.org DISTRO="$(lsb_release -si | awk '{print tolower ($0)}')" DISTROVER="$(lsb_release -sr | awk '{print tolower ($0)}')" elif [ -f /etc/lsb-release ]; then # For some versions of Debian/Ubuntu without lsb_release command . /etc/lsb-release DISTRO="${DISTRIB_ID}" DISTROVER="${DISTRIB_RELEASE}" elif [ -f /etc/debian_version ]; then # Older Debian/Ubuntu/etc. DISTRO=Debian DISTROVER="$(cat /etc/debian_version)" else # Fall back to uname, e.g. "Linux <version>", also works for BSD, etc. DISTRO="$(uname -s)" DISTROVER="$(uname -r)" fi # set helper functions here for now contains() { case "$1" in *"$2"*) true ;; *) false ;; esac } export DISTRO DISTROVER
The contains()
function is for a quick string search.
locale
This is rarely used, most of the times the the system shell startup files already defined these variables.
1: # ~/.config/profile.d/00-locale.sh 2: # locale settings 3: # <alexforsale@yahoo.com> 4: 5: # language 6: [ -z "${LANG}" ] && export LANG=en_US.UTF-8 7: [ -z "${MM_CHARSET}" ] && export MM_CHARSET=en_US.UTF-8
xdg-base-directory
Ensure the running session comply to the XDG Base Directory specification. Variable declaration should be guarded in case the running system already declares it.
1: # ~/.config/profile.d/01-xdg_base_directory.sh 2: # XDG Base Directory specification 3: # https://wiki.archlinux.org/index.php/XDG_BASE_Directory_support 4: # <alexforsale@yahoo.com> 5: 6: if [ -z "${XDG_CONFIG_HOME}" ]; then 7: if [ -d "${HOME}/.config" ]; then 8: mkdir -p "${HOME}/.config" 9: fi 10: fi 11: 12: [ -z "${XDG_CONFIG_HOME}" ] && XDG_CONFIG_HOME="${HOME}/.config" 13: 14: if [ -z "${XDG_CACHE_HOME}" ]; then 15: if [ -d "${HOME}/.cache" ]; then 16: mkdir -p "${HOME}/.cache" 17: fi 18: fi 19: 20: [ -z "${XDG_CACHE_HOME}" ] && XDG_CACHE_HOME="${HOME}/.cache" 21: 22: if [ -z "${XDG_DATA_HOME}" ]; then 23: if [ -d "${HOME}/.local/share" ]; then 24: mkdir -p "${HOME}/.local/share" 25: fi 26: fi 27: 28: [ -z "${XDG_DATA_HOME}" ] && XDG_DATA_HOME="${HOME}/.local/share" 29: 30: if [ -z "${XDG_RUNTIME_DIR}" ]; then 31: case "${DISTRO}" in 32: "gentoo") 33: XDG_RUNTIME_DIR="/tmp/$(id -u)-runtime-dir" 34: if [ ! -d "${XDG_RUNTIME_DIR}" ];then 35: mkdir -p "${XDG_RUNTIME_DIR}" 36: chmod 0700 "${XDG_RUNTIME_DIR}" 37: fi 38: ;; 39: "arch") 40: XDG_RUNTIME_DIR="/run/user/$(id -u)" 41: if [ ! -d "${XDG_RUNTIME_DIR}" ];then 42: mkdir -p "${XDG_RUNTIME_DIR}" 43: chmod 0700 "${XDG_RUNTIME_DIR}" 44: fi 45: ;; 46: "freebsd") 47: XDG_RUNTIME_DIR="/tmp/$(id -u)-runtime-dir" 48: if [ ! -d "${XDG_RUNTIME_DIR}" ];then 49: mkdir -p "${XDG_RUNTIME_DIR}" 50: chmod 0700 "${XDG_RUNTIME_DIR}" 51: fi 52: ;; 53: esac 54: fi 55: 56: if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then 57: # differs per distro 58: #DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus" 59: `command -v dbus-launch` && eval `dbus-launch --sh-syntax` 60: fi 61: 62: # XDG User Directories 63: # https://wiki.archlinux.org/index.php/XDG_user_directories 64: [ -z "${XDG_DESKTOP_DIR}" ] && export XDG_DESKTOP_DIR="${HOME}/Desktop" 65: [ -z "${XDG_DOWNLOAD_DIR}" ] && export XDG_DOWNLOAD_DIR="${HOME}/Downloads" 66: [ -z "${XDG_TEMPLATES_DIR}" ] && export XDG_TEMPLATES_DIR="${HOME}/Templates" 67: [ -z "${XDG_PUBLICSHARE_DIR}" ] && export XDG_PUBLICSHARE_DIR="${HOME}/Public" 68: [ -z "${XDG_DOCUMENTS_DIR}" ] && export XDG_DOCUMENTS_DIR="${HOME}/Documents" 69: [ -z "${XDG_MUSIC_DIR}" ] && export XDG_MUSIC_DIR="${HOME}/Music" 70: [ -z "${XDG_PICTURES_DIR}" ] && export XDG_PICTURES_DIR="${HOME}/Pictures" 71: [ -z "${XDG_VIDEOS_DIR}" ] && export XDG_VIDEOS_DIR="${HOME}/Videos" 72: 73: for dir in "${XDG_DESKTOP_DIR}" "${XDG_DOWNLOAD_DIR}" "${XDG_TEMPLATES_DIR}" \ 74: "${XDG_PUBLICSHARE_DIR}" "${XDG_DOCUMENTS_DIR}" "${XDG_MUSIC_DIR}" \ 75: "${XDG_PICTURES_DIR}" "${XDG_VIDEOS_DIR}";do 76: if [ ! -d "${dir}" ] || [ ! -L "${dir}" ];then 77: mkdir -p "${dir}" 2>/dev/null 78: fi 79: done 80: unset dir 81: 82: if [ -d /usr/share ]; then 83: contains "${XDG_DATA_DIRS}" "/usr/share" || 84: export XDG_DATA_DIRS="/usr/share" 85: fi 86: 87: if [ -d /usr/local/share ]; then 88: contains "${XDG_DATA_DIRS}" "/usr/local/share" || 89: export XDG_DATA_DIRS="${XDG_DATA_DIRS}:/usr/local/share" 90: fi 91: 92: export XDG_CONFIG_HOME XDG_CACHE_HOME XDG_DATA_HOME XDG_RUNTIME_DIR DBUS_SESSION_BUS_ADDRESS
editors
- $EDITOR
- Application set as this variable should be able to operate without the "advanced" terminal functionalities. Most of the times,
vi
is the default $EDITOR - $VISUAL
- for fullscreen editors.
1: # ~/.config/profile.d/02-editors.sh 2: # ${EDITOR}, ${VISUAL} and ${ALTERNATE_EDITOR} 3: # <alexforsale@yahoo.com> 4: 5: # chemacs-profile 6: if [ -e "${HOME}/.config/chemacs/profile" ]; then 7: export CHEMACS_PROFILE="$(cat ${HOME}/.config/chemacs/profile)" 8: elif [ -e "${HOME}/.emacs-profile" ]; then 9: export CHEMACS_PROFILE="$(cat ${HOME}/.emacs-profile)" 10: fi 11: 12: [ -n "${CHEMACS_PROFILE}" ] && emacs_args="-s ${CHEMACS_PROFILE}" 13: 14: # see https://unix.stackexchange.com/questions/4859/visual-vs-editor-what-s-the-difference 15: if [ "$(command -v emacs)" ]; then 16: export VISUAL="${VISUAL:-emacsclient -c} ${emacs_args}" 17: export EDITOR="${EDITOR:-emacsclient -t} ${emacs_args}" 18: export ALTERNATE_EDITOR=${VISUAL} 19: elif [ "$(command -v gvim)" ]; then # in case it's available, I don't use much of this 20: export EDITOR="${EDITOR:-vim}" # this should also installed 21: export VISUAL="${VISUAL:-gvim}" 22: elif [ "$(command -v vim)" ]; then # most distro provide this (linux that is) 23: export EDITOR="${EDITOR:-vim}" 24: export VISUAL="${VISUAL:-vim}" 25: else 26: [ $(command -v nvim) ] && 27: export EDITOR="${EDITOR:-nvim}" 28: 29: [ $(command -v leafpad) ] && 30: export EDITOR="${EDITOR:-leafpad}" 31: 32: [ $(command -v l3afpad) ] && 33: export EDITOR="${EDITOR:-l3afpad}" 34: 35: [ $(command -v kate) ] && 36: export EDITOR="${EDITOR:-kate}" 37: 38: [ $(command -v pluma) ] && 39: export EDITOR="${EDITOR:-pluma}" 40: 41: [ $(command -v kwrite) ] && 42: export EDITOR="${EDITOR:-kwrite}" 43: 44: [ $(command -v scribe) ] && 45: export EDITOR="${EDITOR:-scribe}" 46: 47: [ $(command -v geany) ] && 48: export EDITOR="${EDITOR:-geany}" 49: 50: [ $(command -v gedit) ] && 51: export EDITOR="${EDITOR:-gedit}" 52: 53: [ $(command -v code) ] && 54: export EDITOR="${EDITOR:-code}" 55: 56: # most unix os provide this, 57: [ $(command -v vi) ] && 58: export EDITOR="${EDITOR:-vi}" 59: 60: export VISUAL=${EDITOR} 61: export ALTERNATE_EDITOR=${EDITOR} 62: fi 63: 64: # if [ "%(command -v nvim)" ]; then 65: # export GVIMINIT='let $MYGVIMRC = !has("nvim") ? "$XDG_CONFIG_HOME/vim/gvimrc" : "$XDG_CONFIG_HOME/nvim/init.gvim" | so $MYGVIMRC' 66: # export VIMINIT='let $MYVIMRC = !has("nvim") ? "$XDG_CONFIG_HOME/vim/vimrc" : "$XDG_CONFIG_HOME/nvim/init.vim" | so $MYVIMRC' 67: # elif [ "$(command -v vim)" ]; then 68: # export GVIMINIT='let $MYGVIMRC="$XDG_CONFIG_HOME/vim/gvimrc" | source $MYGVIMRC' 69: # export VIMINIT='let $MYVIMRC="$XDG_CONFIG_HOME/vim/vimrc" | source $MYVIMRC' 70: # fi
- $CHEMACS_PROFILE
- This variable is used as a tweak to have multiple Emacs configurations1.
- VIM / GVIM / NVIM
- I used to set the VIMRC variable to
~/.config
directory. Commented since I rarely used them, their defaults is good enough fo a quick editing.
terminals
The $TERMINAL
variable is not used in any shell init files (that I know of). But handy when using a tiling window manager.
1: # ~/.config/profile.d/03-terminal.sh 2: # ${TERMINAL} apps 3: # <alexforsale@yahoo.com> 4: 5: # Terminal apps 6: if [ "$(command -v alacritty)" ]; then 7: export TERMINAL=${TERMINAL:-alacritty} 8: elif [ "$(command -v gnome-terminal)" ]; then 9: export TERMINAL=${TERMINAL:-gnome-terminal} 10: elif [ "$(command -v terminator)" ]; then 11: export TERMINAL=${TERMINAL:-terminator} 12: elif [ "$(command -v tilda)" ]; then 13: export TERMINAL=${TERMINAL:-tilda} 14: elif [ "$(command -v guake)" ]; then 15: export TERMINAL=${TERMINAL:-guake} 16: elif [ "$(command -v konsole)" ]; then 17: export TERMINAL=${TERMINAL:-konsole} 18: elif [ "$(command -v lxterminal)" ]; then 19: export TERMINAL=${TERMINAL:-lxterminal} 20: elif [ "$(command -v yakuake)" ]; then 21: export TERMINAL=${TERMINAL:-yakuake} 22: elif [ "$(command -v st)" ]; then 23: export TERMINAL=${TERMINAL:-st} 24: elif [ "$(command -v terminology)" ]; then 25: export TERMINAL=${TERMINAL:-terminology} 26: elif [ "$(command -v xfce4-terminal)" ]; then 27: export TERMINAL=${TERMINAL:-xfce4-terminal} 28: elif [ "$(command -v lilyterm)" ]; then 29: export TERMINAL=${TERMINAL:-lilyterm} 30: elif [ "$(command -v alacritty)" ]; then 31: export TERMINAL=${TERMINAL:-alacritty} 32: elif [ "$(command -v xterm)" ]; then 33: export TERMINAL=${TERMINAL:-xterm} 34: elif [ "$(command -v urxvt)" ]; then 35: export TERMINAL=${TERMINAL:-urxvt} 36: fi
security
1: # ~/.config/profile.d/04-security.sh 2: # various security apps 3: # <alexforsale@yahoo.com> 4: 5: # from https://www.gnupg.org/documentation/manuals/gnupg/Invoking-GPG_002dAGENT.html 6: export GPG_TTY="$(tty)" 7: 8: # https://wiki.gentoo.org/wiki/GnuPG#Automatically_starting_the_GPG_agent 9: if [ -n "$SSH_CONNECTION" ]; then 10: export PINENTRY_USER_DATA="USE_CURSES=1" 11: fi 12: 13: # gpg-agent 14: case "${DISTRO}" in 15: freebsd) 16: for i in curses gnome3 gtk2 qt5; do 17: if [ "$(command -v pinentry-${i})" ]; then 18: _PINENTRY="$(command -v pinentry-${i})" 19: else 20: _PINENTRY="$(command -v pinentry)" 21: fi 22: done 23: 24: if [ ! "$(pgrep -u "${USER}" -x gpg-agent)" ]; then 25: /usr/local/bin/gpg-agent --enable-ssh-support \ 26: --pinentry-program "${_PINENTRY}" \ 27: --daemon "$@" 28: if [ -f "${HOME}/.gpg-agent-info" ]; then 29: . "${HOME}/.gpg-agent-info" 30: export GPG_AGENT_INFO SSH_AUTH_SOCK 31: fi 32: fi 33: ;; 34: *) 35: # append pinentry-program since its location varied for each distro 36: [ -z "$(pgrep -u ${USER} -x gpg-agent)" ] && 37: gpg-agent --pinentry-program "$(command -v pinentry)" >/dev/null 2>&1 38: ;; 39: esac 40: 41: unset SSH_AGENT_PID 42: if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then 43: export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" 44: fi 45: 46: # keychain 47: # https://wiki.gentoo.org/wiki/Keychain 48: if [ "$(command -v keychain)" ]; then 49: [ -z "${HOSTNAME}" ] && HOSTNAME="$(uname -n)" 50: keychain --quiet --agents "gpg,ssh" 51: [ -f "${HOME}/.keychain/${HOSTNAME}-sh" ] && 52: . "${HOME}/.keychain/${HOSTNAME}-sh" 53: [ -f "${HOME}/.keychain/${HOSTNAME}-sh-gpg" ] && 54: . "${HOME}/.keychain/${HOSTNAME}-sh-gpg" 55: fi
file managers
# ~/.config/profile.d/05-filemanagers.sh # filemanager configuration # <alexforsale@yahoo.com> # file manager if [ "$(command -v emacs)" ]; then export FILE=${FILE:-emacsclient -c -e '(dired-jump)'} elif [ "$(command -v ranger)" ]; then export FILE=${FILE:-ranger} elif [ "$(command -v pcmanfm)" ]; then export FILE=${FILE:-pcmanfm} elif [ "$(command -v thunar)" ]; then export FILE=${FILE:-thunar} elif [ "$(command -v caja)" ]; then export FILE=${FILE:-caja} elif [ "$(command -v nautilus)" ]; then export FILE=${FILE:-nautilus} elif [ "$(command -v nemo)" ]; then export FILE=${FILE:-nemo} elif [ "$(command -v dolphin)" ]; then export FILE=${FILE:-dolpin} elif [ "$(command -v rox)" ]; then export FILE=${FILE:-rox} fi
Most system I used will default to Emacs's dired
, if you use Emacs you should know dired.
browser
1: # ~/.config/profile.d/06-browser.sh 2: # ${BROWSER} configuration 3: # <alexforsale@yahoo.com> 4: 5: # Browser 6: if [ "$(command -v firefox)" ]; then 7: export BROWSER=${BROWSER:-firefox} 8: elif [ "$(command -v google-chrome-stable)" ]; then 9: export BROWSER=${BROWSER:-google-chrome-stable} 10: elif [ "$(command -v brave)" ]; then 11: export BROWSER=${BROWSER:-brave} 12: elif [ "$(command -v midori)" ]; then 13: export BROWSER=${BROWSER:-midori} 14: elif [ "$(command -v qutebrowser)" ]; then 15: export BROWSER=${BROWSER:-qutebrowser} 16: elif [ "$(command -v chromium)" ]; then 17: export BROWSER=${BROWSER:-chromium} 18: elif [ "$(command -v seamonkey)" ]; then 19: export BROWSER=${BROWSER:-seamonkey} 20: elif [ "$(command -v falkon)" ]; then 21: export BROWSER=${BROWSER:-falkon} 22: else 23: [ "$(command -v elinks)" ] && 24: export BROWSER=${BROWSER:-elinks} 25: 26: [ "$(command -v lynx)" ] && 27: export BROWSER=${BROWSER:-lynx} 28: 29: [ "$(command -v w3m)" ] && 30: export BROWSER=${BROWSER:-w3m} 31: 32: [ "$(command -v links)" ] && 33: export BROWSER="${BROWSER:-links -g}" 34: fi
I use more than one browsers, with firefox being my default browser.
mail apps
1: # ~/.config/profile.d/07-mail_apps.sh 2: # ${MAIL_APP} configuration 3: # <alexforsale@yahoo.com> 4: 5: if [ "$(command -v thunderbird)" ]; then 6: export MAIL_APP=${MAIL_APP:-thunderbird} 7: elif [ "$(command -v alpine)" ]; then 8: export MAIL_APP=${MAIL_APP:-alpine} 9: elif [ "$(command -v balsa)" ]; then 10: export MAIL_APP=${MAIL_APP:-balsa} 11: elif [ "$(command -v evolution)" ]; then 12: export MAIL_APP=${MAIL_APP:-evolution} 13: elif [ "$(command -v geary)" ]; then 14: export MAIL_APP=${MAIL_APP:-geary} 15: elif [ "$(command -v kmail)" ]; then 16: export MAIL_APP=${MAIL_APP:-kmail} 17: elif [ "$(command -v kube)" ]; then 18: export MAIL_APP=${MAIL_APP:-kube} 19: elif [ "$(command -v mailspring)" ]; then 20: export MAIL_APP=${MAIL_APP:-mailspring} 21: fi
Thunderbird never disapoint, so why bother?
themes
1: # ~/.config/profile.d/10-themes.sh 2: # themes configuration 3: # <alexforsale@yahoo.com> 4: 5: # wal 6: #if [ "$(command -v wal)" ] && [ -z "${SSH_CLIENT}" ]; then 7: # wal -R 8: #fi 9: 10: if [ -n "${DESKTOP_SESSION}" ]; then 11: case ${XDG_CURRENT_DESKTOP} in 12: "KDE") 13: if [ -n "${xrdb_args}" ]; then 14: $(command -v xrdb) -merge "${xrdb_args}" "${HOME}"/.Xresources >/dev/null 2>&1 15: fi 16: ;; 17: esac 18: fi 19: 20: [ -z "${GTK_THEME}" ] && export GTK_THEME=${GTK_THEME:Breeze-Dark}
I'm considering moving this into xorg configuration file, or to the display manager configuration.
cargo
# ~/.config/profile.d/99-cargo.sh # cargo configuration # https://wiki.archlinux.org/index.php/Rust#Cargo # <alexforsale@yahoo.com> if [ -d "$HOME/.cargo/bin" ];then export PATH=$HOME/.cargo/bin:$PATH fi
For when I'm playful and messing around with rust.
ccache
1: # ~/.config/profile.d/99-ccache.sh 2: # ccache configuration 3: # <alexforsale@yahoo.com> 4: 5: if [ "$(command -v ccache)" ] && 6: [ -d "/usr/lib/ccache/bin" ]; then 7: if [ "${SHELL}" != "/bin/sh" ] && 8: [ "$(command -v pathprepend)" ]; then 9: pathprepend /usr/lib/ccache/bin 10: else 11: export PATH=/usr/lib/ccache/bin:"${PATH}" 12: fi 13: fi 14: 15: case "${DISTRO}" in 16: "gentoo") 17: [ -r /var/cache/ccache ] && 18: export CCACHE_DIR="/var/cache/ccache" 19: ;; 20: esac
When turning on the monitor means compiling.
composer
1: # ~/.config/profile.d/99-composer.sh 2: # composer path configuration 3: # <alexforsale@yahoo.com> 4: 5: if [ "$(command -v composer)" ] && 6: [ -d "${HOME}/.config/composer/vendor/bin" ]; then 7: export PATH="${HOME}/.config/composer/vendor/bin:${PATH}" 8: fi
I used composer once, but obligated to have this config.
dash
1: # ~/.config/profile.d/99-dash.sh 2: # configuration for dash shells and other sh equivalent 3: # <alexforsale@yahoo.com> 4: 5: if ([ "${SHELL}" = "/bin/sh" ] || [ "${SHELL}" = "/bin/dash" ]);then 6: ENV=${HOME}/.shrc; export ENV 7: [ -x /usr/bin/resizewin ] && /usr/bin/resizewin -z 8: fi
This ensures the ~/.shrc~
file get sourced if exists.
doom emacs
1: # ~/.config/profile.d/99-doom_emacs.sh 2: # doom emacs path 3: # <alexforsale@yahoo.com> 4: 5: if [ "$(command -v emacs)" ] && 6: [ -e "${HOME}"/.emacs.d/bin/doom ]; then 7: [ ! "$(command -v doom)" ] && 8: export PATH="${PATH}:${HOME}/.emacs.d/bin" 9: elif [ -e "${HOME}/.config/doom/bin/doom" ]; then 10: [ ! "$(command -v doom)" ] && 11: export PATH="${PATH}/.config/doom/bin" 12: fi
Doom Emacs have its own scripts.
elinks
1: # ~/.config/profile.d/99-elinks.sh 2: # configuration for elinks 3: # <alexforsale@yahoo.com> 4: 5: if [ "$(command -v elinks)" ];then 6: if [ -d "${XDG_CONFIG_HOME}"/elinks ];then 7: if [ -d "${HOME}/.elinks" ]; then 8: mv "${HOME}/.elinks" "${XDG_CONFIG_HOME}/elinks" 9: else 10: mkdir -p "${XDG_CONFIG_HOME}/elinks" 11: fi 12: fi 13: export ELINKS_CONFDIR="${XDG_CONFIG_HOME}/elinks" 14: fi
Before you ask: "why bother with elinks?", try gentoo, or worse, linuxfromscratch.
emacs vterm
1: # ~/.config/profile.d/99-emacs-vterm.sh 2: # https://github.com/akermu/emacs-libvterm 3: # <alexforsale@yahoo.com> 4: 5: # dont' source this in sh 6: if [ "${SHELL}" = "/bin/sh" ]; then 7: return 8: fi 9: 10: vterm_printf(){ 11: if [ -n "$TMUX" ]; then 12: # Tell tmux to pass the escape sequences through 13: # (Source: http://permalink.gmane.org/gmane.comp.terminal-emulators.tmux.user/1324) 14: printf "\ePtmux;\e\e]%s\007\e\\" "$1" 15: elif [ "${TERM%%-*}" = "screen" ]; then 16: # GNU screen (screen, screen-256color, screen-256color-bce) 17: printf "\eP\e]%s\007\e\\" "$1" 18: else 19: printf "\e]%s\e\\" "$1" 20: fi 21: } 22: 23: if [[ "$INSIDE_EMACS" = 'vterm' ]]; then 24: function clear(){ 25: vterm_printf "51;Evterm-clear-scrollback"; 26: tput clear; 27: } 28: fi 29: 30: vterm_cmd() { 31: local vterm_elisp 32: vterm_elisp="" 33: while [ $# -gt 0 ]; do 34: vterm_elisp="$vterm_elisp""$(printf '"%s" ' "$(printf "%s" "$1" | sed -e 's|\\|\\\\|g' -e 's|"|\\"|g')")" 35: shift 36: done 37: vterm_printf "51;E$vterm_elisp" 38: }
Perhaps later version of vterm doesn't really need this anymore?
freeBSD
1: # ~/.config/profile.d/99-freebsd.sh 2: # configuration for FreeBSD 3: # <alexforsale@yahoo.com> 4: 5: if [ "${DISTRO}" = "freebsd" ]; then 6: [ -z "${ENV}" ] && ENV=${HOME}/.shrc 7: export ENV 8: export PAGER=less 9: [ -x /usr/bin/resizewin ] && /usr/bin/resizewin -z 10: [ -x /usr/bin/fortune ] && /usr/bin/fortune freebsd-tips 11: # Let sh(1) know it's at home, despite /home being a symlink. 12: if [ "$PWD" != "$HOME" ] && [ "$PWD" -ef "$HOME" ]; then cd || return; fi 13: cd "${HOME}" || exit 14: fi
fsharp
1: # ~/.config/profile.d/99-fsharp.sh 2: # configuration for F# 3: # <alexforsale@yahoo.com> 4: 5: if [[ -d "${HOME}/.dotnet/tools" ]] && 6: [[ $(command -v dotnet) ]]; then 7: export PATH="${PATH}:${HOME}/.dotnet/tools" 8: fi
Just to make me looks like a programmer.
ghcup
1: # ~/.config/profile.d/99-ghcup.sh 2: # haskell's ghcup configuration 3: # <alexforsale@yahoo.com> 4: 5: [ -f "/home/alexforsale/.ghcup/env" ] && source "/home/alexforsale/.ghcup/env" # ghcup-env 6: 7: if [ -d "${HOME}/.ghcup/bin" ]; then 8: contains "${PATH}" "${HOME}/.ghcup/bin" || 9: export PATH="${HOME}/.ghcup/bin:${PATH}" 10: fi
go
1: # ~/.config/profile.d/99-go.sh 2: # $GOPATH configuration 3: # <alexforsale@yahoo.com> 4: 5: if [ "$(command -v go)" ];then 6: # set GOPATH to ~/.local so we don't need 7: # to add more PATH 8: export GOPATH=${GOPATH:-~/.local} 9: fi
guix
1: # ~/.config/profile.d/99-guix.sh 2: # guix configuration 3: # <alexforsale@yahoo.com> 4: 5: if [ $(command -v guix) ]; then 6: if [ -n "${GUIX_LOCPATH}" ];then 7: # add /bin and /usr/bin to path 8: # to add more PATH 9: export PATH=${PATH}:/bin 10: export PATH=${PATH}:/usr/bin 11: # set the GUIX_BUILD_OPTIONS 12: contains "${GUIX_BUILD_OPTIONS}" "-v 3 -c 2 -M 2" || 13: export GUIX_BUILD_OPTIONS="${GUIX_BUILD_OPTIONS} -v 3 -c 2 -M 2" 14: if [ -d "${HOME}/.guix-profile/bin" ]; then 15: export PATH="${HOME}/.guix-profile/bin:${PATH}" 16: fi 17: if [ -d "${HOME}/.guix-profile/sbin" ]; then 18: export PATH="${HOME}/.guix-profile/sbin:${PATH}" 19: fi 20: fi 21: 22: if [ -d "${HOME}/.guix-profile/share/emacs/site-lisp" ]; then 23: contains "${EMACSLOADPATH}" "${HOME}/.guix-profile/share/emacs/site-lisp" || 24: export EMACSLOADPATH="${HOME}/.guix-profile/share/emacs/site-lisp:${EMACSLOADPATH}" 25: contains "${XDG_DATA_DIRS}" "${HOME}/.guix-profile/share" || 26: export XDG_DATA_DIRS="${HOME}/.guix-profile/share:${XDG_DATA_DIRS}" 27: fi 28: fi 29: 30: export QT_XCB_GL_INTEGRATION=none
Kinda redundant, if I'm using guix, this repository would never be used.
Opam
1: # ~/.config/profile.d/99-nano.sh 2: # <alexforsale@yahoo.com> 3: 4: if [ "$(command -v opam)" ]; then 5: eval "$(opam env)" 6: fi
nano
1: # ~/.config/profile.d/99-nano.sh 2: # see https://nano-editor.org 3: # <alexforsale@yahoo.com> 4: 5: if [ "$(command -v nano)" ]; then 6: if [ ! -d "${XDG_CONFIG_HOME}/nano" ]; then 7: mkdir -p "${XDG_CONFIG_HOME}/nano" 8: if [ -f "${HOME}/.nanorc" ]; then 9: mv "${HOME}/.nanorc" "${XDG_CONFIG_HOME}/nanorc" 10: fi 11: else 12: if [ -f "${HOME}/.nanorc" ]; then 13: mv "${HOME}/.nanorc" "${XDG_HOME_CONFIG}/nanorc.bak" 14: fi 15: fi 16: # backups 17: mkdir -p "${XDG_CONFIG_HOME}/nano/backups" 18: fi
My first exposure to the command line. Though I don't use nano anymore.
nix
1: # ~/.config/profile.d/99-nix.sh 2: # nix configuration 3: # <alexforsale@yahoo.com> 4: 5: [ -d "${HOME}/.nix-profile/bin" ] && export PATH=${PATH}:${HOME}/.nix-profile/bin 6: 7: if [ -n "${GUIX_LOCPATH}" ]; then 8: # source profile.d 9: [ -e /run/current-system/profile/etc/profile.d/nix.sh ] && . /run/current-system/profile/etc/profile.d/nix.sh 10: [ -e /run/current-system/profile/etc/profile.d/nix-daemon.sh ] && . /run/current-system/profile/etc/profile.d/nix-daemon.sh 11: if [ -d "${HOME}/.nix-profile/share/icons" ]; then 12: contains "${XCURSOR_PATH}" "${HOME}/.nix-profile/share/icons" || 13: export XCURSOR_PATH="${XCURSOR_PATH}:${HOME}/.nix-profile/share/icons" 14: fi 15: if [ -d "${HOME}/.nix-profile/share" ]; then 16: contains "${XDG_DATA_DIRS}" "${HOME}/.nix-profile/share" || 17: export XDG_DATA_DIRS="${HOME}/.nix-profile/share:${XDG_DATA_DIRS}" 18: fi 19: fi
Hipsters use nix.
npm
1: # ~/.config/profile.d/99-npm.sh 2: # node packaged module configuration 3: # see https://wiki.archlinux.org/index.php/Node.js 4: # <alexforsale@yahoo.com> 5: 6: if [ -d "${HOME}/.config/nvm" ]; then 7: export NVM_DIR="${HOME}/.config/nvm" 8: [ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh" # This loads nvm 9: [ -n "${BASH}" ] && 10: [ -s "${NVM_DIR}/bash_completion" ] && \. "${NVM_DIR}/bash_completion" # This loads nvm bash_completion 11: if [ -n "${npm_config_prefix}" ]; then 12: unset npm_config_prefix 13: fi 14: elif [ "$(command -v npm)" ] && [ ! "$(command -v nvm)" ]; then 15: export npm_config_prefix="${HOME}/.local" 16: fi
password-store
1: # ~/.config/profile.d/99-password-store.sh 2: # configuration for pass 3: # <alexforsale@yahoo.com> 4: 5: if [ -f /run/current-system/profile/lib/password-store/extensions/otp.bash ]; then 6: [ ! -L "${HOME}/.password-store/.extensions/otp.bash" ] && 7: ln -s /run/current-system/profile/lib/password-store/extensions/otp.bash \ 8: "${HOME}/.password-store/.extensions/" 9: export PASSWORD_STORE_ENABLE_EXTENSIONS=true 10: fi
This app should have more love!
perl
1: # ~/.config/profile.d/99-perl.sh 2: # configuration for perl 3: # <alexforsale@yahoo.com> 4: 5: [ ! -d "${HOME}/.local/perl5/bin" ] && 6: mkdir -p "${HOME}/.local/perl5/bin" 7: [ ! -d "${HOME}/.local/perl5/lib/perl5" ] && 8: mkdir -p "${HOME}/.local/perl5/lib/perl5" 9: 10: PATH="${HOME}/.local/perl5/bin${PATH:+:${PATH}}" 11: PERL5LIB="${HOME}/.local/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}" 12: PERL_LOCAL_LIB_ROOT="${HOME}/.local/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}" 13: PERL_MB_OPT="--install_base \"${HOME}/.local/perl5\"" 14: PERL_MM_OPT="INSTALL_BASE=${HOME}/.local/perl5" 15: 16: export PATH PERL5LIB PERL_LOCAL_LIB_ROOT PERL_MB_OPT PERL_MM_OPT
python
1: # ~/.config/profile.d/99-python.sh 2: # Python configuration 3: # <alexforsale@yahoo.com> 4: 5: if [ $(command -v pipenv) ]; then 6: [ -z "${PIPENV_VENV_IN_PROJECT}" ] && 7: export PIPENV_VENV_IN_PROJECT=1 8: fi 9: 10: # pyenv 11: if [ $(command -v pyenv) ]; then 12: eval "$(pyenv init -)" 13: fi
ruby
1: # ~/.config/profile.d/99-ruby.sh 2: # ruby configuration 3: # <alexforsale@yahoo.com> 4: 5: if [ "$(command -v ruby)" ] && 6: [ -d "$(ruby -e 'print Gem.user_dir')/bin" ];then 7: PATH="$(ruby -e 'print Gem.user_dir')/bin:$PATH" 8: export GEM_HOME="$(ruby -e 'puts Gem.user_dir')" 9: fi 10: 11: export PATH
screen
# ~/.config/profile.d/99-screen.sh # configuration for GNU Screen # <alexforsale@yahoo.com> if [ "$(command -v screen)" ] && [ ! -d "${XDG_CONFIG_HOME}/screen" ]; then if [ -d "${HOME}/.screen" ]; then mv "${HOME}/.screen" "${XDG_CONFIG_HOME}/screen" else mkdir -p "${XDG_CONFIG_HOME}/screen" fi fi export SCREENDIR="${XDG_CONFIG_HOME}/screen" chmod 700 "${SCREENDIR}" export SCREENRC="${SCREENDIR}/config"
Better than tmux. That statement just to annoy tmux users.
virtualenvwrapper
# ~/.config/profile.d/99-virtualenvwrapper.sh # configuration for virtualenvwrapper # <alexforsale@yahoo.com> if [ -d "${HOME}/.virtualenvs" ]; then export WORKON_HOME="${HOME}/.virtualenvs" fi if [ -x /usr/bin/virtualenvwrapper.sh ]; then . /usr/bin/virtualenvwrapper.sh fi