about summary refs log tree commit diff stats
path: root/profile
diff options
context:
space:
mode:
Diffstat (limited to 'profile')
-rw-r--r--profile/00_functions.sh62
-rw-r--r--profile/01_path.sh6
-rw-r--r--profile/etc.sh2
-rw-r--r--profile/go.sh2
-rw-r--r--profile/infopath.sh8
-rw-r--r--profile/manpath.sh16
-rw-r--r--profile/path.sh30
-rw-r--r--profile/profile10
-rw-r--r--profile/xdg.sh7
9 files changed, 105 insertions, 38 deletions
diff --git a/profile/00_functions.sh b/profile/00_functions.sh new file mode 100644 index 0000000..a94eaee --- /dev/null +++ b/profile/00_functions.sh
@@ -0,0 +1,62 @@
1# utility functions for all shells
2# these should be POSIX-compatible.
3
4# add a path to PATH, but only if it's not already there
5path_add_to_PATH() { # path_add [-a] PATH...
6 # -a appends (default is prepend)
7 APPEND=false
8 if [ "x$1" = "x-a" ]; then
9 APPEND=true
10 shift
11 fi
12
13 for p; do
14 case ":$PATH:" in
15 *:"$p":*) ;;
16 *)
17 if $APPEND; then
18 PATH="$PATH:$p"
19 else
20 PATH="$p:$PATH"
21 fi
22 ;;
23 esac
24 done
25
26 unset APPEND
27}
28
29# Generalization of `path_add_to_PATH' for any variable.
30path_add_unsafe() { #path_add_unsafe [-a] [-d DELIM] VAR PATH...
31 ## Add PATH... to VAR, delimiting with DELIM (default :).
32 # By default, the VAR will be prepended to; passing -a will append the
33 # variable. -d DELIM defines the delimiter.
34 #
35 # This function has the _unsafe suffix because it uses `eval' to set
36 # variables.
37 APPEND=false; DELIM=:
38 while getopts ad: opt; do
39 case "$opt" in
40 a) APPEND=true ;;
41 d) DELIM="$OPTARG" ;;
42 *) return 1 ;;
43 esac
44 done
45 shift $(expr $OPTIND - 1)
46
47 var="$1"; shift
48
49 for path; do
50 case ":$(eval "echo \$$var"):" in
51 *:"$path":*) ;;
52 *)
53 if $APPEND; then
54 eval "$var=\$$var${var:+$DELIM}$path"
55 else
56 eval "$var=$path${var:+$DELIM}\$$var"
57 fi
58 ;;
59 esac
60 done
61 unset -v APPEND DELIM var
62}
diff --git a/profile/01_path.sh b/profile/01_path.sh new file mode 100644 index 0000000..8082cc6 --- /dev/null +++ b/profile/01_path.sh
@@ -0,0 +1,6 @@
1# PATH
2
3# see 00_functions.sh for `path_add'
4path_add_to_PATH "$HOME/bin" "$HOME/usr/bin"
5
6command -v luarocks >/dev/null 2>&1 && path_add "$HOME/.luarocks/bin"
diff --git a/profile/etc.sh b/profile/etc.sh index b91c4c8..0546fe2 100644 --- a/profile/etc.sh +++ b/profile/etc.sh
@@ -2,7 +2,7 @@
2 2
3export GUILE_INSTALL_LOCALE=0 3export GUILE_INSTALL_LOCALE=0
4export TZ=America/Chicago 4export TZ=America/Chicago
5export QT_STYLE_OVERRIDE=adwaita-qt 5#export QT_STYLE_OVERRIDE=adwaita-qt
6export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/keyring/ssh" 6export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/keyring/ssh"
7 7
8export CDPATH=:~ # thanks june :) 8export CDPATH=:~ # thanks june :)
diff --git a/profile/go.sh b/profile/go.sh new file mode 100644 index 0000000..077833e --- /dev/null +++ b/profile/go.sh
@@ -0,0 +1,2 @@
1export GOPATH="${XDG_DATA_HOME:=$HOME/.local/share}/go"
2command -v go >/dev/null 2>&1 && path_add_to_PATH "$(go env GOPATH)/bin"
diff --git a/profile/infopath.sh b/profile/infopath.sh index ad1ec3f..80080b8 100644 --- a/profile/infopath.sh +++ b/profile/infopath.sh
@@ -1 +1,7 @@
1export INFOPATH="/usr/share/info:${XDG_DATA_HOME:-$HOME/.local/share}/info" 1# See 00_functions.sh for `path_add_unsafe'.
2
3path_add_unsafe INFOPATH \
4 /usr/share/info \
5 "${XDG_DATA_HOME:-$HOME/.local/share}/info"
6
7export INFOPATH
diff --git a/profile/manpath.sh b/profile/manpath.sh index def1963..944059c 100644 --- a/profile/manpath.sh +++ b/profile/manpath.sh
@@ -1,9 +1,15 @@
1# $MANPATH shouldn't be too extra complicated (as opposed to $PATH), 1# See 00_functions.sh for `path_add_unsafe'.
2# so I'm not going to include a whole other function. AT SOME POINT, 2
3# I suppose I should generalize that function to set /any/ path-type 3path_add_unsafe MANPATH \
4# variable, not just $PATH. 4 "${XDG_DATA_HOME:-$HOME/.local/share}/man" \
5 "$HOME/.local/local/man" \
6 "$HOME/usr/local/man"
7
5# $MANPATH ends with `:' so that manpath(1) will prepend it to its 8# $MANPATH ends with `:' so that manpath(1) will prepend it to its
6# special thing. 9# special thing.
10case "$MANPATH" in
11 *:) ;;
12 *) MANPATH="$MANPATH:" ;;
13esac
7 14
8MANPATH="${XDG_DATA_HOME:-$HOME/.local/share}/man:"
9export MANPATH 15export MANPATH
diff --git a/profile/path.sh b/profile/path.sh deleted file mode 100644 index 56bdc39..0000000 --- a/profile/path.sh +++ /dev/null
@@ -1,30 +0,0 @@
1# PATH
2
3# add a path to PATH, but only if it's not already there
4path_add() { # path_add [-a] PATH...
5 # -a appends (default is prepend)
6 APPEND=false
7 if [ "x$1" = "x-a" ]; then
8 APPEND=true
9 shift
10 fi
11
12 for p; do
13 case ":$PATH:" in
14 *:"$p":*) ;;
15 *)
16 if $APPEND; then
17 PATH="$PATH:$p"
18 else
19 PATH="$p:$PATH"
20 fi
21 ;;
22 esac
23 done
24
25 unset APPEND
26}
27
28path_add "$HOME/bin" "$HOME/usr/bin"
29
30command -v luarocks >/dev/null 2>&1 && path_add "$HOME/.luarocks/bin"
diff --git a/profile/profile b/profile/profile index 121615f..a531e8e 100644 --- a/profile/profile +++ b/profile/profile
@@ -18,3 +18,13 @@ if [ -d "$XDG_CONFIG_HOME/profile" ]; then
18 [ -r "$file" ] && . "$file" 18 [ -r "$file" ] && . "$file"
19 done 19 done
20fi 20fi
21
22# refresh profile
23reprofile() {
24 printf "Loading ~/.profile..." >&2
25 if . "$HOME/.profile"; then
26 echo "OK." >&2
27 else
28 echo "ERROR!" >&2
29 fi
30}
diff --git a/profile/xdg.sh b/profile/xdg.sh index 7d0ed61..71ab6bb 100644 --- a/profile/xdg.sh +++ b/profile/xdg.sh
@@ -13,7 +13,7 @@ export LESSHISTFILE="$XDG_CACHE_HOME"/less/history
13mkdir -p "$XDG_CACHE_HOME"/less 13mkdir -p "$XDG_CACHE_HOME"/less
14 14
15# Vim 15# Vim
16export VIMINIT="let \$MYVIMRC=\"$XDG_CONFIG_HOME/vim/vimrc\" | source \$MYVIMRC" 16export VIMINIT="source ${XDG_CONFIG_HOME:=$HOME/.config}/vim/vimrc"
17 17
18# Weechat 18# Weechat
19export WEECHAT_HOME="$XDG_CONFIG_HOME/weechat" 19export WEECHAT_HOME="$XDG_CONFIG_HOME/weechat"
@@ -23,3 +23,8 @@ export LYNX_CFG="$XDG_CONFIG_HOME/lynx/lynx.cfg"
23 23
24# Xorg 24# Xorg
25export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-$HOME}" 25export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-$HOME}"
26export XINITRC="$XDG_CONFIG_HOME/X11/xinitrc"
27export XSERVERRC="$XDG_CONFIG_HOME/X11/xserverrc"
28
29# Notmuch
30export NOTMUCH_CONFIG="${XDG_CONFIG_HOME:=$HOME/.config}/notmuch/config"