summaryrefslogtreecommitdiff
path: root/.shenv
blob: 2e8c6b3cf435b67ffbee2e8f3b28bbb54d8767da (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
#!/bin/sh

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

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

emacsclient=$(which emacsclient 2>/dev/null)
mg=$(which mg 2>/dev/null)
# best case: emacsclient and mg available
if [ -x "$emacsclient" -a -x "$mg" ]; then
    EDITOR="emacsclient -amg -t"
    ALTERNATE_EDITOR="mg"
else
    # only emacsclient, so change alternate editor
    if [ -x "$emacsclient" ]; then
        EDITOR="emacsclient -avi -t"
        ALTERNATE_EDITOR="vi"
    else
        # no emacsclient, so see if we can fall back to mg
        if [ -x "$mg" ]; then
            EDITOR="mg"
            ALTERNATE_EDITOR="vi"
        # worse case: assume vi is available
        else
            EDITOR="vi"
        fi
    fi
fi
unset emacsclient
unset mg
export EDITOR
VISUAL=$EDITOR
export VISUAL

# ---- set $PATH

# 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
PATH="/usr/pkg/bin:$PATH"
addition="$HOME/local/pkg/bin";                   maybe_add_to_path
addition="$HOME/local/pkg/sbin";                  maybe_add_to_path
addition="$HOME/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
addition="/meta/s/spw/local/opt/ghc/bin";         maybe_add_to_path
addition="$HOME/local/opt/cabal/cabal-install-1.22.0.0/.cabal-sandbox/bin"; maybe_add_to_path

# now add places where there might be an exe made by cabal-install
for bindir in $(find ~/local/src -path "*/.cabal-sandbox/bin"); do
    addition="$bindir";                           maybe_add_to_path
done

unset addition
export PATH

# ---- access MetaArray libraries

PKG_CONFIG_PATH=/usr/pkg/lib/pkgconfig/:$HOME/local/lib/pkgconfig/:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH
#C_INCLUDE_PATH=$HOME/local/include:/usr/pkg/include/gettext:/usr/pkg/include:$C_INCLUDE_PATH
C_INCLUDE_PATH=/usr/pkg/include:$C_INCLUDE_PATH
export C_INCLUDE_PATH
#LD_LIBRARY_PATH=$HOME/local/lib:/usr/lib64:/usr/pkg/lib:$LD_LIBRARY_PATH
LD_LIBRARY_PATH=/usr/pkg/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH

# CFLAGS="-I/usr/pkg/include/gettext -I/usr/pkg/include $CFLAGS"
# export CFLAGS
# CPPFLAGS="-I/usr/pkg/include/gettext -I/usr/pkg/include $CPPFLAGS"
# export CPPFLAGS
# LDFLAGS="-L/usr/pkg/lib $LDFLAGS"
# export LDFLAGS

# ---- maybe add to $MANPATH

if [ -d "$HOME/pkg/man" ]; then
    MANPATH="$HOME/local/pkg/man:$MANPATH"
    export MAHPATH
fi

# ---- 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.

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=3B6D411B
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
GTK_IM_MODULE=xim
export GTK_IM_MODULE
QT_IM_MODULE=xim
export QT_IM_MODULE
BROWSER="iceweasel"
export BROWSER
TERMCMD="urxvt"
export TERMCMD

# ---- set pager

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

# ---- MetaArray perl settings

PATH="/meta/s/spw/perl5/bin${PATH+:}${PATH}"; export PATH;
PERL5LIB="/meta/s/spw/perl5/lib/perl5${PERL5LIB+:}${PERL5LIB}"; export PERL5LIB;
PERL_LOCAL_LIB_ROOT="/meta/s/spw/perl5${PERL_LOCAL_LIB_ROOT+:}${PERL_LOCAL_LIB_ROOT}"; export PERL_LOCAL_LIB_ROOT;
PERL_MB_OPT="--install_base \"/meta/s/spw/perl5\""; export PERL_MB_OPT;
PERL_MM_OPT="INSTALL_BASE=/meta/s/spw/perl5"; export PERL_MM_OPT;