2013-06-03 20:18:14 +02:00
|
|
|
#!/bin/sh
|
2015-10-19 15:15:12 +02:00
|
|
|
## This file should be automatically sourced by the login manager. We source it
|
|
|
|
## manually from shell rc files to make sure it works in TTY as well
|
2013-06-03 20:18:14 +02:00
|
|
|
|
2016-10-13 11:23:41 +02:00
|
|
|
## Preliminary definitions.
|
2013-06-03 20:18:14 +02:00
|
|
|
|
2013-07-27 11:11:48 +02:00
|
|
|
## Note that it is important for MANPATH to have an empty entry to keep
|
|
|
|
## searching in the default db path. Same for INFOPATH, which should have an
|
|
|
|
## empty entry at the end, otherwise Emacs will not use standard locations. For
|
2016-10-13 11:23:41 +02:00
|
|
|
## security reasons (and bad programming assumptions) you should always append
|
|
|
|
## entries to PATH, not prepend them.
|
|
|
|
appendpath () {
|
2014-11-12 18:00:08 +01:00
|
|
|
[ $# -eq 2 ] && PATHVAR=$2 || PATHVAR=PATH
|
2016-10-13 11:23:41 +02:00
|
|
|
[ -d "$1" ] || return
|
|
|
|
eval echo \$$PATHVAR | grep -q "\(:\|^\)$1\(:\|$\)" && return
|
|
|
|
eval export $PATHVAR="\$$PATHVAR:$1"
|
2013-07-25 20:50:37 +02:00
|
|
|
}
|
2016-10-13 11:23:41 +02:00
|
|
|
prependpath () {
|
2014-11-12 18:00:08 +01:00
|
|
|
[ $# -eq 2 ] && PATHVAR=$2 || PATHVAR=PATH
|
2016-10-13 11:23:41 +02:00
|
|
|
[ -d "$1" ] || return
|
|
|
|
eval echo \$$PATHVAR | grep -q "\(:\|^\)$1\(:\|$\)" && return
|
|
|
|
eval export $PATHVAR="$1:\$$PATHVAR"
|
2013-07-27 11:11:48 +02:00
|
|
|
}
|
2013-07-25 20:50:37 +02:00
|
|
|
|
2016-10-13 11:23:41 +02:00
|
|
|
################################################################################
|
|
|
|
|
|
|
|
## Mask
|
|
|
|
## Result for 027 is: rwxr-x---
|
|
|
|
umask 027
|
2013-06-03 20:18:14 +02:00
|
|
|
|
|
|
|
## TeXlive
|
|
|
|
TEXDIR="${TEXDIR:-/usr/local/texlive}"
|
|
|
|
if [ -d "${TEXDIR}" ]; then
|
2014-11-12 18:00:08 +01:00
|
|
|
TEXYEAR=$(/bin/ls -1r "${TEXDIR}" | grep -m1 "[0-9]\{4\}")
|
2016-05-17 14:03:41 +02:00
|
|
|
TEXDISTRO=$(uname -m)-$(uname | awk '{print tolower($0)}')
|
2016-06-06 20:51:07 +02:00
|
|
|
TEXFOLDER="${TEXDIR}/${TEXYEAR}/bin/${TEXDISTRO}"
|
2014-11-12 18:00:08 +01:00
|
|
|
if [ -d "${TEXFOLDER}" ]; then
|
|
|
|
appendpath $TEXFOLDER
|
|
|
|
prependpath ${TEXDIR}/${TEXYEAR}/texmf/doc/info INFOPATH
|
|
|
|
|
|
|
|
## BSD uses 'manpath' utility, so MANPATH variable may be empty.
|
2016-10-13 11:23:41 +02:00
|
|
|
if [ "$(uname -o)" = "GNU/Linux" ]; then
|
2014-11-12 18:00:08 +01:00
|
|
|
prependpath ${TEXDIR}/${TEXYEAR}/texmf/doc/man MANPATH
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
unset TEXYEAR
|
|
|
|
unset TEXDISTRO
|
|
|
|
unset TEXFOLDER
|
2013-06-03 20:18:14 +02:00
|
|
|
fi
|
|
|
|
unset TEXDIR
|
2016-10-12 11:03:57 +02:00
|
|
|
export BIBINPUTS=~/personal/bibliography
|
2013-06-03 20:18:14 +02:00
|
|
|
|
2016-10-13 11:23:41 +02:00
|
|
|
## Plan9 (base)
|
2014-01-06 15:18:42 +01:00
|
|
|
PLAN9DIR="/opt/plan9"
|
|
|
|
if [ -d "$PLAN9DIR" ]; then
|
2016-05-04 11:57:31 +02:00
|
|
|
## No need to add to path if /etc/profile.d/plan9.sh does it already.
|
|
|
|
# appendpath "$PLAN9DIR/bin"
|
2016-10-13 11:23:41 +02:00
|
|
|
if [ "$(uname -o)" = "GNU/Linux" ]; then
|
2014-11-12 18:00:08 +01:00
|
|
|
appendpath "$PLAN9DIR/share/man" MANPATH
|
|
|
|
fi
|
2014-01-06 15:18:42 +01:00
|
|
|
fi
|
|
|
|
unset PLAN9DIR
|
|
|
|
|
2017-05-14 06:34:58 +02:00
|
|
|
## Less config. -R is needed for lesspipe colorization.
|
|
|
|
# export LESS=' -R '
|
2013-06-03 20:18:14 +02:00
|
|
|
## Make 'less' more friendly for non-text input files, see lesspipe(1).
|
2014-01-03 19:13:07 +01:00
|
|
|
command -v lesspipe >/dev/null 2>&1 && eval "$(lesspipe)"
|
2014-10-22 17:54:33 +02:00
|
|
|
## Remove less history.
|
|
|
|
LESSHISTFILE='-'
|
2013-06-03 20:18:14 +02:00
|
|
|
|
|
|
|
## Manpage.
|
|
|
|
export MANPAGER="less -s"
|
|
|
|
export MANWIDTH=80
|
|
|
|
## The following options are useful for FreeBSD default 'less' command which has
|
|
|
|
## an empty prompt. Sadly this gets messy with 'apropos'.
|
|
|
|
# export MANPAGER="less -sP '?f%f .?m(file %i of %m) .?ltlines %lt-%lb?L/%L. .byte %bB?s/%s. ?e(END) :?pB%pB\%..%t'"
|
|
|
|
|
|
|
|
|
|
|
|
## Time display (with ls command for example)
|
|
|
|
## TODO: BSD version?
|
|
|
|
export TIME_STYLE=+"|%Y-%m-%d %H:%M:%S|"
|
|
|
|
|
|
|
|
## SSH-Agent
|
2016-05-31 10:42:33 +02:00
|
|
|
if command -v ssh-agent >/dev/null 2>&1 && [ -z "$SSH_AGENT_PID" ]; then
|
|
|
|
eval "$(ssh-agent)"
|
|
|
|
## Kill ssh-agent on session end. Console login only.
|
|
|
|
command -v sessionclean >/dev/null 2>&1 && trap 'sessionclean' 0
|
|
|
|
fi
|
2013-07-04 23:56:05 +02:00
|
|
|
|
2016-10-13 11:23:41 +02:00
|
|
|
if [ "$(uname -o)" = "GNU/Linux" ] ; then
|
|
|
|
## Startup error log.
|
|
|
|
## dmesg
|
|
|
|
log_dmesg="$(dmesg | grep -i error)"
|
|
|
|
[ -n "$log_dmesg" ] && echo "$log_dmesg" > "$HOME/errors-dmesg.log" || rm -f "$HOME/errors-dmesg.log"
|
|
|
|
## systemd
|
|
|
|
if command -v systemctl >/dev/null 2>&1; then
|
|
|
|
count="$(systemctl show | awk -F= '$1=="NFailedUnits" {print $2; exit}')"
|
|
|
|
if [ $count -ne 0 ]; then
|
|
|
|
systemctl -l --failed > "$HOME/errors-systemd.log"
|
|
|
|
else
|
|
|
|
rm -f "$HOME/errors-systemd.log"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
## Set sound volume.
|
|
|
|
amixer 2>/dev/null | grep -q PCM && amixer set PCM 100%
|
|
|
|
|
|
|
|
## External device auto-mounting.
|
|
|
|
## If already started, the new process will replace the old one.
|
|
|
|
if command -v udiskie >/dev/null 2>&1; then
|
|
|
|
udiskie &
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2013-10-14 09:12:28 +02:00
|
|
|
## Set TEMP dir if you want to override /tmp for some applications that check
|
2013-12-29 10:10:22 +01:00
|
|
|
## for this variable. Usually not a good idea since some applications will write
|
|
|
|
## junk files in it.
|
2013-09-18 15:05:52 +02:00
|
|
|
# [ -d "$HOME/temp" ] && export TEMP="$HOME/temp"
|
|
|
|
|
2013-07-04 23:56:05 +02:00
|
|
|
## Wine DLL override. This removes the annoying messages for Mono and Gecko.
|
|
|
|
export WINEDLLOVERRIDES="mscoree,mshtml="
|
|
|
|
|
2014-09-25 09:42:57 +02:00
|
|
|
## Go
|
2016-09-24 03:48:47 +02:00
|
|
|
if [ -d "$HOME/go" ]; then
|
|
|
|
export GOPATH=~/go:~/.go-tools
|
|
|
|
appendpath "$HOME/.go-tools/bin"
|
|
|
|
appendpath "$HOME/go/bin"
|
2016-10-13 11:24:05 +02:00
|
|
|
command -v godoc >/dev/null 2>&1 && godoc -http :6060 -play 2>/dev/null &
|
2014-10-22 17:54:33 +02:00
|
|
|
fi
|
2014-09-25 09:42:57 +02:00
|
|
|
|
2015-11-10 10:53:26 +01:00
|
|
|
## fzf
|
|
|
|
if command -v fzf >/dev/null 2>&1; then
|
2017-05-22 14:58:25 +02:00
|
|
|
export FZF_DEFAULT_OPTS="--reverse --inline-info --height 40% --cycle --extended --multi --select-1 --exit-0 --bind=ctrl-k:kill-line,alt-l:accept,alt-f:page-down,alt-b:page-up,alt-a:toggle-all,ctrl-a:select-all,alt-i:toggle-down,alt-o:toggle-up,alt-z:toggle-preview,alt-j:down,alt-k:up,alt-h:kill-line"
|
2016-11-27 05:01:20 +01:00
|
|
|
export FZF_ALT_C_OPTS="--preview='preview {}'"
|
|
|
|
export FZF_BCD_OPTS=$FZF_ALT_C_OPTS
|
|
|
|
export FZF_CDHIST_OPTS=$FZF_ALT_C_OPTS
|
2017-02-03 10:10:36 +01:00
|
|
|
export FZF_CTRL_R_OPTS="--reverse --sort"
|
2017-05-22 14:58:25 +02:00
|
|
|
export FZF_CTRL_T_OPTS="--bind=alt-l:'execute(rifle {+})' --preview='preview {+}'"
|
2017-01-16 10:55:46 +01:00
|
|
|
if [ "$(uname -o)" = "GNU/Linux" ]; then
|
|
|
|
## Append '/' to folder names. GNU find required.
|
|
|
|
export FZF_CTRL_T_COMMAND="command find -L \$dir -mindepth 1 \\( -path \$dir'*/\\.*' -o -fstype 'devfs' -o -fstype 'devtmpfs' \\) -prune \
|
|
|
|
-o -type f -print \
|
|
|
|
-o -type d -printf '%p/\n' \
|
|
|
|
-o -type l -print 2> /dev/null | sed 's#^\./##'"
|
|
|
|
fi
|
2015-11-10 10:53:26 +01:00
|
|
|
fi
|
|
|
|
|
2016-07-05 17:03:15 +02:00
|
|
|
## pacman abs
|
|
|
|
if command -v asp >/dev/null 2>&1; then
|
|
|
|
export ASPROOT="$HOME/.cache/asp"
|
|
|
|
fi
|
|
|
|
|
2016-10-13 11:23:41 +02:00
|
|
|
################################################################################
|
|
|
|
|
|
|
|
## Last PATH entries.
|
|
|
|
appendpath "/usr/lib/surfraw"
|
2017-01-26 14:56:18 +01:00
|
|
|
appendpath "${HOME}/personal/games/launchers"
|
2016-10-13 11:23:41 +02:00
|
|
|
appendpath "${HOME}/.scripts"
|
2017-01-26 14:56:18 +01:00
|
|
|
prependpath "${HOME}/personal/hackpool"
|
2016-10-13 11:23:41 +02:00
|
|
|
|
|
|
|
## Default text editor
|
|
|
|
## 'em' is a custom wrapper for emacsclient. See '.scripts/em'.
|
|
|
|
for i in em emacs vim nano; do
|
|
|
|
command -v $i >/dev/null 2>&1 && export EDITOR=$i && break
|
|
|
|
done
|
2016-10-13 14:57:17 +02:00
|
|
|
GIT_EDITOR="$EDITOR"
|
2017-05-08 18:11:47 +02:00
|
|
|
VISUAL="$EDITOR"
|
2016-10-13 14:57:17 +02:00
|
|
|
[ "$GIT_EDITOR" = em ] && GIT_EDITOR=emc
|
2017-05-08 18:11:47 +02:00
|
|
|
[ "$VISUAL" = em ] && VISUAL=emw
|
2016-10-13 14:57:17 +02:00
|
|
|
export GIT_EDITOR
|
2017-05-08 18:11:47 +02:00
|
|
|
export VISUAL
|
2016-10-13 11:23:41 +02:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
|
2013-08-20 14:49:36 +02:00
|
|
|
## Hook. Should be sourced last
|
|
|
|
[ -f ~/.profile_hook ] && . ~/.profile_hook
|
2013-09-19 12:00:25 +02:00
|
|
|
## Hook example
|
2013-10-14 09:12:28 +02:00
|
|
|
#
|
2013-09-19 12:00:25 +02:00
|
|
|
# appendpath "${HOME}/local/usr/bin"
|
|
|
|
# prependpath "${HOME}/local/usr/share/info" INFOPATH
|
|
|
|
# prependpath "${HOME}/local/usr/share/man" MANPATH
|
2013-10-14 09:12:28 +02:00
|
|
|
#
|
|
|
|
# appendpath "$HOME/local/usr/include" C_INCLUDE_PATH
|
|
|
|
# appendpath "$HOME/local/usr/include" CPLUS_INCLUDE_PATH
|
|
|
|
# appendpath "$HOME/local/usr/lib" LIBRARY_PATH
|
2013-09-19 12:00:25 +02:00
|
|
|
# export CPPFLAGS=-I$HOME/local/usr/include
|
|
|
|
# export LDFLAGS=-L$HOME/local/usr/lib
|
2013-10-14 09:12:28 +02:00
|
|
|
#
|
|
|
|
# appendpath "${HOME}/local/usr/lib/pkgconfig" PKG_CONFIG_PATH
|
|
|
|
#
|
|
|
|
# appendpath "${HOME}/local/usr/lib/" LD_LIBRARY_PATH
|
|
|
|
# appendpath "$HOME/local/usr/lib/python2.7/dist-packages/" PYTHONPATH
|
2014-03-26 15:49:29 +01:00
|
|
|
# export LUA_CPATH="$HOME/local/usr/lib/lib?.so;$(lua -e "print(package.cpath)")"
|
2013-09-19 12:00:25 +02:00
|
|
|
#
|
|
|
|
# umask 077
|
2016-10-13 11:23:41 +02:00
|
|
|
|
|
|
|
## End: Source .bashrc. The rc file should guard against non-interactive shells.
|
|
|
|
[ "$(ps -o comm= $$)" != bash ] && return
|
|
|
|
[ -f ~/.bashrc ] && . ~/.bashrc
|