-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathenvironment
99 lines (85 loc) · 3.12 KB
/
environment
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
97
98
99
#
# Tureba's shell-agnostic environment settings
#
# To use it, source this from the shell resource files.
#
# who: Arthur Nascimento <[email protected]>
# where: github.com/tureba/myconfigfiles
#
# if TERM st and it is not available, fallback to xterm
if [[ $TERM =~ '^st\b' ]]; then
infocmp $TERM &>/dev/null || TERM=xterm${TERM#st}
fi
# prepend paths to variables only when they aren't yet set
() {
while [[ ${#@} -ge 2 ]]; do
eval "[[ \$$1 =~ \"(^|:)$2(:|$)\" ]] || export $1=\"$2\${$1:+:\${$1}}\""
shift 2
done
} \
PATH "${HOME}/local/bin" \
PATH "${HOME}/.local/bin" \
LD_LIBRARY_PATH "${HOME}/local/lib" \
LD_LIBRARY_PATH "${HOME}/.local/lib" \
MANPATH "${HOME}/local/share/man"
# LC_ALL would overide all others
unset LC_ALL
# system messages shouldn't be translated
export LC_MESSAGES=C
# prefer YYYY-MM-DD HH:mm (ISO 8601)
# TODO: find a better solution
#export LC_TIME=en_DK.UTF-8
# it's a safe failback nowadays
LANG=$(locale -a | grep -e '^C.[uU][tT][fF]-\?8$')
export LANG=${LANG:-C}
export EDITOR=vim
export PAGER=less
which htop &>/dev/null && alias top=htop
# case insensitive search, squeeze blank lines, chop long lines, long prompt, display raw characters, shift right/left by 1/10th of screen size
export LESS="-i -s -S -M -R -# .1"
if [[ $- =~ i ]]; then
# less, man, most etc colors
export LESS_TERMCAP_mb=$(tput bold; tput setaf 2)
export LESS_TERMCAP_md=$(tput bold; tput setaf 6)
export LESS_TERMCAP_me=$(tput sgr0)
export LESS_TERMCAP_so=$(tput bold; tput setaf 3; tput setab 4)
export LESS_TERMCAP_se=$(tput rmso; tput sgr0)
export LESS_TERMCAP_us=$(tput smul; tput bold; tput setaf 7)
export LESS_TERMCAP_ue=$(tput rmul; tput sgr0)
export LESS_TERMCAP_mr=$(tput rev)
export LESS_TERMCAP_mh=$(tput dim)
export LESS_TERMCAP_ZN=$(tput ssubm)
export LESS_TERMCAP_ZV=$(tput rsubm)
export LESS_TERMCAP_ZO=$(tput ssupm)
export LESS_TERMCAP_ZW=$(tput rsupm)
fi
# follow the XDG Base and User Directory Specifications
export XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share}
export XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
export XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache}
export XDG_DOWNLOAD_DIR=${XDG_DOWNLOAD_DIR:-$HOME/.download}
export XDG_DESKTOP_DIR=${XDG_DESKTOP_DIR:-$HOME}
export INPUTRC=~/.inputrc
export VIMINIT='let $MYVIMRC="$XDG_CONFIG_HOME/vim/vimrc" | source $MYVIMRC'
### setup the key agent ###
SSH_ENV="$HOME/.ssh/environment"
# Source SSH settings, if applicable
[ -f "${SSH_ENV}" ] && . "${SSH_ENV}" &>/dev/null
# if the agent is not running, start it
grep -q ssh-agent /proc/${SSH_AGENT_PID}/cmdline &>/dev/null || {
ssh-agent | (umask 077 ; sed /echo/d >"${SSH_ENV}")
. "${SSH_ENV}" &>/dev/null
}
# add all known keys
ssh-add -l &>/dev/null || ssh-add 2>/dev/null
unset SSH_ENV
# cd relative to git's project root
function cdg {
cd "$(git rev-parse --show-toplevel)/$1"
}
# send SMS
function smstocel {
m=$(mmcli --list-modems | awk '/ModemManager/{print $1; exit}')
s=$(mmcli -m ${m:?error no modem} --messaging-create-sms="text='$@',number='${CEL:?error no cell}'" | awk '/ModemManager/{print $1; exit}')
mmcli -s ${s:?error no sms} --send && mmcli -m $m --messaging-delete-sms=$s
}