| ... | ... |
@@ -1,8 +1,8 @@ |
| 1 | 1 |
# Title: .bashrc |
| 2 | 2 |
# Author: Frédéric CHEVALIER <f15.chevalier@gmail.com> |
| 3 |
-# Version: 1.3 |
|
| 3 |
+# Version: 1.4 |
|
| 4 | 4 |
# Created in: 2012-05-26 |
| 5 |
-# Modified in: 2014-07-19 |
|
| 5 |
+# Modified in: 2014-07-26 |
|
| 6 | 6 |
|
| 7 | 7 |
|
| 8 | 8 |
|
| ... | ... |
@@ -19,6 +19,7 @@ |
| 19 | 19 |
# Versions # |
| 20 | 20 |
#==========# |
| 21 | 21 |
|
| 22 |
+# v1.4 - 2014-07-26: ssh_agent function for SSH key management added / ssh_agent called when used SSH connexion / wf alias updated |
|
| 22 | 23 |
# v1.3 - 2014-07-19: bug correction for PS1 (\[\e and \] missing for each color) / typo corrections |
| 23 | 24 |
# v1.2 - 2014-07-06: h and t aliases corrected / m alias added / quit function added / R env variables added |
| 24 | 25 |
# v1.1 - 2014-07-02: bug corrections in trash function and EDITOR set up / exit and diff aliases added |
| ... | ... |
@@ -91,23 +92,6 @@ shopt -s cdspell |
| 91 | 92 |
# Make less more friendly for non-text input files, see lesspipe(1) |
| 92 | 93 |
[[ -x /usr/bin/lesspipe ]] && eval "$(SHELL=/bin/sh lesspipe)" |
| 93 | 94 |
|
| 94 |
-## Key binding |
|
| 95 |
-#bind '"\e[1~": beginning-of-line' # home |
|
| 96 |
-#bind '"\e[2~": overwrite-mode' # insert |
|
| 97 |
-#bind '"\e[3~": delete-char' # del |
|
| 98 |
-#bind '"\e[4~": end-of-line' # end |
|
| 99 |
-#bind '"\e[5~": history-search-backward' # page up |
|
| 100 |
-#bind '"\e[6~": history-search-forward' # page down |
|
| 101 |
-#bind '"\e[A": up-line-or-history' # arrow up |
|
| 102 |
-#bind '"\e[B": down-line-or-history' # arrow down |
|
| 103 |
-#bind '"\e[C": forward-char' # arrow right |
|
| 104 |
-#bind '"\e[D": backward-char' # arrow left |
|
| 105 |
- |
|
| 106 |
-#bind '"\e[H": beginning-of-line' # home (xterm) |
|
| 107 |
-#bind '"\e[F": end-of-line' # end (xterm) |
|
| 108 |
- |
|
| 109 |
-#bind '"^R": history-incremental-search-backward' |
|
| 110 |
- |
|
| 111 | 95 |
|
| 112 | 96 |
#---------------# |
| 113 | 97 |
# Color options # |
| ... | ... |
@@ -131,7 +115,7 @@ fi |
| 131 | 115 |
|
| 132 | 116 |
if [[ "$color_prompt" == "yes" ]] |
| 133 | 117 |
then |
| 134 |
- if [[ -n "$SSH_CONNECTION" ]] |
|
| 118 |
+ if [[ -n "$SSH_CONNECTION" ]] |
|
| 135 | 119 |
then |
| 136 | 120 |
PS1='\[\e[31m\][$(date +%H:%M) \u@\[\e[01;35m\]\h\[\e[00;31m\]:\[\e[33m\]\W\[\e[31m\]]\[\e[00m\]\$ ' |
| 137 | 121 |
else |
| ... | ... |
@@ -202,7 +186,7 @@ alias diff="diff -y --suppress-common-lines" |
| 202 | 186 |
alias dl="wget -c" |
| 203 | 187 |
alias scp="scp -pr" |
| 204 | 188 |
alias ssh="ssh -Y" |
| 205 |
-alias wf="ssh wf@vaderf.com" |
|
| 189 |
+alias wf="ssh -i $HOME/.ssh/id_main-server.dsa wf@vaderf.com" |
|
| 206 | 190 |
alias fwf="ssh fred@vaderf.com" |
| 207 | 191 |
alias heron="ssh fcheval@heron.txbiomedgenetics.org" |
| 208 | 192 |
|
| ... | ... |
@@ -357,6 +341,29 @@ function q {
|
| 357 | 341 |
} |
| 358 | 342 |
|
| 359 | 343 |
|
| 344 |
+# SSH agent function |
|
| 345 |
+function start_agent {
|
|
| 346 |
+ if [[ $LANG =~ ^fr ]] |
|
| 347 |
+ then |
|
| 348 |
+ msg1="Initialisation du nouvel agent SSH..." |
|
| 349 |
+ msg2="Opération réussi" |
|
| 350 |
+ else |
|
| 351 |
+ msg1="Initializing new SSH agent..." |
|
| 352 |
+ msg2="Succeeded" |
|
| 353 |
+ fi |
|
| 354 |
+ |
|
| 355 |
+ # SSH agent environment |
|
| 356 |
+ echo -e "\n${msg1}"
|
|
| 357 |
+ ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
|
|
| 358 |
+ echo -e "${msg2}\n"
|
|
| 359 |
+ chmod 600 "${SSH_ENV}"
|
|
| 360 |
+ source "${SSH_ENV}" > /dev/null
|
|
| 361 |
+ |
|
| 362 |
+ # SSH key add |
|
| 363 |
+ ssh-add |
|
| 364 |
+} |
|
| 365 |
+ |
|
| 366 |
+ |
|
| 360 | 367 |
|
| 361 | 368 |
#================================================# |
| 362 | 369 |
# User specific environment and startup programs # |
| ... | ... |
@@ -382,3 +389,20 @@ export TEXMFHOME="$HOME/.texmf" |
| 382 | 389 |
# R environment |
| 383 | 390 |
export R_HISTFILE="$HOME/.Rhistory" |
| 384 | 391 |
export R_HISTSIZE=$HISTSIZE |
| 392 |
+ |
|
| 393 |
+ |
|
| 394 |
+# SSH environment |
|
| 395 |
+SSH_ENV="$HOME/.ssh/ssh_agent_$HOSTNAME" |
|
| 396 |
+ |
|
| 397 |
+if [[ -n "$SSH_CONNECTION" ]] |
|
| 398 |
+then |
|
| 399 |
+ # Source SSH settings, if applicable |
|
| 400 |
+ if [[ -f "${SSH_ENV}" ]]
|
|
| 401 |
+ then |
|
| 402 |
+ source "${SSH_ENV}" > /dev/null
|
|
| 403 |
+ #ps ${SSH_AGENT_PID} doesn't work under cywgin
|
|
| 404 |
+ ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || start_agent
|
|
| 405 |
+ else |
|
| 406 |
+ start_agent |
|
| 407 |
+ fi |
|
| 408 |
+fi |
|
| 385 | 409 |
\ No newline at end of file |