summaryrefslogtreecommitdiff
path: root/10_Environment.zsh
blob: 083fbf4038d02fb8b90bb4ae70a3473b44785929 (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
##
## Part of configuration files for Zsh 4
## by Hugues Hiegel <hugues@hiegel.fr>
## 
## NO WARRANTY PROVIDED, USE AT YOUR OWN RISKS
##
## You are encouraged to use, modify, and redistribute
## these files with or without this notice.
## 

##
## NDLA: 
##
## ma politique pour l'export des variables est très simple :
## si elle a pour vocation d'être utilisée en dehors de Zsh,
## on l'exporte. Sinon pas.
##

export SHELL=`which zsh`


## Colors 
autoload colors && colors
c_='['$color[none]";"
_c=m
C_="%{$c_"
_C="$_c%}"

unset has_termcaps
[ $TERM = "rxvt-unicode" -o $TERM = "screen" ] && has_termcaps="true"
T_=${has_termcaps:+$termcap[as]}
_T=${has_termcaps:+$termcap[ae]}
_tq_=${${has_termcaps:+"q"}:-"-"}
_tj_=${${has_termcaps:+"j"}:-"'"}
_tk_=${${has_termcaps:+"k"}:-"."}
_tl_=${${has_termcaps:+"l"}:-","}
_tm_=${${has_termcaps:+"m"}:-"\`"}
_tt_=${${has_termcaps:+"t"}:-"]"}
_tu_=${${has_termcaps:+"u"}:-"["}
_tx_=${${has_termcaps:+"x"}:-"|"}

# I hate kik00l0l colorized prompts, so I'm using a way to
# give a dominant color for each part of the prompt, each of
# these remain still configurable one by one.
# Take a look to _set_prompt_colors (01_Internals) for these colorizations.
#
# To set the dominant color I'm using this :
#
#  - PS1_ROOT when we are root
#  - PS1_USER for normal usage
#
# I'm storing the resulting dominant color in $_prompt_colors[generic]

PS1_ROOT=${PS1_ROOT:-$color[red]}
PS1_USER=${PS1_USER:-$color[blue]}
PS1_YEAH="38;5;82"

## Variables d'environnement ``classiques''
#
# L'utilisation de la forme ${VARIABLE:+$VARIABLE:} permet d'accoler ``:''
# si et seulement si $VARIABLE contient déjà des choses, cela pour éviter
# d'avoir un PATH (p.e.) de la forme : PATH=:/bin
#
#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:~/libs
#export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/X11R6/lib/pkgconfig
export PATH=$PATH:~/sbin:~/local/bin
PATH=/sbin:/usr/sbin:$PATH
export MANPATH=~/man:~/local/share/man:/usr/local/share/man:$MANPATH
export INFOPATH=~/info:~/local/share/info:/usr/local/share/info:$INFOPATH
[ "$DEBUG" = "yes" ] && export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}~/libs
[ "$DEBUG" = "yes" ] && export PKG_CONFIG_PATH=${PKG_CONFIG_PATH:+$PKG_CONFIG_PATH:}~/pkgconfig

## Nettoyage des précédentes variables pour supprimer les duplicata
typeset -gU PATH MANPATH INFOPATH PKG_CONFIG_PATH LD_LIBRARY_PATH

## Gestion de l'historique
# Voir le fichier d'Options pour plus de contrôle là-dessus
if [ -w $ZDOTDIR ]
then
	HISTFILE=$ZDOTDIR/.history.$USER.$HOST # Pour éviter les conflits de conf
else
	HISTFILE=~$USER/.zsh.history.$HOST
fi

SAVEHIST=42000
HISTSIZE=$(( $SAVEHIST * 1.10 ))

export GPG_TTY=`tty`

# YeahConsole..
if ( ps x | grep $$ -B1 | grep -q yeahconsole )
then
	_yeahconsole=true
fi

# Display guess
_current_display=$(finger 2>&- | tail -n+2 | grep -E $USER'[[:blank:]]+.*[[:blank:]]+tty[0-9][[:blank:]]+($DISPLAY)' | head -n1 | cut -d'(' -f2 | cut -d')' -f1)
if [ "$DISPLAY" = "" -a "$_current_display" = "" ]
then
	_guess_display=$(finger 2>&- | tail -n+2 | grep -E $USER'[[:blank:]]+.*[[:blank:]]+tty[0-9]' | head -n1 | cut -d'(' -f2 | cut -d')' -f1)
	if [ "$_guess_display" != "" ]
	then
		export DISPLAY=$_guess_display
	else
		unset DISPLAY
	fi
fi

export COLUMNS