| ... | ... |
@@ -1,8 +1,8 @@ |
| 1 | 1 |
# Title: .bashrc |
| 2 | 2 |
# Author: Frédéric CHEVALIER <f15.chevalier@gmail.com> |
| 3 |
-# Version: 1.13 |
|
| 3 |
+# Version: 1.14 |
|
| 4 | 4 |
# Created in: 2012-05-26 |
| 5 |
-# Modified in: 2016-08-14 |
|
| 5 |
+# Modified in: 2016-10-06 |
|
| 6 | 6 |
|
| 7 | 7 |
|
| 8 | 8 |
|
| ... | ... |
@@ -19,6 +19,7 @@ |
| 19 | 19 |
# Versions # |
| 20 | 20 |
#==========# |
| 21 | 21 |
|
| 22 |
+# v1.14 - 2016-10-06: ls aliases improved to not display quote around names with spaces / terminal title functions added |
|
| 22 | 23 |
# v1.13 - 2016-08-14: command history automatically appended / HISTSIZE increased / ssh alias without -Y for improving security / trash function improved |
| 23 | 24 |
# v1.12 - 2016-01-01: PS1 updated / extract function updated |
| 24 | 25 |
# v1.11 - 2015-08-17: sty-updater function added |
| ... | ... |
@@ -207,11 +208,11 @@ alias ..="cd .." |
| 207 | 208 |
alias ....="cd ../.." |
| 208 | 209 |
|
| 209 | 210 |
# Listing files |
| 210 |
-alias l="ls" |
|
| 211 |
+alias l="ls -N" |
|
| 211 | 212 |
alias ll="l -l" |
| 212 | 213 |
alias lr="l --recursive" |
| 213 | 214 |
alias llr="ll --recursive" |
| 214 |
-alias la="ls -A" |
|
| 215 |
+alias la="ls -AN" |
|
| 215 | 216 |
alias lla="la -l" |
| 216 | 217 |
|
| 217 | 218 |
# File manipulations |
| ... | ... |
@@ -412,7 +413,21 @@ function sty-updater {
|
| 412 | 413 |
# Info message |
| 413 | 414 |
echo -e "The STY value has been updated:\n\t- old value: $old_sty\n\t- new value: $STY" |
| 414 | 415 |
fi |
| 415 |
-} |
|
| 416 |
+} |
|
| 417 |
+ |
|
| 418 |
+ |
|
| 419 |
+# Terminal title definition |
|
| 420 |
+## Specific terminal title |
|
| 421 |
+function termtitle() {
|
|
| 422 |
+ PS1=$(echo "$PS1" | sed "s,\\\\\[\\\e\\]0;.*\\\a\\\],,") # Remove previous title present in the prompt if any |
|
| 423 |
+ echo -ne "\e]0;$1\a" |
|
| 424 |
+} |
|
| 425 |
+ |
|
| 426 |
+## Terminal title from path |
|
| 427 |
+function termtitlepath() {
|
|
| 428 |
+ TTY=$(tty) |
|
| 429 |
+ PS1="\[\e]0;\h - ${TTY#/dev/} | \w\a\]$PS1"
|
|
| 430 |
+} |
|
| 416 | 431 |
|
| 417 | 432 |
|
| 418 | 433 |
|
| ... | ... |
@@ -420,6 +435,10 @@ function sty-updater {
|
| 420 | 435 |
# User specific environment and startup programs # |
| 421 | 436 |
#================================================# |
| 422 | 437 |
|
| 438 |
+# Set default terminal title |
|
| 439 |
+termtitlepath |
|
| 440 |
+ |
|
| 441 |
+ |
|
| 423 | 442 |
# Editor |
| 424 | 443 |
if [[ $(which vim &> /dev/null ; echo $?) == 0 ]] |
| 425 | 444 |
then |
History size increased, history appended after each command, -Y option of ssh alias removed, and trash function improved
| ... | ... |
@@ -1,8 +1,8 @@ |
| 1 | 1 |
# Title: .bashrc |
| 2 | 2 |
# Author: Frédéric CHEVALIER <f15.chevalier@gmail.com> |
| 3 |
-# Version: 1.12 |
|
| 3 |
+# Version: 1.13 |
|
| 4 | 4 |
# Created in: 2012-05-26 |
| 5 |
-# Modified in: 2016-01-01 |
|
| 5 |
+# Modified in: 2016-08-14 |
|
| 6 | 6 |
|
| 7 | 7 |
|
| 8 | 8 |
|
| ... | ... |
@@ -19,6 +19,7 @@ |
| 19 | 19 |
# Versions # |
| 20 | 20 |
#==========# |
| 21 | 21 |
|
| 22 |
+# v1.13 - 2016-08-14: command history automatically appended / HISTSIZE increased / ssh alias without -Y for improving security / trash function improved |
|
| 22 | 23 |
# v1.12 - 2016-01-01: PS1 updated / extract function updated |
| 23 | 24 |
# v1.11 - 2015-08-17: sty-updater function added |
| 24 | 25 |
# v1.10 - 2015-04-19: one archive format added to the extract function / less behaviour improved / alias updated |
| ... | ... |
@@ -68,10 +69,10 @@ export HISTCONTROL=ignoreboth |
| 68 | 69 |
export HISTIGNORE=$'[ \t]*:&:[fb]g:l[slar]:l:ll[ar]:exit:q:?q:s:ns:screen -X*' |
| 69 | 70 |
|
| 70 | 71 |
# Whenever displaying the prompt, write the previous line to disk |
| 71 |
-#export PROMPT_COMMAND="history -a" |
|
| 72 |
+export PROMPT_COMMAND="history -a" |
|
| 72 | 73 |
|
| 73 | 74 |
# Maximum command retain in the .bash_history file |
| 74 |
-export HISTSIZE=2000 |
|
| 75 |
+export HISTSIZE=50000 |
|
| 75 | 76 |
|
| 76 | 77 |
# Add timestamps for each command |
| 77 | 78 |
export HISTTIMEFORMAT="$(echo -e '\e[0;32m')[ %d/%m/%Y %H:%M:%S ] $(echo -e '\e[0m') " |
| ... | ... |
@@ -109,7 +110,7 @@ shopt -s autocd |
| 109 | 110 |
# source: http://stackoverflow.com/questions/6787734/strange-behavior-of-vim-color-inside-screen-with-256-colors |
| 110 | 111 |
case "$TERM" in |
| 111 | 112 |
*-256color) |
| 112 |
- alias myssh="TERM=${TERM%-256color} ssh"
|
|
| 113 |
+ alias ssh="TERM=${TERM%-256color} ssh"
|
|
| 113 | 114 |
;; |
| 114 | 115 |
*) |
| 115 | 116 |
POTENTIAL_TERM=${TERM}-256color
|
| ... | ... |
@@ -124,7 +125,6 @@ case "$TERM" in |
| 124 | 125 |
# export TERM=$POTENTIAL_TERM |
| 125 | 126 |
fi |
| 126 | 127 |
|
| 127 |
- alias myssh="ssh" |
|
| 128 | 128 |
;; |
| 129 | 129 |
esac |
| 130 | 130 |
|
| ... | ... |
@@ -220,7 +220,6 @@ alias diff="diff -y --suppress-common-lines" |
| 220 | 220 |
# Internet |
| 221 | 221 |
alias dl="wget -c" |
| 222 | 222 |
alias scp="scp -pr" |
| 223 |
-alias ssh="myssh -Y" |
|
| 224 | 223 |
alias wf="ssh wf" |
| 225 | 224 |
alias fwf="ssh fwf" |
| 226 | 225 |
alias heron="ssh heron" |
| ... | ... |
@@ -349,7 +348,7 @@ then |
| 349 | 348 |
else |
| 350 | 349 |
if [[ -d $HOME/.trash/ ]] |
| 351 | 350 |
then |
| 352 |
- alias trash='mv $1 -t $HOME/.trash/' |
|
| 351 |
+ alias trash='mv -f --backup=numbered -t $HOME/.trash/ $@' |
|
| 353 | 352 |
else |
| 354 | 353 |
echo -e "\n\tNo trash set up: trash-cli not installed or $HOME/.trash/ does not exist.\n" |
| 355 | 354 |
fi |
| ... | ... |
@@ -409,11 +408,11 @@ function sty-updater {
|
| 409 | 408 |
|
| 410 | 409 |
# Update STY with the new value |
| 411 | 410 |
export STY=$(screen -list | sed "s/^\t//g" | grep $(echo $STY | cut -d "." -f 1) | cut -f 1) |
| 412 |
- |
|
| 411 |
+ |
|
| 413 | 412 |
# Info message |
| 414 | 413 |
echo -e "The STY value has been updated:\n\t- old value: $old_sty\n\t- new value: $STY" |
| 415 | 414 |
fi |
| 416 |
-} |
|
| 415 |
+} |
|
| 417 | 416 |
|
| 418 | 417 |
|
| 419 | 418 |
|
| ... | ... |
@@ -1,8 +1,8 @@ |
| 1 | 1 |
# Title: .bashrc |
| 2 | 2 |
# Author: Frédéric CHEVALIER <f15.chevalier@gmail.com> |
| 3 |
-# Version: 1.11 |
|
| 3 |
+# Version: 1.12 |
|
| 4 | 4 |
# Created in: 2012-05-26 |
| 5 |
-# Modified in: 2015-08-17 |
|
| 5 |
+# Modified in: 2016-01-01 |
|
| 6 | 6 |
|
| 7 | 7 |
|
| 8 | 8 |
|
| ... | ... |
@@ -19,6 +19,7 @@ |
| 19 | 19 |
# Versions # |
| 20 | 20 |
#==========# |
| 21 | 21 |
|
| 22 |
+# v1.12 - 2016-01-01: PS1 updated / extract function updated |
|
| 22 | 23 |
# v1.11 - 2015-08-17: sty-updater function added |
| 23 | 24 |
# v1.10 - 2015-04-19: one archive format added to the extract function / less behaviour improved / alias updated |
| 24 | 25 |
# v1.9 - 2014-10-18: value of TERM variable determined by case statement => this fix 256 color terminal problem / improvement of color capability detection / alias added |
| ... | ... |
@@ -147,10 +148,16 @@ if [[ "$color_prompt" == "yes" ]] |
| 147 | 148 |
then |
| 148 | 149 |
if [[ -n "$SSH_CONNECTION" ]] |
| 149 | 150 |
then |
| 150 |
- PS1='\[\e[31m\][$(date +%H:%M) \u@\[\e[01;35m\]\h\[\e[00;31m\]:\[\e[33m\]\W\[\e[31m\]]\[\e[00m\]\$ ' |
|
| 151 |
+ PS1='\[\e[31m\][$(date +%H:%M) \[\e[01;34m\]\u\[\e[00;31m\]@\[\e[01;35m\]\h\[\e[00;31m\]:\[\e[33m\]\W\[\e[31m\]]\[\e[00m\]\$ ' |
|
| 151 | 152 |
else |
| 152 |
- PS1='\[\e[36m\][$(date +%H:%M) \u@\[\e[01;35m\]\h\[\e[00;36m\]:\[\e[33m\]\W\[\e[36m\]]\[\e[00m\]\$ ' |
|
| 153 |
+ PS1='\[\e[36m\][$(date +%H:%M) \[\e[01;34m\]\u\[\e[00;36m\]@\[\e[01;35m\]\h\[\e[00;36m\]:\[\e[33m\]\W\[\e[36m\]]\[\e[00m\]\$ ' |
|
| 153 | 154 |
fi |
| 155 |
+ |
|
| 156 |
+ if [[ $EUID -eq 0 ]] |
|
| 157 |
+ then |
|
| 158 |
+ PS1='\[\e[7m\]\[\e[31m\][$(date +%H:%M) \u@\h:\W]\[\e[00m\]\$ ' |
|
| 159 |
+ fi |
|
| 160 |
+ |
|
| 154 | 161 |
else |
| 155 | 162 |
PS1='[$(date +%H:%M) \u@\h:\W]\$ ' |
| 156 | 163 |
fi |
| ... | ... |
@@ -323,7 +330,8 @@ function extract {
|
| 323 | 330 |
*.bz2 ) bunzip2 "$1" ;; |
| 324 | 331 |
*.rar ) rar x "$1" ;; |
| 325 | 332 |
*.xz ) tar xvJf "$1" ;; |
| 326 |
- *.zip | *.7z ) unzip "$1" ;; |
|
| 333 |
+ *.zip ) unzip "$1" ;; |
|
| 334 |
+ *.7z ) 7z x "$1" ;; |
|
| 327 | 335 |
*.Z ) uncompress "$1" ;; |
| 328 | 336 |
* ) echo "don't know how to extract '$1'..." ;; |
| 329 | 337 |
esac |
| ... | ... |
@@ -1,8 +1,8 @@ |
| 1 | 1 |
# Title: .bashrc |
| 2 | 2 |
# Author: Frédéric CHEVALIER <f15.chevalier@gmail.com> |
| 3 |
-# Version: 1.10 |
|
| 3 |
+# Version: 1.11 |
|
| 4 | 4 |
# Created in: 2012-05-26 |
| 5 |
-# Modified in: 2015-04-19 |
|
| 5 |
+# Modified in: 2015-08-17 |
|
| 6 | 6 |
|
| 7 | 7 |
|
| 8 | 8 |
|
| ... | ... |
@@ -19,7 +19,8 @@ |
| 19 | 19 |
# Versions # |
| 20 | 20 |
#==========# |
| 21 | 21 |
|
| 22 |
-# v.1.10 - 2015-04-19: one archive format added to the extract function / less behaviour improved / alias updated |
|
| 22 |
+# v1.11 - 2015-08-17: sty-updater function added |
|
| 23 |
+# v1.10 - 2015-04-19: one archive format added to the extract function / less behaviour improved / alias updated |
|
| 23 | 24 |
# v1.9 - 2014-10-18: value of TERM variable determined by case statement => this fix 256 color terminal problem / improvement of color capability detection / alias added |
| 24 | 25 |
# v1.8 - 2014-10-14: HISTIGNORE correction and adding / start_agent function output improved |
| 25 | 26 |
# v1.7 - 2014-09-25: start_agent function improved |
| ... | ... |
@@ -387,6 +388,26 @@ function start_agent {
|
| 387 | 388 |
} |
| 388 | 389 |
|
| 389 | 390 |
|
| 391 |
+# STY updater |
|
| 392 |
+# Usage: reset the STY value after change in screen session name |
|
| 393 |
+function sty-updater {
|
|
| 394 |
+ # Check for STY presence |
|
| 395 |
+ if [[ -z "$STY" ]] |
|
| 396 |
+ then |
|
| 397 |
+ echo "No STY present." |
|
| 398 |
+ else |
|
| 399 |
+ # Get the current STY value |
|
| 400 |
+ old_sty=$STY |
|
| 401 |
+ |
|
| 402 |
+ # Update STY with the new value |
|
| 403 |
+ export STY=$(screen -list | sed "s/^\t//g" | grep $(echo $STY | cut -d "." -f 1) | cut -f 1) |
|
| 404 |
+ |
|
| 405 |
+ # Info message |
|
| 406 |
+ echo -e "The STY value has been updated:\n\t- old value: $old_sty\n\t- new value: $STY" |
|
| 407 |
+ fi |
|
| 408 |
+} |
|
| 409 |
+ |
|
| 410 |
+ |
|
| 390 | 411 |
|
| 391 | 412 |
#================================================# |
| 392 | 413 |
# User specific environment and startup programs # |
| ... | ... |
@@ -1,8 +1,8 @@ |
| 1 | 1 |
# Title: .bashrc |
| 2 | 2 |
# Author: Frédéric CHEVALIER <f15.chevalier@gmail.com> |
| 3 |
-# Version: 1.9 |
|
| 3 |
+# Version: 1.10 |
|
| 4 | 4 |
# Created in: 2012-05-26 |
| 5 |
-# Modified in: 2014-10-18 |
|
| 5 |
+# Modified in: 2015-04-19 |
|
| 6 | 6 |
|
| 7 | 7 |
|
| 8 | 8 |
|
| ... | ... |
@@ -19,6 +19,7 @@ |
| 19 | 19 |
# Versions # |
| 20 | 20 |
#==========# |
| 21 | 21 |
|
| 22 |
+# v.1.10 - 2015-04-19: one archive format added to the extract function / less behaviour improved / alias updated |
|
| 22 | 23 |
# v1.9 - 2014-10-18: value of TERM variable determined by case statement => this fix 256 color terminal problem / improvement of color capability detection / alias added |
| 23 | 24 |
# v1.8 - 2014-10-14: HISTIGNORE correction and adding / start_agent function output improved |
| 24 | 25 |
# v1.7 - 2014-09-25: start_agent function improved |
| ... | ... |
@@ -62,7 +63,7 @@ export HISTCONTROL=ignoreboth |
| 62 | 63 |
|
| 63 | 64 |
# Ignore some controlling instructions |
| 64 | 65 |
# The '&' is a special pattern which suppresses duplicate entries. |
| 65 |
-export HISTIGNORE=$'[ \t]*:&:[fb]g:l[slar]:l:ll[ar]:exit:q:?q:s:ns:screen*' |
|
| 66 |
+export HISTIGNORE=$'[ \t]*:&:[fb]g:l[slar]:l:ll[ar]:exit:q:?q:s:ns:screen -X*' |
|
| 66 | 67 |
|
| 67 | 68 |
# Whenever displaying the prompt, write the previous line to disk |
| 68 | 69 |
#export PROMPT_COMMAND="history -a" |
| ... | ... |
@@ -170,13 +171,11 @@ then |
| 170 | 171 |
export LESS_TERMCAP_us=$'\e[01;35m' # underlined start (if white bg: $'\e[01;32m') |
| 171 | 172 |
fi |
| 172 | 173 |
|
| 173 |
-unset color_prompt |
|
| 174 |
- |
|
| 175 | 174 |
|
| 176 | 175 |
# Enable color support of ls and grep and also add handy aliases |
| 177 |
-if [[ -x /usr/bin/dircolors ]] |
|
| 176 |
+if [[ -x /usr/bin/dircolors && "$color_prompt" == "yes" ]] |
|
| 178 | 177 |
then |
| 179 |
- test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" |
|
| 178 |
+ [[ -r ~/.dircolors ]] && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" |
|
| 180 | 179 |
|
| 181 | 180 |
alias ls="ls --color=auto --group-directories-first -h -C" |
| 182 | 181 |
alias dir="dir --color=auto" |
| ... | ... |
@@ -209,15 +208,14 @@ alias lla="la -l" |
| 209 | 208 |
|
| 210 | 209 |
# File manipulations |
| 211 | 210 |
alias diff="diff -y --suppress-common-lines" |
| 212 |
-alias less="less -R" |
|
| 213 | 211 |
|
| 214 | 212 |
# Internet |
| 215 | 213 |
alias dl="wget -c" |
| 216 | 214 |
alias scp="scp -pr" |
| 217 | 215 |
alias ssh="myssh -Y" |
| 218 |
-alias wf="ssh -i $HOME/.ssh/id_main-server.dsa wf@vaderf.com" |
|
| 219 |
-alias fwf="ssh fred@vaderf.com" |
|
| 220 |
-alias heron="ssh fcheval@heron.txbiomedgenetics.org" |
|
| 216 |
+alias wf="ssh wf" |
|
| 217 |
+alias fwf="ssh fwf" |
|
| 218 |
+alias heron="ssh heron" |
|
| 221 | 219 |
|
| 222 | 220 |
# Disk space |
| 223 | 221 |
alias df="df -h" |
| ... | ... |
@@ -314,17 +312,18 @@ alias cd=cd_func |
| 314 | 312 |
|
| 315 | 313 |
# Extract function |
| 316 | 314 |
function extract {
|
| 317 |
- if [[ -f $1 ]] |
|
| 315 |
+ if [[ -f "$1" ]] |
|
| 318 | 316 |
then |
| 319 | 317 |
case $1 in |
| 320 |
- *.tar.bz2 | *.tbz2 ) tar xvjf $1 ;; |
|
| 321 |
- *.tar.gz | *.tgz ) tar xvzf $1 ;; |
|
| 322 |
- *.tar ) tar xvf $1 ;; |
|
| 323 |
- *.gz ) gunzip $1 ;; |
|
| 324 |
- *.bz2 ) bunzip2 $1 ;; |
|
| 325 |
- *.rar ) rar x $1 ;; |
|
| 326 |
- *.zip | *.7z ) unzip $1 ;; |
|
| 327 |
- *.Z ) uncompress $1 ;; |
|
| 318 |
+ *.tar.bz2 | *.tbz2 ) tar xvjf "$1" ;; |
|
| 319 |
+ *.tar.gz | *.tgz ) tar xvzf "$1" ;; |
|
| 320 |
+ *.tar ) tar xvf "$1" ;; |
|
| 321 |
+ *.gz ) gunzip "$1" ;; |
|
| 322 |
+ *.bz2 ) bunzip2 "$1" ;; |
|
| 323 |
+ *.rar ) rar x "$1" ;; |
|
| 324 |
+ *.xz ) tar xvJf "$1" ;; |
|
| 325 |
+ *.zip | *.7z ) unzip "$1" ;; |
|
| 326 |
+ *.Z ) uncompress "$1" ;; |
|
| 328 | 327 |
* ) echo "don't know how to extract '$1'..." ;; |
| 329 | 328 |
esac |
| 330 | 329 |
else |
| ... | ... |
@@ -378,12 +377,13 @@ function start_agent {
|
| 378 | 377 |
# SSH agent environment |
| 379 | 378 |
echo -e "\n${msg1}"
|
| 380 | 379 |
ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
|
| 381 |
- echo -e "${msg2}\n\n"
|
|
| 380 |
+ echo -e "${msg2}\n"
|
|
| 382 | 381 |
chmod 600 "${SSH_ENV}"
|
| 383 | 382 |
source "${SSH_ENV}" > /dev/null
|
| 384 | 383 |
|
| 385 | 384 |
# SSH key add ($@: useful to add ssh-add options like lifetime directly through start_agent) |
| 386 | 385 |
ssh-add $@ |
| 386 |
+ echo "" |
|
| 387 | 387 |
} |
| 388 | 388 |
|
| 389 | 389 |
|
| ... | ... |
@@ -417,3 +417,39 @@ export R_HISTSIZE=$HISTSIZE |
| 417 | 417 |
# SSH environment |
| 418 | 418 |
export SSH_ENV="$HOME/.ssh/ssh_agent_$HOSTNAME" |
| 419 | 419 |
|
| 420 |
+ |
|
| 421 |
+# LESS environment |
|
| 422 |
+if [[ "$color_prompt" == yes ]] |
|
| 423 |
+then |
|
| 424 |
+ export LESS="-RM " |
|
| 425 |
+ |
|
| 426 |
+ # Pretty less function |
|
| 427 |
+ function pless {
|
|
| 428 |
+ # Pygmentize version |
|
| 429 |
+ #pygmentize -f 256 -P style=friendly $@ | less -R |
|
| 430 |
+ |
|
| 431 |
+ # Vim version |
|
| 432 |
+ /usr/share/vim/vim$(vim --version | grep -o -m 1 "[[:digit:]]\.[[:digit:]]" | sed "s/\.//g")/macros/less.sh "$@" |
|
| 433 |
+ } |
|
| 434 |
+ |
|
| 435 |
+ # Dependency: lesspipe.sh |
|
| 436 |
+ ## source: http://www-zeuthen.desy.de/~friebel/unix/lesspipe.html |
|
| 437 |
+ if [[ -x $(which lesspipe.sh 2> /dev/null) ]] |
|
| 438 |
+ then |
|
| 439 |
+ unset LESSOPEN |
|
| 440 |
+ #eval "$(SHELL=/bin/sh lesspipe.sh)" |
|
| 441 |
+ export LESSOPEN="| lesspipe.sh %s 2> /dev/null" # Avoid pigmentize message when lexer not found |
|
| 442 |
+ |
|
| 443 |
+ if [[ -x $(which pygmentize 2> /dev/null) ]] |
|
| 444 |
+ then |
|
| 445 |
+ export LESSCOLORIZER="pygmentize" |
|
| 446 |
+ elif [[ -x $(which code2color 2> /dev/null) ]] |
|
| 447 |
+ then |
|
| 448 |
+ export LESSCOLORIZER="code2color" |
|
| 449 |
+ fi |
|
| 450 |
+ fi |
|
| 451 |
+fi |
|
| 452 |
+ |
|
| 453 |
+ |
|
| 454 |
+# Unset variables previously created |
|
| 455 |
+unset color_prompt |
| ... | ... |
@@ -1,8 +1,8 @@ |
| 1 | 1 |
# Title: .bashrc |
| 2 | 2 |
# Author: Frédéric CHEVALIER <f15.chevalier@gmail.com> |
| 3 |
-# Version: 1.8 |
|
| 3 |
+# Version: 1.9 |
|
| 4 | 4 |
# Created in: 2012-05-26 |
| 5 |
-# Modified in: 2014-10-14 |
|
| 5 |
+# Modified in: 2014-10-18 |
|
| 6 | 6 |
|
| 7 | 7 |
|
| 8 | 8 |
|
| ... | ... |
@@ -19,6 +19,7 @@ |
| 19 | 19 |
# Versions # |
| 20 | 20 |
#==========# |
| 21 | 21 |
|
| 22 |
+# v1.9 - 2014-10-18: value of TERM variable determined by case statement => this fix 256 color terminal problem / improvement of color capability detection / alias added |
|
| 22 | 23 |
# v1.8 - 2014-10-14: HISTIGNORE correction and adding / start_agent function output improved |
| 23 | 24 |
# v1.7 - 2014-09-25: start_agent function improved |
| 24 | 25 |
# v1.6 - 2014-08-16: new history entries to ignore / screen and :q aliases |
| ... | ... |
@@ -96,24 +97,48 @@ shopt -s autocd |
| 96 | 97 |
[[ -x /usr/bin/lesspipe ]] && eval "$(SHELL=/bin/sh lesspipe)" |
| 97 | 98 |
|
| 98 | 99 |
|
| 100 |
+#--------------------# |
|
| 101 |
+# Terminal selection # |
|
| 102 |
+#--------------------# |
|
| 103 |
+ |
|
| 104 |
+# To select the right terminal |
|
| 105 |
+# (case of distant server that may not possess color capabilty for terminal) |
|
| 106 |
+# source: http://stackoverflow.com/questions/6787734/strange-behavior-of-vim-color-inside-screen-with-256-colors |
|
| 107 |
+case "$TERM" in |
|
| 108 |
+ *-256color) |
|
| 109 |
+ alias myssh="TERM=${TERM%-256color} ssh"
|
|
| 110 |
+ ;; |
|
| 111 |
+ *) |
|
| 112 |
+ POTENTIAL_TERM=${TERM}-256color
|
|
| 113 |
+# POTENTIAL_TERMINFO=${TERM:0:1}/$POTENTIAL_TERM
|
|
| 114 |
+# HOME_TERMINFO_DIR=$HOME/.terminfo |
|
| 115 |
+ |
|
| 116 |
+ if [[ $(toe -a | cut -f 1 | grep $POTENTIAL_TERM) ]] |
|
| 117 |
+ then |
|
| 118 |
+ export TERM=$POTENTIAL_TERM |
|
| 119 |
+# elif [[ -f $HOME_TERMINFO_DIR/$POTENTIAL_TERMINFO ]] |
|
| 120 |
+# then |
|
| 121 |
+# export TERM=$POTENTIAL_TERM |
|
| 122 |
+ fi |
|
| 123 |
+ |
|
| 124 |
+ alias myssh="ssh" |
|
| 125 |
+ ;; |
|
| 126 |
+esac |
|
| 127 |
+ |
|
| 128 |
+unset POTENTIAL_TERM BOX_TERMINFO_DIR HOME_TERMINFO_DIR |
|
| 129 |
+ |
|
| 130 |
+ |
|
| 131 |
+ |
|
| 99 | 132 |
#---------------# |
| 100 | 133 |
# Color options # |
| 101 | 134 |
#---------------# |
| 102 | 135 |
|
| 103 |
-# Set a fancy prompt (non-color, unless we know we "want" color) |
|
| 104 |
-force_color_prompt=yes |
|
| 105 |
- |
|
| 106 |
-if [ -n "$force_color_prompt" ] |
|
| 136 |
+# Set a fancy prompt if capability present |
|
| 137 |
+if [[ -x /usr/bin/tput && $(tput -T$TERM colors) -ge 8 ]] |
|
| 107 | 138 |
then |
| 108 |
- if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null |
|
| 109 |
- then |
|
| 110 |
- # We have color support; assume it's compliant with Ecma-48 |
|
| 111 |
- # (ISO/IEC-6429). (Lack of such support is extremely rare, and such |
|
| 112 |
- # a case would tend to support setf rather than setaf.) |
|
| 113 |
- color_prompt=yes |
|
| 114 |
- else |
|
| 115 |
- color_prompt= |
|
| 116 |
- fi |
|
| 139 |
+ color_prompt=yes |
|
| 140 |
+else |
|
| 141 |
+ color_prompt= |
|
| 117 | 142 |
fi |
| 118 | 143 |
|
| 119 | 144 |
if [[ "$color_prompt" == "yes" ]] |
| ... | ... |
@@ -136,16 +161,16 @@ PS1="${debian_chroot:+($debian_chroot)}$PS1"
|
| 136 | 161 |
# Enable colors for man pages (adapt colors as needed) |
| 137 | 162 |
if [[ "$color_prompt" == "yes" ]] |
| 138 | 163 |
then |
| 139 |
- export LESS_TERMCAP_mb=$'\e[01;31m' # blink start |
|
| 140 |
- export LESS_TERMCAP_md=$'\e[01;33m' # bold start (if white bg: $'\e[01;31m') |
|
| 141 |
- export LESS_TERMCAP_me=$'\e[0m' # end |
|
| 142 |
- export LESS_TERMCAP_se=$'\e[0m' # end |
|
| 143 |
- export LESS_TERMCAP_so=$'\e[01;44;33m' # status line start |
|
| 144 |
- export LESS_TERMCAP_ue=$'\e[0m' # end |
|
| 145 |
- export LESS_TERMCAP_us=$'\e[01;35m' # underlined start (if white bg: $'\e[01;32m') |
|
| 164 |
+ export LESS_TERMCAP_mb=$'\e[01;31m' # blink start |
|
| 165 |
+ export LESS_TERMCAP_md=$'\e[01;33m' # bold start (if white bg: $'\e[01;31m') |
|
| 166 |
+ export LESS_TERMCAP_me=$'\e[0m' # end |
|
| 167 |
+ export LESS_TERMCAP_se=$'\e[0m' # end |
|
| 168 |
+ export LESS_TERMCAP_so=$'\e[01;44;33m' # status line start |
|
| 169 |
+ export LESS_TERMCAP_ue=$'\e[0m' # end |
|
| 170 |
+ export LESS_TERMCAP_us=$'\e[01;35m' # underlined start (if white bg: $'\e[01;32m') |
|
| 146 | 171 |
fi |
| 147 | 172 |
|
| 148 |
-unset color_prompt force_color_prompt |
|
| 173 |
+unset color_prompt |
|
| 149 | 174 |
|
| 150 | 175 |
|
| 151 | 176 |
# Enable color support of ls and grep and also add handy aliases |
| ... | ... |
@@ -184,11 +209,12 @@ alias lla="la -l" |
| 184 | 209 |
|
| 185 | 210 |
# File manipulations |
| 186 | 211 |
alias diff="diff -y --suppress-common-lines" |
| 212 |
+alias less="less -R" |
|
| 187 | 213 |
|
| 188 | 214 |
# Internet |
| 189 | 215 |
alias dl="wget -c" |
| 190 | 216 |
alias scp="scp -pr" |
| 191 |
-alias ssh="ssh -Y" |
|
| 217 |
+alias ssh="myssh -Y" |
|
| 192 | 218 |
alias wf="ssh -i $HOME/.ssh/id_main-server.dsa wf@vaderf.com" |
| 193 | 219 |
alias fwf="ssh fred@vaderf.com" |
| 194 | 220 |
alias heron="ssh fcheval@heron.txbiomedgenetics.org" |
See Versions section of the file for details
| ... | ... |
@@ -1,8 +1,8 @@ |
| 1 | 1 |
# Title: .bashrc |
| 2 | 2 |
# Author: Frédéric CHEVALIER <f15.chevalier@gmail.com> |
| 3 |
-# Version: 1.7 |
|
| 3 |
+# Version: 1.8 |
|
| 4 | 4 |
# Created in: 2012-05-26 |
| 5 |
-# Modified in: 2014-09-25 |
|
| 5 |
+# Modified in: 2014-10-14 |
|
| 6 | 6 |
|
| 7 | 7 |
|
| 8 | 8 |
|
| ... | ... |
@@ -19,6 +19,7 @@ |
| 19 | 19 |
# Versions # |
| 20 | 20 |
#==========# |
| 21 | 21 |
|
| 22 |
+# v1.8 - 2014-10-14: HISTIGNORE correction and adding / start_agent function output improved |
|
| 22 | 23 |
# v1.7 - 2014-09-25: start_agent function improved |
| 23 | 24 |
# v1.6 - 2014-08-16: new history entries to ignore / screen and :q aliases |
| 24 | 25 |
# v1.5 - 2014-08-06: autocd set on / R alias added /bk function turned in a separate script / SSH environment setup moved in bash_profile |
| ... | ... |
@@ -60,8 +61,7 @@ export HISTCONTROL=ignoreboth |
| 60 | 61 |
|
| 61 | 62 |
# Ignore some controlling instructions |
| 62 | 63 |
# The '&' is a special pattern which suppresses duplicate entries. |
| 63 |
-export HISTIGNORE=$'[ \t]*:&:[fb]g:exit:*q:screen*' |
|
| 64 |
-# export HISTIGNORE=$'[ \t]*:&:[fb]g:exit:ls' # Ignore the ls command as well |
|
| 64 |
+export HISTIGNORE=$'[ \t]*:&:[fb]g:l[slar]:l:ll[ar]:exit:q:?q:s:ns:screen*' |
|
| 65 | 65 |
|
| 66 | 66 |
# Whenever displaying the prompt, write the previous line to disk |
| 67 | 67 |
#export PROMPT_COMMAND="history -a" |
| ... | ... |
@@ -352,7 +352,7 @@ function start_agent {
|
| 352 | 352 |
# SSH agent environment |
| 353 | 353 |
echo -e "\n${msg1}"
|
| 354 | 354 |
ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
|
| 355 |
- echo -e "${msg2}\n"
|
|
| 355 |
+ echo -e "${msg2}\n\n"
|
|
| 356 | 356 |
chmod 600 "${SSH_ENV}"
|
| 357 | 357 |
source "${SSH_ENV}" > /dev/null
|
| 358 | 358 |
|
Update of bashrc and bash_profile to add ssh key lifetime (or any ssh-agent option) to the start_agent function and use it in the bash_profile on cygwin.
| ... | ... |
@@ -1,8 +1,8 @@ |
| 1 | 1 |
# Title: .bashrc |
| 2 | 2 |
# Author: Frédéric CHEVALIER <f15.chevalier@gmail.com> |
| 3 |
-# Version: 1.6 |
|
| 3 |
+# Version: 1.7 |
|
| 4 | 4 |
# Created in: 2012-05-26 |
| 5 |
-# Modified in: 2014-08-16 |
|
| 5 |
+# Modified in: 2014-09-25 |
|
| 6 | 6 |
|
| 7 | 7 |
|
| 8 | 8 |
|
| ... | ... |
@@ -19,6 +19,7 @@ |
| 19 | 19 |
# Versions # |
| 20 | 20 |
#==========# |
| 21 | 21 |
|
| 22 |
+# v1.7 - 2014-09-25: start_agent function improved |
|
| 22 | 23 |
# v1.6 - 2014-08-16: new history entries to ignore / screen and :q aliases |
| 23 | 24 |
# v1.5 - 2014-08-06: autocd set on / R alias added /bk function turned in a separate script / SSH environment setup moved in bash_profile |
| 24 | 25 |
# v1.4 - 2014-07-26: ssh_agent function for SSH key management added / ssh_agent called when used SSH connexion / wf alias updated |
| ... | ... |
@@ -355,8 +356,8 @@ function start_agent {
|
| 355 | 356 |
chmod 600 "${SSH_ENV}"
|
| 356 | 357 |
source "${SSH_ENV}" > /dev/null
|
| 357 | 358 |
|
| 358 |
- # SSH key add |
|
| 359 |
- ssh-add |
|
| 359 |
+ # SSH key add ($@: useful to add ssh-add options like lifetime directly through start_agent) |
|
| 360 |
+ ssh-add $@ |
|
| 360 | 361 |
} |
| 361 | 362 |
|
| 362 | 363 |
|
| ... | ... |
@@ -1,8 +1,8 @@ |
| 1 | 1 |
# Title: .bashrc |
| 2 | 2 |
# Author: Frédéric CHEVALIER <f15.chevalier@gmail.com> |
| 3 |
-# Version: 1.5 |
|
| 3 |
+# Version: 1.6 |
|
| 4 | 4 |
# Created in: 2012-05-26 |
| 5 |
-# Modified in: 2014-08-06 |
|
| 5 |
+# Modified in: 2014-08-16 |
|
| 6 | 6 |
|
| 7 | 7 |
|
| 8 | 8 |
|
| ... | ... |
@@ -19,7 +19,8 @@ |
| 19 | 19 |
# Versions # |
| 20 | 20 |
#==========# |
| 21 | 21 |
|
| 22 |
-# v1.5 - 2014-08-06: autocd set on / R alias added / bk function turned in a separate script / SSH environment setup moved in bash_profile |
|
| 22 |
+# v1.6 - 2014-08-16: new history entries to ignore / screen and :q aliases |
|
| 23 |
+# v1.5 - 2014-08-06: autocd set on / R alias added /bk function turned in a separate script / SSH environment setup moved in bash_profile |
|
| 23 | 24 |
# v1.4 - 2014-07-26: ssh_agent function for SSH key management added / ssh_agent called when used SSH connexion / wf alias updated |
| 24 | 25 |
# v1.3 - 2014-07-19: bug correction for PS1 (\[\e and \] missing for each color) / typo corrections |
| 25 | 26 |
# v1.2 - 2014-07-06: h and t aliases corrected / m alias added / quit function added / R env variables added |
| ... | ... |
@@ -58,7 +59,7 @@ export HISTCONTROL=ignoreboth |
| 58 | 59 |
|
| 59 | 60 |
# Ignore some controlling instructions |
| 60 | 61 |
# The '&' is a special pattern which suppresses duplicate entries. |
| 61 |
-export HISTIGNORE=$'[ \t]*:&:[fb]g:exit' |
|
| 62 |
+export HISTIGNORE=$'[ \t]*:&:[fb]g:exit:*q:screen*' |
|
| 62 | 63 |
# export HISTIGNORE=$'[ \t]*:&:[fb]g:exit:ls' # Ignore the ls command as well |
| 63 | 64 |
|
| 64 | 65 |
# Whenever displaying the prompt, write the previous line to disk |
| ... | ... |
@@ -205,7 +206,10 @@ alias h="head" |
| 205 | 206 |
alias t="tail" |
| 206 | 207 |
alias m="more" |
| 207 | 208 |
alias bye="exit" |
| 209 |
+alias :q="exit" |
|
| 208 | 210 |
alias R="R --no-save" |
| 211 |
+alias s="screen -D -RR" |
|
| 212 |
+alias ns="screen" |
|
| 209 | 213 |
|
| 210 | 214 |
|
| 211 | 215 |
# You may want to put all your additions into a separate file like |
| ... | ... |
@@ -1,8 +1,8 @@ |
| 1 | 1 |
# Title: .bashrc |
| 2 | 2 |
# Author: Frédéric CHEVALIER <f15.chevalier@gmail.com> |
| 3 |
-# Version: 1.4 |
|
| 3 |
+# Version: 1.5 |
|
| 4 | 4 |
# Created in: 2012-05-26 |
| 5 |
-# Modified in: 2014-07-26 |
|
| 5 |
+# Modified in: 2014-08-06 |
|
| 6 | 6 |
|
| 7 | 7 |
|
| 8 | 8 |
|
| ... | ... |
@@ -19,6 +19,7 @@ |
| 19 | 19 |
# Versions # |
| 20 | 20 |
#==========# |
| 21 | 21 |
|
| 22 |
+# v1.5 - 2014-08-06: autocd set on / R alias added / bk function turned in a separate script / SSH environment setup moved in bash_profile |
|
| 22 | 23 |
# v1.4 - 2014-07-26: ssh_agent function for SSH key management added / ssh_agent called when used SSH connexion / wf alias updated |
| 23 | 24 |
# v1.3 - 2014-07-19: bug correction for PS1 (\[\e and \] missing for each color) / typo corrections |
| 24 | 25 |
# v1.2 - 2014-07-06: h and t aliases corrected / m alias added / quit function added / R env variables added |
| ... | ... |
@@ -87,7 +88,7 @@ shopt -s checkwinsize |
| 87 | 88 |
shopt -s cdspell |
| 88 | 89 |
|
| 89 | 90 |
# Avoid cd usage |
| 90 |
-#shopt -s autocd |
|
| 91 |
+shopt -s autocd |
|
| 91 | 92 |
|
| 92 | 93 |
# Make less more friendly for non-text input files, see lesspipe(1) |
| 93 | 94 |
[[ -x /usr/bin/lesspipe ]] && eval "$(SHELL=/bin/sh lesspipe)" |
| ... | ... |
@@ -204,6 +205,7 @@ alias h="head" |
| 204 | 205 |
alias t="tail" |
| 205 | 206 |
alias m="more" |
| 206 | 207 |
alias bye="exit" |
| 208 |
+alias R="R --no-save" |
|
| 207 | 209 |
|
| 208 | 210 |
|
| 209 | 211 |
# You may want to put all your additions into a separate file like |
| ... | ... |
@@ -315,18 +317,6 @@ else |
| 315 | 317 |
fi |
| 316 | 318 |
|
| 317 | 319 |
|
| 318 |
-# Backup function |
|
| 319 |
-function bk {
|
|
| 320 |
- if [[ -f "$1" || -d "$1" ]] |
|
| 321 |
- then |
|
| 322 |
- mydate=$(date +%F) |
|
| 323 |
- cp -R "$1" "$1.bk_$mydate" |
|
| 324 |
- else |
|
| 325 |
- echo -e "$1 is not a file or a directory" |
|
| 326 |
- fi |
|
| 327 |
-} |
|
| 328 |
- |
|
| 329 |
- |
|
| 330 | 320 |
# Quit function |
| 331 | 321 |
function q {
|
| 332 | 322 |
read -a ans -p "Do you want to exit [Y/n]? " |
| ... | ... |
@@ -342,6 +332,8 @@ function q {
|
| 342 | 332 |
|
| 343 | 333 |
|
| 344 | 334 |
# SSH agent function |
| 335 |
+# Usage: function used to store SSH environment (SSH key in ssh-agent) |
|
| 336 |
+# See .bash_profile from servers for use |
|
| 345 | 337 |
function start_agent {
|
| 346 | 338 |
if [[ $LANG =~ ^fr ]] |
| 347 | 339 |
then |
| ... | ... |
@@ -392,17 +384,5 @@ export R_HISTSIZE=$HISTSIZE |
| 392 | 384 |
|
| 393 | 385 |
|
| 394 | 386 |
# SSH environment |
| 395 |
-SSH_ENV="$HOME/.ssh/ssh_agent_$HOSTNAME" |
|
| 387 |
+export SSH_ENV="$HOME/.ssh/ssh_agent_$HOSTNAME" |
|
| 396 | 388 |
|
| 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 |
|
| 409 | 389 |
\ No newline at end of file |
| ... | ... |
@@ -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 |
| ... | ... |
@@ -1,8 +1,8 @@ |
| 1 | 1 |
# Title: .bashrc |
| 2 | 2 |
# Author: Frédéric CHEVALIER <f15.chevalier@gmail.com> |
| 3 |
-# Version: 1.2 |
|
| 3 |
+# Version: 1.3 |
|
| 4 | 4 |
# Created in: 2012-05-26 |
| 5 |
-# Modified in: 2014-07-06 |
|
| 5 |
+# Modified in: 2014-07-19 |
|
| 6 | 6 |
|
| 7 | 7 |
|
| 8 | 8 |
|
| ... | ... |
@@ -19,6 +19,7 @@ |
| 19 | 19 |
# Versions # |
| 20 | 20 |
#==========# |
| 21 | 21 |
|
| 22 |
+# v1.3 - 2014-07-19: bug correction for PS1 (\[\e and \] missing for each color) / typo corrections |
|
| 22 | 23 |
# v1.2 - 2014-07-06: h and t aliases corrected / m alias added / quit function added / R env variables added |
| 23 | 24 |
# v1.1 - 2014-07-02: bug corrections in trash function and EDITOR set up / exit and diff aliases added |
| 24 | 25 |
# v1.0 - 2014-06-22: file reorganization / aliases added |
| ... | ... |
@@ -31,16 +32,16 @@ |
| 31 | 32 |
#=======================# |
| 32 | 33 |
|
| 33 | 34 |
# If not running interactively, don't do anything |
| 34 |
-[ -z "$PS1" ] && return |
|
| 35 |
+[[ -z "$PS1" ]] && return |
|
| 35 | 36 |
|
| 36 | 37 |
# Enable programmable completion features |
| 37 |
-if [ -f /etc/bash_completion ] && ! shopt -oq posix |
|
| 38 |
+if [[ -f /etc/bash_completion ]] && ! shopt -oq posix |
|
| 38 | 39 |
then |
| 39 | 40 |
. /etc/bash_completion |
| 40 | 41 |
fi |
| 41 | 42 |
|
| 42 | 43 |
# Set variable identifying the chroot you work in (used in the prompt below) |
| 43 |
-if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ] |
|
| 44 |
+if [[ -z "$debian_chroot" && -r /etc/debian_chroot ]] |
|
| 44 | 45 |
then |
| 45 | 46 |
debian_chroot=$(cat /etc/debian_chroot) |
| 46 | 47 |
fi |
| ... | ... |
@@ -88,7 +89,7 @@ shopt -s cdspell |
| 88 | 89 |
#shopt -s autocd |
| 89 | 90 |
|
| 90 | 91 |
# Make less more friendly for non-text input files, see lesspipe(1) |
| 91 |
-[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" |
|
| 92 |
+[[ -x /usr/bin/lesspipe ]] && eval "$(SHELL=/bin/sh lesspipe)" |
|
| 92 | 93 |
|
| 93 | 94 |
## Key binding |
| 94 | 95 |
#bind '"\e[1~": beginning-of-line' # home |
| ... | ... |
@@ -128,13 +129,13 @@ then |
| 128 | 129 |
fi |
| 129 | 130 |
fi |
| 130 | 131 |
|
| 131 |
-if [ "$color_prompt" = yes ] |
|
| 132 |
+if [[ "$color_prompt" == "yes" ]] |
|
| 132 | 133 |
then |
| 133 |
- if [ -n "$SSH_CONNECTION" ] |
|
| 134 |
+ if [[ -n "$SSH_CONNECTION" ]] |
|
| 134 | 135 |
then |
| 135 |
- PS1='\[\e[31m\][$(date +%H:%M) \u@\e[01;35m\h\e[00;36m:\[\e[33m\]\W\[\e[31m\]]\[\e[00m\]\$ ' |
|
| 136 |
+ PS1='\[\e[31m\][$(date +%H:%M) \u@\[\e[01;35m\]\h\[\e[00;31m\]:\[\e[33m\]\W\[\e[31m\]]\[\e[00m\]\$ ' |
|
| 136 | 137 |
else |
| 137 |
- PS1='\[\e[36m\][$(date +%H:%M) \u@\e[01;35m\h\e[00;36m:\[\e[33m\]\W\[\e[36m\]]\[\e[00m\]\$ ' |
|
| 138 |
+ PS1='\[\e[36m\][$(date +%H:%M) \u@\[\e[01;35m\]\h\[\e[00;36m\]:\[\e[33m\]\W\[\e[36m\]]\[\e[00m\]\$ ' |
|
| 138 | 139 |
fi |
| 139 | 140 |
else |
| 140 | 141 |
PS1='[$(date +%H:%M) \u@\h:\W]\$ ' |
| ... | ... |
@@ -146,7 +147,7 @@ PS1="${debian_chroot:+($debian_chroot)}$PS1"
|
| 146 | 147 |
|
| 147 | 148 |
|
| 148 | 149 |
# Enable colors for man pages (adapt colors as needed) |
| 149 |
-if [ "$color_prompt" = yes ] |
|
| 150 |
+if [[ "$color_prompt" == "yes" ]] |
|
| 150 | 151 |
then |
| 151 | 152 |
export LESS_TERMCAP_mb=$'\e[01;31m' # blink start |
| 152 | 153 |
export LESS_TERMCAP_md=$'\e[01;33m' # bold start (if white bg: $'\e[01;31m') |
| ... | ... |
@@ -161,7 +162,7 @@ unset color_prompt force_color_prompt |
| 161 | 162 |
|
| 162 | 163 |
|
| 163 | 164 |
# Enable color support of ls and grep and also add handy aliases |
| 164 |
-if [ -x /usr/bin/dircolors ] |
|
| 165 |
+if [[ -x /usr/bin/dircolors ]] |
|
| 165 | 166 |
then |
| 166 | 167 |
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" |
| 167 | 168 |
|
| ... | ... |
@@ -225,7 +226,7 @@ alias bye="exit" |
| 225 | 226 |
# ~/.bash_aliases, instead of adding them here directly. |
| 226 | 227 |
# See /usr/share/doc/bash-doc/examples in the bash-doc package. |
| 227 | 228 |
|
| 228 |
-if [ -f ~/.bash_aliases ] |
|
| 229 |
+if [[ -f ~/.bash_aliases ]] |
|
| 229 | 230 |
then |
| 230 | 231 |
. ~/.bash_aliases |
| 231 | 232 |
fi |
| ... | ... |
@@ -1,8 +1,8 @@ |
| 1 | 1 |
# Title: .bashrc |
| 2 | 2 |
# Author: Frédéric CHEVALIER <f15.chevalier@gmail.com> |
| 3 |
-# Version: 1.1 |
|
| 3 |
+# Version: 1.2 |
|
| 4 | 4 |
# Created in: 2012-05-26 |
| 5 |
-# Modified in: 2014-07-02 |
|
| 5 |
+# Modified in: 2014-07-06 |
|
| 6 | 6 |
|
| 7 | 7 |
|
| 8 | 8 |
|
| ... | ... |
@@ -10,9 +10,8 @@ |
| 10 | 10 |
# Comments # |
| 11 | 11 |
#==========# |
| 12 | 12 |
|
| 13 |
-# ~/.bashrc: executed by bash(1) for non-login shells. |
|
| 14 |
-# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) |
|
| 15 |
-# for examples |
|
| 13 |
+# ~/.bashrc: executed by bash(1) for non-login shells |
|
| 14 |
+# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) for examples |
|
| 16 | 15 |
|
| 17 | 16 |
|
| 18 | 17 |
|
| ... | ... |
@@ -20,6 +19,7 @@ |
| 20 | 19 |
# Versions # |
| 21 | 20 |
#==========# |
| 22 | 21 |
|
| 22 |
+# v1.2 - 2014-07-06: h and t aliases corrected / m alias added / quit function added / R env variables added |
|
| 23 | 23 |
# v1.1 - 2014-07-02: bug corrections in trash function and EDITOR set up / exit and diff aliases added |
| 24 | 24 |
# v1.0 - 2014-06-22: file reorganization / aliases added |
| 25 | 25 |
# v0.0 - 2012-05-26: creation |
| ... | ... |
@@ -215,8 +215,9 @@ alias du="du -h" |
| 215 | 215 |
# Misc short aliases |
| 216 | 216 |
alias c="cat" |
| 217 | 217 |
alias g="grep" |
| 218 |
-alias h="head -15" |
|
| 219 |
-alias t="tail -15" |
|
| 218 |
+alias h="head" |
|
| 219 |
+alias t="tail" |
|
| 220 |
+alias m="more" |
|
| 220 | 221 |
alias bye="exit" |
| 221 | 222 |
|
| 222 | 223 |
|
| ... | ... |
@@ -329,7 +330,6 @@ else |
| 329 | 330 |
fi |
| 330 | 331 |
|
| 331 | 332 |
|
| 332 |
- |
|
| 333 | 333 |
# Backup function |
| 334 | 334 |
function bk {
|
| 335 | 335 |
if [[ -f "$1" || -d "$1" ]] |
| ... | ... |
@@ -342,6 +342,20 @@ function bk {
|
| 342 | 342 |
} |
| 343 | 343 |
|
| 344 | 344 |
|
| 345 |
+# Quit function |
|
| 346 |
+function q {
|
|
| 347 |
+ read -a ans -p "Do you want to exit [Y/n]? " |
|
| 348 |
+ |
|
| 349 |
+ if [[ -z $ans ]] ; then ans=Y ; fi |
|
| 350 |
+ |
|
| 351 |
+ case $ans in |
|
| 352 |
+ Y|y|yes ) exit ;; |
|
| 353 |
+ N|n|no ) ;; |
|
| 354 |
+ * ) echo "Wrong choice" ;; |
|
| 355 |
+ esac |
|
| 356 |
+} |
|
| 357 |
+ |
|
| 358 |
+ |
|
| 345 | 359 |
|
| 346 | 360 |
#================================================# |
| 347 | 361 |
# User specific environment and startup programs # |
| ... | ... |
@@ -361,4 +375,9 @@ export PATH="$HOME/.local/bin:$PATH" |
| 361 | 375 |
|
| 362 | 376 |
|
| 363 | 377 |
# LaTeX environment |
| 364 |
-export TEXMFHOME=$HOME/.texmf |
|
| 378 |
+export TEXMFHOME="$HOME/.texmf" |
|
| 379 |
+ |
|
| 380 |
+ |
|
| 381 |
+# R environment |
|
| 382 |
+export R_HISTFILE="$HOME/.Rhistory" |
|
| 383 |
+export R_HISTSIZE=$HISTSIZE |
| ... | ... |
@@ -1,8 +1,8 @@ |
| 1 | 1 |
# Title: .bashrc |
| 2 | 2 |
# Author: Frédéric CHEVALIER <f15.chevalier@gmail.com> |
| 3 |
-# Version: 1.0 |
|
| 4 |
-# Created in: 2014-06-22 |
|
| 5 |
-# Modified in: |
|
| 3 |
+# Version: 1.1 |
|
| 4 |
+# Created in: 2012-05-26 |
|
| 5 |
+# Modified in: 2014-07-02 |
|
| 6 | 6 |
|
| 7 | 7 |
|
| 8 | 8 |
|
| ... | ... |
@@ -20,8 +20,9 @@ |
| 20 | 20 |
# Versions # |
| 21 | 21 |
#==========# |
| 22 | 22 |
|
| 23 |
-# v1.0: file reorganization / aliases added |
|
| 24 |
-# v0.0: creation |
|
| 23 |
+# v1.1 - 2014-07-02: bug corrections in trash function and EDITOR set up / exit and diff aliases added |
|
| 24 |
+# v1.0 - 2014-06-22: file reorganization / aliases added |
|
| 25 |
+# v0.0 - 2012-05-26: creation |
|
| 25 | 26 |
|
| 26 | 27 |
|
| 27 | 28 |
|
| ... | ... |
@@ -164,15 +165,15 @@ if [ -x /usr/bin/dircolors ] |
| 164 | 165 |
then |
| 165 | 166 |
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" |
| 166 | 167 |
|
| 167 |
- alias ls='ls --color=auto --group-directories-first -h -C' |
|
| 168 |
- alias dir='dir --color=auto' |
|
| 169 |
- alias vdir='vdir --color=auto' |
|
| 168 |
+ alias ls="ls --color=auto --group-directories-first -h -C" |
|
| 169 |
+ alias dir="dir --color=auto" |
|
| 170 |
+ alias vdir="vdir --color=auto" |
|
| 170 | 171 |
|
| 171 |
- alias grep='grep --color=auto' |
|
| 172 |
- alias fgrep='fgrep --color=auto' |
|
| 173 |
- alias egrep='egrep --color=auto' |
|
| 172 |
+ alias grep="grep --color=auto" |
|
| 173 |
+ alias fgrep="fgrep --color=auto" |
|
| 174 |
+ alias egrep="egrep --color=auto" |
|
| 174 | 175 |
|
| 175 |
- alias tree='tree -C' |
|
| 176 |
+ alias tree="tree -C" |
|
| 176 | 177 |
fi |
| 177 | 178 |
|
| 178 | 179 |
|
| ... | ... |
@@ -181,30 +182,32 @@ fi |
| 181 | 182 |
# User specific aliases # |
| 182 | 183 |
#=======================# |
| 183 | 184 |
|
| 185 |
+# Moving in directories |
|
| 186 |
+alias ..="cd .." |
|
| 187 |
+alias ....="cd ../.." |
|
| 188 |
+ |
|
| 184 | 189 |
# Listing files |
| 185 | 190 |
alias l="ls" |
| 186 |
-alias ll="ls -l" |
|
| 191 |
+alias ll="l -l" |
|
| 187 | 192 |
alias lr="l --recursive" |
| 188 | 193 |
alias llr="ll --recursive" |
| 189 | 194 |
alias la="ls -A" |
| 190 | 195 |
alias lla="la -l" |
| 191 | 196 |
|
| 192 |
-# Moving in directories |
|
| 193 |
-alias ..='cd ..' |
|
| 194 |
-alias ....='cd ../..' |
|
| 197 |
+# File manipulations |
|
| 198 |
+alias diff="diff -y --suppress-common-lines" |
|
| 195 | 199 |
|
| 196 | 200 |
# Internet |
| 197 | 201 |
alias dl="wget -c" |
| 198 |
-alias scp='scp -pr' |
|
| 199 |
-alias ssh='ssh -Y' |
|
| 200 |
-alias wf='ssh wf@vaderf.com' |
|
| 201 |
-alias wf2='ssh wf2@192.168.1.65' |
|
| 202 |
-alias fwf='ssh fred@vaderf.com' |
|
| 203 |
-alias heron='ssh fcheval@heron.txbiomedgenetics.org' |
|
| 202 |
+alias scp="scp -pr" |
|
| 203 |
+alias ssh="ssh -Y" |
|
| 204 |
+alias wf="ssh wf@vaderf.com" |
|
| 205 |
+alias fwf="ssh fred@vaderf.com" |
|
| 206 |
+alias heron="ssh fcheval@heron.txbiomedgenetics.org" |
|
| 204 | 207 |
|
| 205 | 208 |
# Disk space |
| 206 |
-alias df='df -h' |
|
| 207 |
-alias du='du -h' |
|
| 209 |
+alias df="df -h" |
|
| 210 |
+alias du="du -h" |
|
| 208 | 211 |
|
| 209 | 212 |
# Safety aliases |
| 210 | 213 |
#alias rm="rm --interactive" |
| ... | ... |
@@ -214,6 +217,7 @@ alias c="cat" |
| 214 | 217 |
alias g="grep" |
| 215 | 218 |
alias h="head -15" |
| 216 | 219 |
alias t="tail -15" |
| 220 |
+alias bye="exit" |
|
| 217 | 221 |
|
| 218 | 222 |
|
| 219 | 223 |
# You may want to put all your additions into a separate file like |
| ... | ... |
@@ -311,20 +315,19 @@ function extract {
|
| 311 | 315 |
|
| 312 | 316 |
|
| 313 | 317 |
# Trash function |
| 314 |
-function trash {
|
|
| 315 |
- # Check if trash-cli is installed otherwize check for already existing .trash |
|
| 316 |
- if [[ $(which trash-put) ]] |
|
| 318 |
+# Check if trash-cli is installed otherwize check for already existing .trash |
|
| 319 |
+if [[ $(which trash-put &> /dev/null ; echo $?) == 0 ]] |
|
| 320 |
+then |
|
| 321 |
+ alias trash='trash-put' |
|
| 322 |
+else |
|
| 323 |
+ if [[ -d $HOME/.trash/ ]] |
|
| 317 | 324 |
then |
| 318 |
- alias trash='trash-put' |
|
| 325 |
+ alias trash='mv $1 -t $HOME/.trash/' |
|
| 319 | 326 |
else |
| 320 |
- if [[ -d $HOME/.trash/ ]] |
|
| 321 |
- then |
|
| 322 |
- alias trash='mv $1 -t $HOME/.trash/' |
|
| 323 |
- else |
|
| 324 |
- echo -e "\n\tNo trash set up: trash-cli not installed or $HOME/.trash/ does not exist.\n" |
|
| 325 |
- fi |
|
| 327 |
+ echo -e "\n\tNo trash set up: trash-cli not installed or $HOME/.trash/ does not exist.\n" |
|
| 326 | 328 |
fi |
| 327 |
-} |
|
| 329 |
+fi |
|
| 330 |
+ |
|
| 328 | 331 |
|
| 329 | 332 |
|
| 330 | 333 |
# Backup function |
| ... | ... |
@@ -345,7 +348,7 @@ function bk {
|
| 345 | 348 |
#================================================# |
| 346 | 349 |
|
| 347 | 350 |
# Editor |
| 348 |
-if [[ $(which vim) ]] |
|
| 351 |
+if [[ $(which vim &> /dev/null ; echo $?) == 0 ]] |
|
| 349 | 352 |
then |
| 350 | 353 |
export EDITOR="vim" |
| 351 | 354 |
else |
| ... | ... |
@@ -358,4 +361,4 @@ export PATH="$HOME/.local/bin:$PATH" |
| 358 | 361 |
|
| 359 | 362 |
|
| 360 | 363 |
# LaTeX environment |
| 361 |
-export TEXMFHOME=$HOME/.texmf |
|
| 362 | 364 |
\ No newline at end of file |
| 365 |
+export TEXMFHOME=$HOME/.texmf |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,361 @@ |
| 1 |
+# Title: .bashrc |
|
| 2 |
+# Author: Frédéric CHEVALIER <f15.chevalier@gmail.com> |
|
| 3 |
+# Version: 1.0 |
|
| 4 |
+# Created in: 2014-06-22 |
|
| 5 |
+# Modified in: |
|
| 6 |
+ |
|
| 7 |
+ |
|
| 8 |
+ |
|
| 9 |
+#==========# |
|
| 10 |
+# Comments # |
|
| 11 |
+#==========# |
|
| 12 |
+ |
|
| 13 |
+# ~/.bashrc: executed by bash(1) for non-login shells. |
|
| 14 |
+# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) |
|
| 15 |
+# for examples |
|
| 16 |
+ |
|
| 17 |
+ |
|
| 18 |
+ |
|
| 19 |
+#==========# |
|
| 20 |
+# Versions # |
|
| 21 |
+#==========# |
|
| 22 |
+ |
|
| 23 |
+# v1.0: file reorganization / aliases added |
|
| 24 |
+# v0.0: creation |
|
| 25 |
+ |
|
| 26 |
+ |
|
| 27 |
+ |
|
| 28 |
+#=======================# |
|
| 29 |
+# User specific options # |
|
| 30 |
+#=======================# |
|
| 31 |
+ |
|
| 32 |
+# If not running interactively, don't do anything |
|
| 33 |
+[ -z "$PS1" ] && return |
|
| 34 |
+ |
|
| 35 |
+# Enable programmable completion features |
|
| 36 |
+if [ -f /etc/bash_completion ] && ! shopt -oq posix |
|
| 37 |
+then |
|
| 38 |
+ . /etc/bash_completion |
|
| 39 |
+fi |
|
| 40 |
+ |
|
| 41 |
+# Set variable identifying the chroot you work in (used in the prompt below) |
|
| 42 |
+if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ] |
|
| 43 |
+then |
|
| 44 |
+ debian_chroot=$(cat /etc/debian_chroot) |
|
| 45 |
+fi |
|
| 46 |
+ |
|
| 47 |
+ |
|
| 48 |
+#-----------------# |
|
| 49 |
+# History options # |
|
| 50 |
+#-----------------# |
|
| 51 |
+ |
|
| 52 |
+# Ignore duplicates and spaces |
|
| 53 |
+export HISTCONTROL=ignoreboth |
|
| 54 |
+ |
|
| 55 |
+# Ignore some controlling instructions |
|
| 56 |
+# The '&' is a special pattern which suppresses duplicate entries. |
|
| 57 |
+export HISTIGNORE=$'[ \t]*:&:[fb]g:exit' |
|
| 58 |
+# export HISTIGNORE=$'[ \t]*:&:[fb]g:exit:ls' # Ignore the ls command as well |
|
| 59 |
+ |
|
| 60 |
+# Whenever displaying the prompt, write the previous line to disk |
|
| 61 |
+#export PROMPT_COMMAND="history -a" |
|
| 62 |
+ |
|
| 63 |
+# Maximum command retain in the .bash_history file |
|
| 64 |
+export HISTSIZE=2000 |
|
| 65 |
+ |
|
| 66 |
+# Add timestamps for each command |
|
| 67 |
+export HISTTIMEFORMAT="$(echo -e '\e[0;32m')[ %d/%m/%Y %H:%M:%S ] $(echo -e '\e[0m') " |
|
| 68 |
+ |
|
| 69 |
+# Append to the history file, don't overwrite it |
|
| 70 |
+shopt -s histappend |
|
| 71 |
+ |
|
| 72 |
+# Allow edition of history command |
|
| 73 |
+shopt -s histverify |
|
| 74 |
+ |
|
| 75 |
+ |
|
| 76 |
+#---------------# |
|
| 77 |
+# Shell options # |
|
| 78 |
+#---------------# |
|
| 79 |
+ |
|
| 80 |
+# Adjust each LINES and COLUMNS after each command |
|
| 81 |
+shopt -s checkwinsize |
|
| 82 |
+ |
|
| 83 |
+# Manage typing error |
|
| 84 |
+shopt -s cdspell |
|
| 85 |
+ |
|
| 86 |
+# Avoid cd usage |
|
| 87 |
+#shopt -s autocd |
|
| 88 |
+ |
|
| 89 |
+# Make less more friendly for non-text input files, see lesspipe(1) |
|
| 90 |
+[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" |
|
| 91 |
+ |
|
| 92 |
+## Key binding |
|
| 93 |
+#bind '"\e[1~": beginning-of-line' # home |
|
| 94 |
+#bind '"\e[2~": overwrite-mode' # insert |
|
| 95 |
+#bind '"\e[3~": delete-char' # del |
|
| 96 |
+#bind '"\e[4~": end-of-line' # end |
|
| 97 |
+#bind '"\e[5~": history-search-backward' # page up |
|
| 98 |
+#bind '"\e[6~": history-search-forward' # page down |
|
| 99 |
+#bind '"\e[A": up-line-or-history' # arrow up |
|
| 100 |
+#bind '"\e[B": down-line-or-history' # arrow down |
|
| 101 |
+#bind '"\e[C": forward-char' # arrow right |
|
| 102 |
+#bind '"\e[D": backward-char' # arrow left |
|
| 103 |
+ |
|
| 104 |
+#bind '"\e[H": beginning-of-line' # home (xterm) |
|
| 105 |
+#bind '"\e[F": end-of-line' # end (xterm) |
|
| 106 |
+ |
|
| 107 |
+#bind '"^R": history-incremental-search-backward' |
|
| 108 |
+ |
|
| 109 |
+ |
|
| 110 |
+#---------------# |
|
| 111 |
+# Color options # |
|
| 112 |
+#---------------# |
|
| 113 |
+ |
|
| 114 |
+# Set a fancy prompt (non-color, unless we know we "want" color) |
|
| 115 |
+force_color_prompt=yes |
|
| 116 |
+ |
|
| 117 |
+if [ -n "$force_color_prompt" ] |
|
| 118 |
+then |
|
| 119 |
+ if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null |
|
| 120 |
+ then |
|
| 121 |
+ # We have color support; assume it's compliant with Ecma-48 |
|
| 122 |
+ # (ISO/IEC-6429). (Lack of such support is extremely rare, and such |
|
| 123 |
+ # a case would tend to support setf rather than setaf.) |
|
| 124 |
+ color_prompt=yes |
|
| 125 |
+ else |
|
| 126 |
+ color_prompt= |
|
| 127 |
+ fi |
|
| 128 |
+fi |
|
| 129 |
+ |
|
| 130 |
+if [ "$color_prompt" = yes ] |
|
| 131 |
+then |
|
| 132 |
+ if [ -n "$SSH_CONNECTION" ] |
|
| 133 |
+ then |
|
| 134 |
+ PS1='\[\e[31m\][$(date +%H:%M) \u@\e[01;35m\h\e[00;36m:\[\e[33m\]\W\[\e[31m\]]\[\e[00m\]\$ ' |
|
| 135 |
+ else |
|
| 136 |
+ PS1='\[\e[36m\][$(date +%H:%M) \u@\e[01;35m\h\e[00;36m:\[\e[33m\]\W\[\e[36m\]]\[\e[00m\]\$ ' |
|
| 137 |
+ fi |
|
| 138 |
+else |
|
| 139 |
+ PS1='[$(date +%H:%M) \u@\h:\W]\$ ' |
|
| 140 |
+fi |
|
| 141 |
+ |
|
| 142 |
+ |
|
| 143 |
+# Add chroot if present |
|
| 144 |
+PS1="${debian_chroot:+($debian_chroot)}$PS1"
|
|
| 145 |
+ |
|
| 146 |
+ |
|
| 147 |
+# Enable colors for man pages (adapt colors as needed) |
|
| 148 |
+if [ "$color_prompt" = yes ] |
|
| 149 |
+then |
|
| 150 |
+ export LESS_TERMCAP_mb=$'\e[01;31m' # blink start |
|
| 151 |
+ export LESS_TERMCAP_md=$'\e[01;33m' # bold start (if white bg: $'\e[01;31m') |
|
| 152 |
+ export LESS_TERMCAP_me=$'\e[0m' # end |
|
| 153 |
+ export LESS_TERMCAP_se=$'\e[0m' # end |
|
| 154 |
+ export LESS_TERMCAP_so=$'\e[01;44;33m' # status line start |
|
| 155 |
+ export LESS_TERMCAP_ue=$'\e[0m' # end |
|
| 156 |
+ export LESS_TERMCAP_us=$'\e[01;35m' # underlined start (if white bg: $'\e[01;32m') |
|
| 157 |
+fi |
|
| 158 |
+ |
|
| 159 |
+unset color_prompt force_color_prompt |
|
| 160 |
+ |
|
| 161 |
+ |
|
| 162 |
+# Enable color support of ls and grep and also add handy aliases |
|
| 163 |
+if [ -x /usr/bin/dircolors ] |
|
| 164 |
+then |
|
| 165 |
+ test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" |
|
| 166 |
+ |
|
| 167 |
+ alias ls='ls --color=auto --group-directories-first -h -C' |
|
| 168 |
+ alias dir='dir --color=auto' |
|
| 169 |
+ alias vdir='vdir --color=auto' |
|
| 170 |
+ |
|
| 171 |
+ alias grep='grep --color=auto' |
|
| 172 |
+ alias fgrep='fgrep --color=auto' |
|
| 173 |
+ alias egrep='egrep --color=auto' |
|
| 174 |
+ |
|
| 175 |
+ alias tree='tree -C' |
|
| 176 |
+fi |
|
| 177 |
+ |
|
| 178 |
+ |
|
| 179 |
+ |
|
| 180 |
+#=======================# |
|
| 181 |
+# User specific aliases # |
|
| 182 |
+#=======================# |
|
| 183 |
+ |
|
| 184 |
+# Listing files |
|
| 185 |
+alias l="ls" |
|
| 186 |
+alias ll="ls -l" |
|
| 187 |
+alias lr="l --recursive" |
|
| 188 |
+alias llr="ll --recursive" |
|
| 189 |
+alias la="ls -A" |
|
| 190 |
+alias lla="la -l" |
|
| 191 |
+ |
|
| 192 |
+# Moving in directories |
|
| 193 |
+alias ..='cd ..' |
|
| 194 |
+alias ....='cd ../..' |
|
| 195 |
+ |
|
| 196 |
+# Internet |
|
| 197 |
+alias dl="wget -c" |
|
| 198 |
+alias scp='scp -pr' |
|
| 199 |
+alias ssh='ssh -Y' |
|
| 200 |
+alias wf='ssh wf@vaderf.com' |
|
| 201 |
+alias wf2='ssh wf2@192.168.1.65' |
|
| 202 |
+alias fwf='ssh fred@vaderf.com' |
|
| 203 |
+alias heron='ssh fcheval@heron.txbiomedgenetics.org' |
|
| 204 |
+ |
|
| 205 |
+# Disk space |
|
| 206 |
+alias df='df -h' |
|
| 207 |
+alias du='du -h' |
|
| 208 |
+ |
|
| 209 |
+# Safety aliases |
|
| 210 |
+#alias rm="rm --interactive" |
|
| 211 |
+ |
|
| 212 |
+# Misc short aliases |
|
| 213 |
+alias c="cat" |
|
| 214 |
+alias g="grep" |
|
| 215 |
+alias h="head -15" |
|
| 216 |
+alias t="tail -15" |
|
| 217 |
+ |
|
| 218 |
+ |
|
| 219 |
+# You may want to put all your additions into a separate file like |
|
| 220 |
+# ~/.bash_aliases, instead of adding them here directly. |
|
| 221 |
+# See /usr/share/doc/bash-doc/examples in the bash-doc package. |
|
| 222 |
+ |
|
| 223 |
+if [ -f ~/.bash_aliases ] |
|
| 224 |
+then |
|
| 225 |
+ . ~/.bash_aliases |
|
| 226 |
+fi |
|
| 227 |
+ |
|
| 228 |
+ |
|
| 229 |
+#=========================# |
|
| 230 |
+# User specific functions # |
|
| 231 |
+#=========================# |
|
| 232 |
+ |
|
| 233 |
+# cd improvment function |
|
| 234 |
+# This function defines a 'cd' replacement function capable of keeping, |
|
| 235 |
+# displaying and accessing history of visited directories, up to 10 entries. |
|
| 236 |
+# To use it, try 'cd --'. |
|
| 237 |
+# acd_func 1.0.5, 10-nov-2004 |
|
| 238 |
+# Petar Marinov, http:/geocities.com/h2428, this is public domain |
|
| 239 |
+function cd_func {
|
|
| 240 |
+ local x2 the_new_dir adir index |
|
| 241 |
+ local -i cnt |
|
| 242 |
+ |
|
| 243 |
+ if [[ $1 == "--" ]] |
|
| 244 |
+ then |
|
| 245 |
+ dirs -v |
|
| 246 |
+ return 0 |
|
| 247 |
+ fi |
|
| 248 |
+ |
|
| 249 |
+ the_new_dir=$1 |
|
| 250 |
+ [[ -z $1 ]] && the_new_dir=$HOME |
|
| 251 |
+ |
|
| 252 |
+ if [[ ${the_new_dir:0:1} == '-' ]]
|
|
| 253 |
+ then |
|
| 254 |
+ # Extract dir N from dirs |
|
| 255 |
+ index=${the_new_dir:1}
|
|
| 256 |
+ [[ -z $index ]] && index=1 |
|
| 257 |
+ adir=$(dirs +$index) |
|
| 258 |
+ [[ -z $adir ]] && return 1 |
|
| 259 |
+ the_new_dir=$adir |
|
| 260 |
+ fi |
|
| 261 |
+ |
|
| 262 |
+ # '~' has to be substituted by ${HOME}
|
|
| 263 |
+ [[ ${the_new_dir:0:1} == '~' ]] && the_new_dir="${HOME}${the_new_dir:1}"
|
|
| 264 |
+ |
|
| 265 |
+ # Now change to the new dir and add to the top of the stack |
|
| 266 |
+ pushd "${the_new_dir}" > /dev/null
|
|
| 267 |
+ [[ $? -ne 0 ]] && return 1 |
|
| 268 |
+ the_new_dir=$(pwd) |
|
| 269 |
+ |
|
| 270 |
+ # Trim down everything beyond 11th entry |
|
| 271 |
+ popd -n +11 2>/dev/null 1>/dev/null |
|
| 272 |
+ |
|
| 273 |
+ # Remove any other occurence of this dir, skipping the top of the stack |
|
| 274 |
+ for ((cnt=1; cnt <= 10; cnt++)) |
|
| 275 |
+ do |
|
| 276 |
+ x2=$(dirs +${cnt} 2>/dev/null)
|
|
| 277 |
+ [[ $? -ne 0 ]] && return 0 |
|
| 278 |
+ [[ ${x2:0:1} == '~' ]] && x2="${HOME}${x2:1}"
|
|
| 279 |
+ if [[ "${x2}" == "${the_new_dir}" ]]
|
|
| 280 |
+ then |
|
| 281 |
+ popd -n +$cnt 2>/dev/null 1>/dev/null |
|
| 282 |
+ cnt=cnt-1 |
|
| 283 |
+ fi |
|
| 284 |
+ done |
|
| 285 |
+ |
|
| 286 |
+ return 0 |
|
| 287 |
+} |
|
| 288 |
+ |
|
| 289 |
+alias cd=cd_func |
|
| 290 |
+ |
|
| 291 |
+ |
|
| 292 |
+# Extract function |
|
| 293 |
+function extract {
|
|
| 294 |
+ if [[ -f $1 ]] |
|
| 295 |
+ then |
|
| 296 |
+ case $1 in |
|
| 297 |
+ *.tar.bz2 | *.tbz2 ) tar xvjf $1 ;; |
|
| 298 |
+ *.tar.gz | *.tgz ) tar xvzf $1 ;; |
|
| 299 |
+ *.tar ) tar xvf $1 ;; |
|
| 300 |
+ *.gz ) gunzip $1 ;; |
|
| 301 |
+ *.bz2 ) bunzip2 $1 ;; |
|
| 302 |
+ *.rar ) rar x $1 ;; |
|
| 303 |
+ *.zip | *.7z ) unzip $1 ;; |
|
| 304 |
+ *.Z ) uncompress $1 ;; |
|
| 305 |
+ * ) echo "don't know how to extract '$1'..." ;; |
|
| 306 |
+ esac |
|
| 307 |
+ else |
|
| 308 |
+ echo "'$1' is not a valid file!" |
|
| 309 |
+ fi |
|
| 310 |
+} |
|
| 311 |
+ |
|
| 312 |
+ |
|
| 313 |
+# Trash function |
|
| 314 |
+function trash {
|
|
| 315 |
+ # Check if trash-cli is installed otherwize check for already existing .trash |
|
| 316 |
+ if [[ $(which trash-put) ]] |
|
| 317 |
+ then |
|
| 318 |
+ alias trash='trash-put' |
|
| 319 |
+ else |
|
| 320 |
+ if [[ -d $HOME/.trash/ ]] |
|
| 321 |
+ then |
|
| 322 |
+ alias trash='mv $1 -t $HOME/.trash/' |
|
| 323 |
+ else |
|
| 324 |
+ echo -e "\n\tNo trash set up: trash-cli not installed or $HOME/.trash/ does not exist.\n" |
|
| 325 |
+ fi |
|
| 326 |
+ fi |
|
| 327 |
+} |
|
| 328 |
+ |
|
| 329 |
+ |
|
| 330 |
+# Backup function |
|
| 331 |
+function bk {
|
|
| 332 |
+ if [[ -f "$1" || -d "$1" ]] |
|
| 333 |
+ then |
|
| 334 |
+ mydate=$(date +%F) |
|
| 335 |
+ cp -R "$1" "$1.bk_$mydate" |
|
| 336 |
+ else |
|
| 337 |
+ echo -e "$1 is not a file or a directory" |
|
| 338 |
+ fi |
|
| 339 |
+} |
|
| 340 |
+ |
|
| 341 |
+ |
|
| 342 |
+ |
|
| 343 |
+#================================================# |
|
| 344 |
+# User specific environment and startup programs # |
|
| 345 |
+#================================================# |
|
| 346 |
+ |
|
| 347 |
+# Editor |
|
| 348 |
+if [[ $(which vim) ]] |
|
| 349 |
+then |
|
| 350 |
+ export EDITOR="vim" |
|
| 351 |
+else |
|
| 352 |
+ export EDITOR="nano" |
|
| 353 |
+fi |
|
| 354 |
+ |
|
| 355 |
+ |
|
| 356 |
+# Personalized PATH |
|
| 357 |
+export PATH="$HOME/.local/bin:$PATH" |
|
| 358 |
+ |
|
| 359 |
+ |
|
| 360 |
+# LaTeX environment |
|
| 361 |
+export TEXMFHOME=$HOME/.texmf |
|
| 0 | 362 |
\ No newline at end of file |