summaryrefslogtreecommitdiff
path: root/.shenv
blob: 2ae1b59d431f7c081a01280bae5a565521803557 (plain)
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/bin/sh

# Environment variables for X and all text-mode shells: bash, Xsession
# and scripts run by cron all source this.  So POSIX only.

# We have calls to `which` which we expect to fail
set +e

# ---- choose editor depending on what's available

if [ "$DESKTOP_SESSION" = "i3" ]; then
    ec="emacsclient -c"
else
    ec="emacsclient -t"
fi

# Either GNU Emacs, or UNIX vi -- lightweight Emacs alternatives like
# mg and zile are so rarely installed, so let's have a constant
# fallback which is almost certainly available and which I can use
# well enough.  When GNU Emacs is available, set ALTERNATE_EDITOR to
# the empty string so that an `emacs --daemon` process is spawned
emacsclient=$(which emacsclient 2>/dev/null)
if [ -x "$emacsclient" ]; then
    EDITOR="$ec"
    ALTERNATE_EDITOR=""
    export ALTERNATE_EDITOR
else
    EDITOR="vi"
fi
unset ec
unset emacsclient
export EDITOR
VISUAL="$EDITOR"
export VISUAL

# ---- set $PATH

# backup embedded copies of mr and stow

mrf=$(which mr)
if ! [ -x "$mrf" ]; then
    PATH="$HOME/src/dotfiles/lib/bins/mr:$PATH"
fi
unset mrf

stowf=$(which stow)
if ! [ -x "$stowf" ]; then
    PATH="$HOME/src/dotfiles/lib/bins/stow:$PATH"
fi
unset stowf

# this function prepends $addition to $PATH iff $addition isn't
# already in $PATH and $addition is a directory
maybe_add_to_path ()
{
    if ! echo $PATH | grep -q "$addition"; then
        if [ -d "$addition" ]; then
            PATH="$addition:$PATH"
        fi
    fi
}

addition="/sbin";                                 maybe_add_to_path
addition="/usr/sbin";                             maybe_add_to_path
addition="/usr/local/bin";                        maybe_add_to_path
addition="/usr/pkg/bin";                          maybe_add_to_path
addition="$HOME/local/pkg/bin";                   maybe_add_to_path
addition="$HOME/local/pkg/sbin";                  maybe_add_to_path
addition="$HOME/src/dotfiles/bin";                maybe_add_to_path
addition="$HOME/local/bin";                       maybe_add_to_path
addition="$HOME/.cabal/bin";                      maybe_add_to_path
addition="$HOME/.local/bin";                      maybe_add_to_path
addition="/meta/s/spw/local/src/git-annex.linux"; maybe_add_to_path
unset addition

export PATH

# ---- add to $MANPATH

MANPATH="$HOME/.local/share/man:$MANPATH"
export MANPATH

# ---- package management by Nix: add to $PATH once more

# # crude heuristic to determine if it's already been added
# if ! echo $PATH | grep -q "$HOME/.nix-profile/bin"; then
#     if [ -e "/etc/profile.d/nix.sh" ]; then
#         . /etc/profile.d/nix.sh
#     fi
# fi

# ---- set language (snippet from joeyh's home-etc.git repo)

# TODO: according to <https://wiki.debian.org/Locale>, I ought not to
# be setting LC_ALL.  Instead I could set most of LC_* to en_GB.UTF-8,
# and some e.g. LC_PAPER to en_US.UTF-8.

# disabled: propellor setting it system-wide on my machines and that's
# enough

# case " $(echo $(locale -a)) " in
#     *\ en_GB.utf8\ *) LANG=en_GB.utf8 ;;
#     *\ en_GB.UTF-8\ *) LANG=en_GB.UTF-8 ;;
#     *\ C.UTF-8\ *) LANG=C.UTF-8 ;;
#     *\ C.utf8\ *) LANG=C.utf8 ;;
#     *) unset LANG ;;
# esac

# LC_ALL=$LANG
# export LC_ALL
# export LANG

# ---- further preferences

GIT_PAGER=
export GIT_PAGER
GIT_MERGE_AUTOEDIT=no
export GIT_MERGE_AUTOEDIT
GPG_KEY_ID=0F56D0553B6D411B
export GPG_KEY_ID
MAILDIR="$HOME/.fmail/"
export MAILDIR
# LD_RUN_PATH="$HOME/local/lib/"
# export LD_RUN_PATH
# LD_LIBRARY_PATH="$HOME/local/lib/"
# export LD_LIBRARY_PATH
BROWSER="firefox"
export BROWSER
TERMCMD="xfce4-terminal"
export TERMCMD
TERMINAL="xfce4-terminal"
export TERMINAL
DEBFULLNAME="Sean Whitton"
export DEBFULLNAME
DEBEMAIL="spwhitton@spwhitton.name"
export DEBEMAIL
DGIT_SCHROOT_CHROOT=sid
export DGIT_SCHROOT_CHROOT
DAK_INSPECT_UPLOAD='tmux new-session -d -s mc 2>/dev/null; tmux new-window -n "{changes}" -t mc:^ -k "cd {directory}; mc"'
export DAK_INSPECT_UPLOAD
XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/var/lib/flatpak/exports/share/:/var/lib/snapd/desktop/
export XDG_DATA_DIRS
IMPASS_DB="$HOME/lib/priv/impass/db"
export IMPASS_DB
IMPASS_KEYFILE="$HOME/lib/priv/impass/keyid"
export IMPASS_KEYFILE
PERLDOC="-oman"
export PERLDOC

# Select the pygments parser for GNU GLOBAL, which works for a lot of
# languages.  Override with a gtags.conf in the project root.  Relies
# on having /etc/gtags/gtags.conf defining which languages the
# pygments parser works with (available in Debian global package
# version 6.6.4-2 or later, or can copy that file from upstream source
# to ~/.globalrc)
GTAGSLABEL=pygments
export GTAGSLABEL

# "Setting the monitor port to 0 turns the monitoring function off,
# and autossh will only restart ssh upon ssh's exit."
#
# We rely on ServerAliveInterval and ServerAliveCountMax set in ~/.ssh/config
AUTOSSH_PORT=0
export AUTOSSH_PORT

# ---- set pager

lessf=$(which less)
if [ -x "$lessf" ]; then
    PAGER=less
    export PAGER
    LESS="--ignore-case --long-prompt"
    export LESS
fi
unset lessf

# ---- use gpg agent as SSH agent, if it's running

# needed from Debian buster, for unknown reasons

if [ -e "${XDG_RUNTIME_DIR}/gnupg/S.gpg-agent.ssh" ]; then
    SSH_AUTH_SOCK="${XDG_RUNTIME_DIR}/gnupg/S.gpg-agent.ssh"
    export SSH_AUTH_SOCK
    unset SSH_AGENT_PID
fi