Created
August 1, 2013 19:50
-
-
Save jpatovh/6134613 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Alias, coloration syntaxique, et fonctions supplémentaires. | |
USER='toto' | |
HOST='toto-linux' | |
export EDITOR='nano' | |
# Couleurs pour le prompt. | |
DEFAULT="\[\033[00m\]" | |
BLACK="\[\033[30m\]" | |
RED="\[\033[31m\]" | |
GREEN="\[\033[32m\]" | |
ORANGE="\[\033[33m\]" | |
BLUE="\[\033[34m\]" | |
MAGENTA="\[\033[35m\]" | |
CYAN="\[\033[36m\]" | |
WHITE="\[\033[37m\]" | |
## Exemples de prompts. | |
#PS1='\d | \h | \u \n\t | \T | \@ \n\w | \W | \# | \n\$ ' | |
#PS1="${DEFAULT}DEFAULT ${BLACK}BLACK ${RED}RED ${GREEN}GREEN ${ORANGE}ORANGE ${BLUE}BLUE ${MAGENTA}MAGENTA ${CYAN}CYAN ${WHITE}WHITE" | |
#PS1="$GREEN[$BLUE\u$GREEN:$MAGENTA\w$GREEN]\$ $DEFAULT" | |
#PS1="$GREEN[$BLUE\u@\h$GREEN][$MAGENTA\w$GREEN]$RED\$ $DEFAULT" | |
#PS1="$GREEN[$BLUE\u@\h$DEFAULT:$MAGENTA\W$GREEN]$ORANGE\$ $DEFAULT" | |
# Affichage d'un prompt différent si local ou distant. | |
if [ `whoami` = $USER ] && [ `hostname` = $HOST ]; then | |
PS1="$BLACK[$BLUE\w$BLACK]$RED\$ $DEFAULT" | |
else | |
PS1="$BLACK[$GREEN\u@\h$BLACK]$BLACK[$BLUE\w$BLACK]$RED\$ $DEFAULT" | |
fi | |
# Navigation simplifiée. | |
alias ..='cd ..' | |
alias ...='cd ../../' | |
alias ....='cd ../../../' | |
alias .4='cd ../../../../' | |
alias .5='cd ../../../../../' | |
alias .6='cd ../../../../../../' | |
alias .7='cd ../../../../../../../' | |
alias .8='cd ../../../../../../../../' | |
# FU 'command not found' ! | |
alias cd..='cd ..' | |
alias cd...='cd ../../' | |
alias cd....='cd ../../../' | |
alias vi='$EDITOR' | |
alias ll='ls -F -a -l -h' | |
alias ls='ls -F -a -C --color=auto' | |
alias md='mkdir -p -v' | |
alias cp='cp -v -i' | |
alias df='df -h -T' | |
alias du='du -h' | |
alias find='find -L' | |
alias mv='mv -v -i' | |
alias rm='rm -v' | |
alias dir='dir --color=auto' | |
alias egrep='egrep --color=auto' | |
alias fgrep='fgrep --color=auto' | |
alias grep='grep --color=auto' | |
alias inpkg='sudo apt-get install' | |
alias rmpkg='sudo apt-get autoremove --purge' | |
# Extraire facilement les fichiers compressés. | |
extract() { | |
if [ -f $1 ] | |
then | |
case $1 in | |
(*.7z) 7z x $1 ;; | |
(*.lzma) unlzma $1 ;; | |
(*.rar) unrar x $1 ;; | |
(*.tar) tar xvf $1 ;; | |
(*.tar.bz2) tar xvjf $1 ;; | |
(*.bz2) bunzip2 $1 ;; | |
(*.tar.gz) tar xvzf $1 ;; | |
(*.gz) gunzip $1 ;; | |
(*.tar.xz) tar Jxvf $1 ;; | |
(*.xz) xz -d $1 ;; | |
(*.tbz2) tar xvjf $1 ;; | |
(*.tgz) tar xvzf $1 ;; | |
(*.zip) unzip $1 ;; | |
(*.Z) uncompress ;; | |
(*) echo "Don't know how to extract '$1'..." ;; | |
esac | |
else | |
echo "Error: '$1' is not a valid file!" | |
fi | |
} | |
# Update du système. | |
update() { | |
echo -e 'Suppresion des fichiers de sauvegarde inutiles (/home)...' | |
sudo find /home -name "*~" -delete | |
echo -e 'Mise à jour de la base de données...' | |
sudo updatedb | |
echo -e 'Mise à jour des paquets...' | |
sudo dpkg --configure -a | |
sudo apt-get install -f | |
sudo apt-get check -qq | |
sudo apt-get update -qq | |
sudo apt-get upgrade | |
sudo apt-get autoremove --purge | |
sudo apt-get clean -qq | |
sudo apt-get autoclean -qq | |
} | |
# Fonction simple de recherche. | |
search() { | |
for i in "$@" | |
do | |
find -iname "*$i*" | grep -i $i | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment