aboutsummaryrefslogtreecommitdiff
path: root/.config/shell/sources
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2019-10-02 16:35:18 +0200
committerPatrick Spek <p.spek@tyil.nl>2019-10-02 16:35:18 +0200
commitd62f1d1673fc0a319ea4581dee0f6085b1f70005 (patch)
tree78ea262acbdf6b43ed9c7c3f18b8012867e40615 /.config/shell/sources
parent06d7914df92c78469b84220aee5e18f2517af1dc (diff)
Add shell configs
Diffstat (limited to '.config/shell/sources')
-rw-r--r--.config/shell/sources105
1 files changed, 105 insertions, 0 deletions
diff --git a/.config/shell/sources b/.config/shell/sources
new file mode 100644
index 0000000..c4acb5e
--- /dev/null
+++ b/.config/shell/sources
@@ -0,0 +1,105 @@
+#!/bin/usr/env sh
+# Author: Patrick Spek <p.spek@tyil.nl>
+# License: BSD 3-clause license
+#
+# Apparently tmux likes to unset your PATH variable. As a workaround the PATH
+# will be unset completely at the start of this script, then reset using this
+# script. This was the only viable method for me to keep my PATH clean
+[ "${DEBUG_DOTFILES}" ] && echo "Unsetting PATH"
+unset PATH
+
+[ "${DEBUG_DOTFILES}" ] && echo "Setting PATH"
+
+# User-local bin dir
+PATH="${HOME}/.local/bin"
+
+# Personal scripts and wrappers
+PATH="${PATH}:${HOME}/.scripts/generic"
+PATH="${PATH}:${HOME}/.config/shell/wrappers.d"
+
+# Language specific package manager bin dirs
+PATH="${PATH}:${HOME}/.perl6/bin"
+PATH="${PATH}:${HOME}/.cabal/bin"
+
+# System bin dirs
+PATH="${PATH}:/bin"
+PATH="${PATH}:/sbin"
+PATH="${PATH}:/usr/bin"
+PATH="${PATH}:/usr/sbin"
+PATH="${PATH}:/usr/local/bin"
+PATH="${PATH}:/usr/local/sbin"
+PATH="${PATH}:/usr/games/bin"
+PATH="${PATH}:/opt/bin"
+
+# Nix package manager
+if [ -f "$HOME/.nix-profile/etc/profile.d/nix.sh" ]
+then
+ # In case of single-user Nix installation
+ . "$HOME/.nix-profile/etc/profile.d/nix.sh"
+else
+ if [ -d "/nix/var/nix/profiles/per-user/${USER}" ]
+ then
+ # In case of multi-user Nix installation
+ PATH="${PATH}:/nix/var/nix/profiles/per-user/${USER}/profile/bin"
+ fi
+fi
+
+[ "${DEBUG_DOTFILES}" ] && echo "Setting FPATH"
+FPATH="${HOME}/.config/shell/completion ${FPATH}"
+
+[ "${DEBUG_DOTFILES}" ] && echo "Sourcing ~/.config/shell/env"
+# shellcheck disable=SC1090
+. "${HOME}/.config/shell/env"
+
+if [ -f "${HOME}/.local/etc/shell/env" ]
+then
+ [ "${DEBUG_DOTFILES}" ] && echo "Sourcing ~/.local/etc/shell/env"
+ # shellcheck disable=SC1090
+ . "${HOME}/.local/etc/shell/env"
+fi
+
+# if ruby is installed and we have a gems folder, include it in the path
+if ruby -v > /dev/null 2>&1
+then
+ GEMDIR="$(ruby -r rubygems -e 'puts Gem.user_dir')/bin"
+
+ if [ -d "$GEMDIR" ]
+ then
+ [ "$DEBUG_DOTFILES" ] && echo "Extending PATH with $GEMDIR"
+ PATH="$GEMDIR:$PATH"
+ fi
+fi
+
+# Add machine-specific paths from ~/.local/etc/shell/path
+if [ -f "$HOME/.local/etc/shell/path" ]
+then
+ for p in $(envsubst < "$HOME/.local/etc/shell/path")
+ do
+ PATH="$PATH:$p"
+ done
+fi
+
+# export the extended PATH
+export PATH
+
+# Add aliases
+. "$HOME/.config/shell/aliases"
+
+# Add custom functions
+#. "$HOME/.config/shell/functions"
+
+# Load profile
+if [ -f "${HOME}/.config/shell/profile" ]
+then
+ [ "${DEBUG_DOTFILES}" ] && echo " Loading ~/.config/shell/init"
+ #shellcheck disable=1090
+ . "${HOME}/.config/shell/profile"
+fi
+
+
+# show motd
+if [ -f "${HOME}/.config/shell/motd" ]; then
+ [ "${DEBUG_DOTFILES}" ] && echo "Reading motd"
+ # shellcheck disable=SC1090
+ . "${HOME}/.config/shell/motd"
+fi