-
Notifications
You must be signed in to change notification settings - Fork 1
/
.profile
96 lines (79 loc) · 3.52 KB
/
.profile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/sh
# =============================================================================
# ~/.profile
# -----------------------------------------------------------------------------
# This file sets up the environment for all login shells for this user.
#
# Note that this file is written as a POSIX-compliant shell script to ensure
# that its contents can be read regardless of the chosen shell.
# =============================================================================
# =============================================================================
# ENVIRONMENT
# =============================================================================
# Explicitly set variables related to the XDG base directory specification.
XDG_CACHE_HOME="$HOME/.cache"
XDG_CONFIG_HOME="$HOME/.config"
XDG_DATA_HOME="$HOME/.local/share"
[ -z "$XDG_RUNTIME_DIR" ] && export XDG_RUNTIME_DIR="/run/user/$(id -u)"
export XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME
# Set the default pager and disable history for it.
PAGER='less'
MANPAGER="$PAGER"
LESSHISTFILE=-
export PAGER MANPAGER
# Set the default editor for terminal applications.
EDITOR='vim'
VISUAL="$EDITOR"
export EDITOR VISUAL
# Read the ~/.config/vim/vimrc file when opening Vim. This effectively replaces
# the ~/.vimrc file used by default, conforming to the XDG Base Directory
# specification.
export VIMINIT='let $MYVIMRC="$XDG_CONFIG_HOME/vim/vimrc" | source $MYVIMRC'
# Redefine where the configuration file for `readline` resides, conforming to
# the XDG Base Directory specification.
export INPUTRC="$XDG_CONFIG_HOME/readline/inputrc"
# Set the default terminal emulator, screen locker, and web browser for X.
XTERMINAL='st'
XLOCKER='slock'
XBROWSER='firefox'
export XTERMINAL XLOCKER XBROWSER
# Ensure we have access to the $DISPLAY environment variable within a terminal
# multiplexer. This allows us to open graphical applications.
if [ -z "$DISPLAY" ] && [ -n "$(pidof X)" ] && [ "$TERM" == 'screen' ] ; then
export DISPLAY=:0
fi
# =============================================================================
# FUNCTIONS
# =============================================================================
# =============================================================================
# Function: __prepend_path__(dir)
# -----------------------------------------------------------------------------
# Adds the given argument to the $PATH environment variable if it does not
# already exist.
# =============================================================================
__prepend_path__() {
case ":$PATH:" in
*:"$1":*) ;; # Do nothing if the path already exists.
*) PATH="$1:${PATH:+$PATH}" ;;
esac
}
# =============================================================================
# PATHS
# =============================================================================
# Set up the environment for Go development if we have the Go compiler
# installed.
[ -x "$(command -v go)" ] && {
export GOPATH="$HOME/doc/src/go"
[ ! -d "$GOPATH/bin" ] && mkdir -p "$GOPATH/bin"
__prepend_path__ "$GOPATH/bin"
}
# Add the directory for cargo binaries to our `$PATH` if it exists.
[ -d "$HOME/.cargo/bin" ] && __prepend_path__ "$HOME/.cargo/bin"
# Load local profile settings if they exist.
[ -r "$XDG_CONFIG_HOME/sh/profile.local" ] && \
. "$XDG_CONFIG_HOME/sh/profile.local"
# Add the `~/.local/bin` directory to the `$PATH` if it exists.
[ -d "$HOME/.local/bin" ] && __prepend_path__ "$HOME/.local/bin"
# Add the `~/bin` directory to `$PATH` if it exists.
[ -d "$HOME/bin" ] && __prepend_path__ "$HOME/bin"
unset __prepend_path__