Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
# XDG Base Directory Specification
|
|
|
|
#
|
|
|
|
# Sets up necessary environment variables for XDG convention,
|
|
|
|
# and those that applications obey for their environments.
|
|
|
|
#
|
|
|
|
# Thank you remeberYou for the idea
|
|
|
|
# see: https://github.com/rememberYou/dotfiles/blob/master/sh/.config/sh/xdg
|
|
|
|
#
|
|
|
|
# Additionally, home directories are set using the XDG specification,
|
|
|
|
# if the xdg-user-dirs module is enabled.
|
|
|
|
#
|
|
|
|
# Shellcheck will complain about setting permissions for the directories
|
|
|
|
# unless it is ignored https://github.com/koalaman/shellcheck/wiki/SC2174
|
|
|
|
# shellcheck disable=SC2174
|
|
|
|
|
|
|
|
# http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
|
|
|
test "$XDG_CACHE_HOME" || export XDG_CACHE_HOME="$HOME/.cache"
|
|
|
|
test "$XDG_CONFIG_HOME" || export XDG_CONFIG_HOME="$HOME/.config"
|
|
|
|
test "$XDG_DATA_HOME" || export XDG_DATA_HOME="$HOME/.local/share"
|
2022-06-28 08:20:57 +00:00
|
|
|
test "$XDG_STATE_HOME" || export XDG_STATE_HOME="$HOME/.local/state"
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
|
2020-07-24 07:39:07 +00:00
|
|
|
# Desktop environment XDG variables - mimics `xdg-user-dirs` settings, only lowercased and not localized
|
|
|
|
test "$XDG_DESKTOP_DIR" || export XDG_DESKTOP_DIR="$HOME/desktop"
|
|
|
|
test "$XDG_DOCUMENTS_DIR" || export XDG_DOCUMENTS_DIR="$HOME/documents"
|
|
|
|
test "$XDG_DOWNLOAD_DIR" || export XDG_DOWNLOAD_DIR="$HOME/downloads"
|
2021-04-17 07:54:53 +00:00
|
|
|
|
2023-03-03 11:54:55 +00:00
|
|
|
export XDG_MEDIA_DIR="$HOME/media"
|
|
|
|
export XDG_MUSIC_DIR="$XDG_MEDIA_DIR/audio/music"
|
2021-11-16 11:01:11 +00:00
|
|
|
export XDG_PICTURES_DIR="$HOME/pictures"
|
|
|
|
export XDG_VIDEOS_DIR="$HOME/videos"
|
2020-07-24 07:39:07 +00:00
|
|
|
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
## Non-Standard additions
|
|
|
|
# non-standard, is added to path to enable execution of any files herein
|
2022-06-28 08:20:57 +00:00
|
|
|
test "$XDG_PROJECTS_DIR" || export XDG_PROJECTS_DIR="$HOME/projects"
|
2022-06-28 09:10:34 +00:00
|
|
|
test "$XDG_BIN_HOME" || export XDG_BIN_HOME="$HOME/.local/bin"
|
|
|
|
# anything on BIN_HOME should be executable form anywhere
|
|
|
|
export PATH="$PATH:$XDG_BIN_HOME"
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
|
2021-04-13 07:17:54 +00:00
|
|
|
xdg_isThere() {
|
|
|
|
if [ -e "$1" ] || [ -h "$1" ]; then
|
|
|
|
true
|
|
|
|
else
|
|
|
|
false
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
xdg_makeForUser() {
|
|
|
|
mkdir -p "$1"
|
|
|
|
chmod 0700 "$1"
|
|
|
|
}
|
|
|
|
|
2023-03-03 11:54:55 +00:00
|
|
|
if [ -h "$XDG_MEDIA_DIR" ] && [ ! -e "$XDG_MEDIA_DIR" ]; then
|
|
|
|
rm "$XDG_MEDIA_DIR"
|
|
|
|
xdg_makeForUser "$XDG_MEDIA_DIR"
|
|
|
|
fi
|
|
|
|
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
## ensure directories exist
|
2021-04-13 07:17:54 +00:00
|
|
|
xdg_isThere "$XDG_BIN_HOME" || xdg_makeForUser "$XDG_BIN_HOME"
|
|
|
|
xdg_isThere "$XDG_CACHE_HOME" || xdg_makeForUser "$XDG_CACHE_HOME"
|
|
|
|
xdg_isThere "$XDG_CONFIG_HOME" || xdg_makeForUser "$XDG_CONFIG_HOME"
|
|
|
|
xdg_isThere "$XDG_DATA_HOME" || xdg_makeForUser "$XDG_DATA_HOME"
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
|
2020-07-24 07:39:07 +00:00
|
|
|
# create xdg-user-dirs if necessary
|
2021-04-13 07:17:54 +00:00
|
|
|
xdg_isThere "$XDG_DESKTOP_DIR" || xdg_makeForUser "$XDG_DESKTOP_DIR"
|
|
|
|
xdg_isThere "$XDG_DOCUMENTS_DIR" || xdg_makeForUser "$XDG_DOCUMENTS_DIR"
|
|
|
|
xdg_isThere "$XDG_DOWNLOAD_DIR" || xdg_makeForUser "$XDG_DOWNLOAD_DIR"
|
|
|
|
xdg_isThere "$XDG_MUSIC_DIR" || xdg_makeForUser "$XDG_MUSIC_DIR"
|
|
|
|
xdg_isThere "$XDG_PICTURES_DIR" || xdg_makeForUser "$XDG_PICTURES_DIR"
|
|
|
|
xdg_isThere "$XDG_VIDEOS_DIR" || xdg_makeForUser "$XDG_VIDEOS_DIR"
|
2021-11-16 11:01:11 +00:00
|
|
|
xdg_isThere "$XDG_PROJECTS_DIR" || xdg_makeForUser "$XDG_PROJECTS_DIR"
|
2021-04-13 07:17:54 +00:00
|
|
|
|
|
|
|
unset -f xdg_isThere xdg_makeForUser
|
2020-07-24 07:39:07 +00:00
|
|
|
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
## Applications that can be set through environment variables
|
2022-06-28 09:10:34 +00:00
|
|
|
export ANDROID_HOME="$XDG_DATA_HOME/android"
|
|
|
|
export ATOM_HOME="$XDG_DATA_HOME/atom"
|
|
|
|
export CARGO_HOME="$XDG_DATA_HOME/cargo"
|
|
|
|
export GEM_HOME="$XDG_DATA_HOME/gem"
|
|
|
|
export GEM_SPEC_CACHE="$XDG_CACHE_HOME/gem"
|
|
|
|
export GNUPGHOME="$XDG_DATA_HOME/gnupg"
|
|
|
|
export GRADLE_USER_HOME="$XDG_DATA_HOME/gradle"
|
|
|
|
export GRIPHOME="$XDG_CONFIG_HOME/grip"
|
|
|
|
export IMAPFILTER_HOME="$XDG_CONFIG_HOME/imapfilter"
|
|
|
|
export IPYTHONDIR="$XDG_CONFIG_HOME/ipython"
|
|
|
|
export KDEHOME="$XDG_CONFIG_HOME/kde"
|
|
|
|
export KODI_DATA="$XDG_DATA_HOME/kodi"
|
|
|
|
export LESSHISTFILE="XDG_STATE_HOME/lesshst"
|
|
|
|
export MPLAYER_HOME="$XDG_CONFIG_HOME/mplayer"
|
|
|
|
export NODE_REPL_HISTORY="$XDG_STATE_HOME/node_repl_history"
|
2020-02-06 19:30:35 +00:00
|
|
|
export NVM_DIR="$XDG_DATA_HOME/nvm"
|
2022-12-08 20:34:40 +00:00
|
|
|
if [ ! -e "$PYTHONSTARTUP" ]; then
|
|
|
|
mkdir -p "$XDG_CONFIG_HOME/python"
|
|
|
|
touch "$PYTHONSTARTUP"
|
|
|
|
fi
|
2022-06-28 09:10:34 +00:00
|
|
|
export PYTHONSTARTUP="$XDG_CONFIG_HOME/python/pythonrc"
|
|
|
|
export SQLITE_HISTORY="$XDG_STATE_HOME/sqlite_history"
|
|
|
|
export TEXMFVAR="$XDG_CACHE_HOME/texlive/texmf-var"
|
2020-02-06 19:30:35 +00:00
|
|
|
export TMUX_PLUGIN_MANAGER_PATH="$XDG_DATA_HOME/tmux"
|
2022-06-28 09:10:34 +00:00
|
|
|
export VAGRANT_HOME="$XDG_DATA_HOME/vagrant"
|
|
|
|
export WINEPREFIX="$XDG_DATA_HOME/wine"
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
export ZDOTDIR="$XDG_CONFIG_HOME/zsh"
|
2022-06-28 09:10:34 +00:00
|
|
|
export _JAVA_OPTIONS=-Djava.util.prefs.userRoot="$XDG_CONFIG_HOME"/java
|
|
|
|
|
|
|
|
alias yarn='yarn --use-yarnrc "$XDG_CONFIG_HOME/yarn/config"'
|
|
|
|
alias wget='wget --hsts-file="$XDG_STATE_HOME/wget-hsts"'
|