115 lines
3.3 KiB
Bash
115 lines
3.3 KiB
Bash
## -*- mode:sh -*- #
|
|
################################################################################
|
|
## Shell Config -- Main
|
|
## Date 2012-07-27
|
|
################################################################################
|
|
|
|
## Mask
|
|
## Result for 027 is: rwxr-x---
|
|
umask 027
|
|
|
|
## Path
|
|
## WARNING: putting current dir '.' in PATH is mostly a bad idea!
|
|
# export PATH=.:$PATH
|
|
export PATH=$PATH:${HOME}/launchers/
|
|
|
|
|
|
## TeXlive
|
|
TEXDIR="${TEXDIR:-/usr/local/texlive}"
|
|
if [ -d "${TEXDIR}" ]; then
|
|
TEXYEAR=$(/bin/ls -1r "${TEXDIR}" | grep -m1 "[0-9]\{4\}")
|
|
TEXDISTRO=$(uname -m)-$(uname | tr "[[:upper:]]" "[[:lower:]]")
|
|
TEXFOLDER="${TEXDIR}/${TEXYEAR}/bin/${TEXDISTRO}/"
|
|
if [ -d "${TEXFOLDER}" ]; then
|
|
export PATH=${TEXFOLDER}:$PATH
|
|
export INFOPATH=${TEXDIR}/${TEXYEAR}/texmf/doc/info:$INFOPATH
|
|
|
|
## BSD uses 'manpath' utility, so MANPATH variable may be empty.
|
|
if [ "$OSTYPE" = "linux-gnu" ]; then
|
|
export MANPATH=${TEXDIR}/${TEXYEAR}/texmf/doc/man:$MANPATH
|
|
fi
|
|
fi
|
|
unset TEXYEAR
|
|
unset TEXDISTRO
|
|
unset TEXFOLDER
|
|
fi
|
|
unset TEXDIR
|
|
|
|
## Enable color support of ls.
|
|
if [ "$TERM" != "dumb" ] && [ "$OSTYPE" = "linux-gnu" ]; then
|
|
eval "`dircolors $HOME/.shell.d/dircolorsdb`"
|
|
elif [ "$TERM" != "dumb" ]; then
|
|
export LSCOLORS="Ex"
|
|
# export LSCOLORS="ExfxcxDxCxdxdxCxCxECEh"
|
|
fi
|
|
|
|
## Terminal
|
|
## WARNING: this is always a bad idea!
|
|
## FreeBSD urxvt $TERM variable is not set properly for some reasons.
|
|
## TODO: check how to do this properly.
|
|
if [ ! "$OSTYPE" = "linux-gnu" ] && [[ "$TERM" = *rxvt* ]]; then
|
|
export TERM="rxvt-unicode-256color"
|
|
fi
|
|
|
|
## Make 'less' more friendly for non-text input files, see lesspipe(1).
|
|
[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
|
|
|
|
## Manpage.
|
|
export MANPAGER="less -s"
|
|
## 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'"
|
|
export MANWIDTH=80
|
|
|
|
## Less config. -R is needed for lesspipe.
|
|
export LESS=' -R '
|
|
|
|
## Time display (with ls command for example)
|
|
## TODO: BSD version?
|
|
export TIME_STYLE=+"|%Y-%m-%d %H:%M:%S|"
|
|
|
|
## System locale
|
|
# export LC_MESSAGES=fr_FR.utf8
|
|
|
|
## Default text editor
|
|
EDITOR=nano
|
|
if [ -n "$(command -v vim)" ]; then
|
|
EDITOR=vim
|
|
fi
|
|
if [ -n "$(command -v emacs)" ]; then
|
|
EDITOR='emacs'
|
|
fi
|
|
## 'em' is a script for emacsclient. See '.homeinit'.
|
|
if [ -f "/bin/em" ]; then
|
|
EDITOR='em'
|
|
fi
|
|
export EDITOR
|
|
|
|
## Internet Browser
|
|
[ -n "$(command -v dwb)" ] && export BROWSER="dwb"
|
|
|
|
## Title
|
|
## If this is an xterm set the title to user@host:dir
|
|
#case "$TERM" in
|
|
#xterm*|rxvt*)
|
|
# PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
|
|
# ;;
|
|
#*)
|
|
# ;;
|
|
#esac
|
|
|
|
## SSH-Agent
|
|
## WARNING: this is somewhat insecure. avoid using it on a mutli-user machine.
|
|
if [ $(ps ax -o command="" | grep -c "ssh-agent") -eq 1 ]; then
|
|
SSH_AGENT_VARS=$(ssh-agent)
|
|
eval $(echo "${SSH_AGENT_VARS}")
|
|
rm -f "/tmp/ssh-agent-env"
|
|
echo "${SSH_AGENT_VARS}" | sed '2q' | cut -d'=' -f2 | cut -d';' -f1 > "/tmp/ssh-agent-env"
|
|
chmod 444 "/tmp/ssh-agent-env"
|
|
unset $SSH_AGENT_VARS
|
|
else
|
|
SSH_AUTH_SOCK=$(sed -n '1{p;q}' "/tmp/ssh-agent-env") ; export SSH_AUTH_SOCK
|
|
SSH_AGENT_PID=$(sed -n '2{p;q}' "/tmp/ssh-agent-env") 2>/dev/null ; export SSH_AGENT_PID
|
|
fi
|
|
|