-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtomohara-settings.bash
More file actions
executable file
·146 lines (128 loc) · 5.46 KB
/
tomohara-settings.bash
File metadata and controls
executable file
·146 lines (128 loc) · 5.46 KB
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
# idiosyncratic settings for user tomohara
#
# note:
# - New place for settings previously put in tomohara-aliases.bash.
# - This mainly is for enironment variables, Bash variables and other settings
# not directly related to aliases or functions.
# - Selectively ignore following shellcheck warnings
# -- SC2155: Declare and assign separately to avoid masking return values
# -- SCnnnn: ...
# TODO:
# - ** Move misc. settings from .bashrc and tomohara-aliases.bash here.
# - Flesh out.
#
# Ensure OSTYPE is environment variable for script usage
if [ "$(printenv OSTYPE)" = "" ]; then
export OSTYPE="$OSTYPE";
fi
# Fixup for Linux OSTYPE setting (likewise for solaris)
# TODO: use ${OSTYPE/[0-9]*/}
OSTYPE_BRIEF="$OSTYPE"
case "$OSTYPE_BRIEF" in
linux*) export OSTYPE_BRIEF=linux; ;;
cygwin*) export OSTYPE_BRIEF=cygwin; ;;
solaris*) export OSTYPE_BRIEF=solaris; alias printenv='printenv.sh' ;;
darwin*) export OSTYPE_BRIEF=mac-os; ;;
*) echo "Warning: unknown OS type ($OSTYPE)"; ;;
esac
# Add directories to path: ./bin, ./bin/<OS>
# TODO: develop a function for doing this
if [ "$(printenv PATH | $GREP "$TOM_BIN":)" = "" ]; then
export PATH="$TOM_BIN:$PATH"
fi
if [ "$(printenv PATH | $GREP "$TOM_BIN/${OSTYPE_BRIEF}":)" = "" ]; then
export PATH="$TOM_BIN/${OSTYPE_BRIEF}:$PATH"
fi
# TODO: make optional & put append-path later to account for later PERLLIB changes
append-path "$PERLLIB"
## OLD (see below): prepend-path "$HOME/python/Mezcla/mezcla"
append-path "$HOME/python"
append-path "$TOM_BIN/adhoc"
append-path "$TOM_BIN/archive"
append-path "$TOM_BIN/examples"
append-path-warn "$HOME/.local/bin"
# Put current directory at end of path; can be overwritting with ./ prefix
export PATH="$PATH:."
# Note: ~/lib only used to augment existing library, not pre-empt
## OLD: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/lib:$HOME/lib/linux
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$HOME/lib:$HOME/lib/$OSTYPE_BRIEF"
# Setup pythonpath to include .. for sake of testing
## OLD: export PYTHONPATH="$PYTHONPATH:.."
# note: '.' & '..' put at end to avoid unexpected conflicts with scripts like common.py
export PYTHONPATH="src:$PYTHONPATH:.:.."
# Define HOST_NICKNAME from ~/.host-nickname if unset or the default
if [[ ("$HOST_NICKNAME" = "") || ("$HOST_NICKNAME" = "tpo-host") ]]; then
## OLD: export HOST_NICKNAME="$(cat ~/.host-nickname 2> /dev/null | grep -v '^#')";
# shellcheck disable=SC2155
export HOST_NICKNAME="$(grep -v '^#' ~/.host-nickname 2> /dev/null)";
fi
# Python stuff
## OLD: prepend-path "$HOME/python/Mezcla/mezcla"
## OLD: add-python-path "$HOME/python/Mezcla/mezcla"
add-python-path "$HOME/Mezcla/mezcla"
## OLD: append-path "$HOME/mezcla-tom/examples:$HOME/python/examples:$TOM_BIN/bruno"
append-path "$HOME/Mezcla/mezcla/examples"
#
# HACK: make sure ~/mezcla-tom used if available
if [ -e "$HOME/mezcla-tom" ]; then add-python-path "$HOME/mezcla-tom"; fi
#
# Make sure gradio apps accessible in local net
# See https://superuser.com/questions/949428/whats-the-difference-between-127-0-0-1-and-0-0-0-0.
## OLD: export GRADIO_SERVER_NAME=0.0.0.0
export GRADIO_SERVER_NAME="$HOSTNAME.local"
#
# Mezcla stuff
cond-export BRIEF_USAGE 1 # running w/o args shows usage line
cond-export TRACE_INVOCATION 1 # trace script invocation argv
cond-export DISABLE_RECURSIVE_DELETE 1 # don't allow rm -r during cleanup
cond-export SKIP_EXPECTED_ERRORS 1 # skip pytests known to fail (e.g., to filter error messages from check-errors)
# Enable timestamp preservation during git-update alias operations (n.b., stash pop quirk)
cond-export PRESERVE_GIT_STASH 1
# Misc bash options
# make file globs cases insensitve
# note: also include 'set completion-ignore-case on' in ~/.inputrc (see http://www.cygwin.com/cygwin-ug-net/setup-files.html)
shopt -s nocaseglob
#
# Have less handle unicode (avoids reverse video display of hex, such as for non-breaking space U+FEFF)
export LESSCHARSET=utf-8
# Also have it display binary characters as underline instead of reverse video (i.e., standout)
export LESSBINFMT="*u<%02X>"
export SHELL="/bin/bash"
# Don't enable default .bashrc settings
cond-export SKIP_DEFAULT_BASHRC 1
# Don't enable tab completion (n.b., due to slow init)
cond-export SKIP_TAB_COMPLETION 1
# Invoke image viewer after renaming snapshots
cond-export RENAME_SNAPSHOT_PREVIEW 1
# Get rid of (mostly) nitpicking shellcheck warnings
# See shell-check function comments for synopsis.
cond-export SHELL_CHECK_EXCLUDE "SC1090,SC1091,SC2004,SC2009,SC2012,SC2119,SC2120,SC2129,SC2155,SC2164,SC2181,SC2196,SC2219,SC2230"
# Get idiosyncratic aliases
conditional-source "$TOM_BIN/tomohara-proper-aliases.bash"
# xterm window support
cond-export XTERM_SHOW_PID 1
# User-specific mount directory
cond-export MNT /media/"$USER"
# Use native KDE open dialogs (e.g., for recent files feature)
# TODO2: put in user-specific settings (e.g., ~/.local/sell-scripts-settings.bash)
cond-export GTK_USE_PORTAL 1
# Emacs stuff
# use emacs with crontab
## TODO: export EDITOR="emacs -nw"
export EDITOR="emacs"
# Other default programs (e.g., for use with start.sh)
export BROWSER="google-chrome"
# Perl stuff
cond-export PERL_RANDOM_SEED 122949823 # 7 millionth prime
# Linux stuff
## OLD:
if [ "$(under-linux)" = "1" ]; then
cond-export WNSEARCHDIR /usr/share/wordnet
elif [ "$(under-cygwin)" = "1" ]; then
cond-export WNSEARCHDIR /lib/wnres/dict
fi
if [ "$DOMAIN_NAME" = "" ]; then
# shellcheck disable=SC2155
# TODO: cond-export
export DOMAIN_NAME=$(domainname.sh);
fi