This siteAll blogsLe 17ClémentCCBCuisineLe 3ContactSe connecterS'inscrire
  • All blogs
  • Le 17
  • Clément
  • CCB
  • Cuisine
  • Le 3
  • Contact

  • S'inscrire

Recettes informatiques

  • Page de garde
  • Contact
  • Se connecter
  • « Extraire des commentaires d'un fichier C/C++
  • Convertiseur Fig -> LaTeX -> EPS »

Fichier de ressource Bash

Posted by mazet on 17 Nov 2009 in Programmation, Bash

Fichier de resource .bashrc redefinissant rm (deplacement vers ~/.wastebasket)

Shell

# -*- sh -*-
#
 
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
 
# User preferences
 
export NAME="Laurent Mazet"
export EMAIL="$NAME <${NAME// /.}@ercom.fr>"
export REPLYTO=$EMAIL
export SIGNATURE=".signature"
export ORGANIZATION="Ercom"
export HOME=${HOME//\.\/}
 
# Don't put duplicate lines in the history.
export HISTCONTROL=ignoredups
 
# Check the window size after each command and, if necessary,
# Update the values of LINES and COLUMNS.
shopt -s checkwinsize
 
# Make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
 
# Enable color support of ls and also add handy aliases
if [ "$TERM" != "dumb" ]; then
    eval `dircolors -b`
    alias ls='\ls -CF --color=auto'
else
    alias ls='\ls -CF'
fi
 
# some more ls aliases
alias ll='ls -l'
alias la='ls -a'
alias l='ls -CAF'
 
# miscellaneous aliases
alias cls='clear'
alias dir='ls --format=vertical'
alias del='\rm -i'
alias deldir='\rm -r'
alias grep='\grep --color'
alias g='grep'
alias copy='cp'
alias ren='mv'
 
# set a fancy prompt
case $TERM in
xterm*|rxvt*) PS1='\[\033[01;34m\]\u\[\033[00m\]@\[\033[01;33m\]\h\[\033[00m\]:\[\033[01;32m\]\w\[\033[00m\] \$ ';;
*) PS1='\u@\h:\w \$ ' ;;
esac
 
# 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
 
# Environment variables
export BLOCKSIZE=1k
export EDITOR=vim
export GZIP=--best
export LESS=FMISRX
export MACHINE="`uname -rs`"
export PAGER=less
[ -d $HOME/bin ] && [[ ! $PATH =~ $HOME/bin ]] && \
    export PATH=$HOME/bin:$PATH
#export TOP=-s1
export VISUAL=vim
 
# Malloc checker
#export MALLOC_CHECK_=2
 
# Core size
ulimit -c unlimited
 
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
 
fi
## libcurl options
[ -f $HOME/.libcurlrc ] && source $HOME/.libcurlrc
 
# delete & undelete commands
function garbageinit () {
    if [ ! -d $HOME/.wastebasket ]; then
        echo "Create $HOME/.wastebasket"
        [ -e $HOME/.wastebasket ] || $(which rm) -f $HOME/.wastebasket
        mkdir $HOME/.wastebasket
    fi
}
    
function rm () {
    rm=$(which rm)
    mv=$(which mv)
 
    if [ $# -eq 0 ]; then
        echo "rm/undelete functions"
        echo "Usage: rm <file1> ..."
        return 1
    fi
 
    while [ $# -gt 0 ]; do
        if [ -e "$1" ] || [ -L "$1" ]; then
            bn=$HOME/.wastebasket/$(basename "$1")
            [ -e "$bn" ] || [ -L "$1" ]&& \
                $rm -rf "$HOME/.wastebasket/$bn"
            $mv -f "$1" $HOME/.wastebasket/
        else
            echo "rm: No such file or directory '$1'"
        fi
        shift
    done
}
 
function undelete () {
    mv=$(which mv)
 
    if [ $# -eq 0 ]; then
        echo "rm/undelete functions"
        echo "Usage: undelete <file1> ..."
        return 1
    fi
 
    while [ $# -gt 0 ]; do
        n="$HOME/.wastebasket/$1"
        if [ -e "$n" ] || [ -L "$n" ]; then
            bn=$(basename "$1")
            if [ -e "./$bn" ] || [ -L "./$bn" ]; then
                $mv -f "./$bn" "$n.undelete"
                $mv -f "$n" "./$bn"
                $mv -f "$n.undelete" "$n"
            else
                $mv -f "$n" "./$bn"
            fi
        else
            echo "undelete: No such file or directory '$1'"
        fi
        shift
    done
}
 
function garbageclean () {
    $(which rm) -rf $HOME/.wastebasket
    garbageinit >&/dev/null
}
 
function garbagelist () {
    ls=$(which ls)
 
    nf=$($ls -1A $HOME/.wastebasket/ | wc -w)
    echo "List of file(s) in garbage: $nf file(s) "
 
    $ls -CFA $HOME/.wastebasket | sed -e /total/d
 
    gf=$(du -s $HOME/.wastebasket | awk '{ print $1 }' )
    echo "Garbage filled: $((gf - 1)) Ko"
}
 
# startup commands
garbageinit
 
# todo commands
TODO_OPTS="--summary"
 
if [ -e "$(which devtodo)" ]; then
 
    function cd () {
        builtin cd "$@" && [ -f .todo ] && devtodo ${TODO_OPTS}
    }
 
    function pushd () {
        builtin pushd "$@" && [ -f .todo ] && devtodo ${TODO_OPTS}
    }
 
    function popd () {
        builtin popd && [ -f .todo ] && devtodo ${TODO_OPTS}
    }
 
fi
 
# run todo initially upon login
[ -e "$(which devtodo)" ] && devtodo ${TODO_OPTS}
This entry was posted by mazet and filed under Programmation, Bash.

Aucun commentaire pour le moment

Catégories

  • Toutes
  • Non catégorisé
  • Programmation
    • Awk
    • Bash
    • C
    • C++
    • Javascript
    • LaTeX
    • Perl
    • Tcl/Tk
  • Systeme
    • Android
    • Debian
    • Ubuntu

Contenu

  • Linux Router
  • Creating a network between 2 virtual machines on Windows with Qemu
  • Build a Debian package for pdmenu
  • Extract informations from epub file
  • Connexion PostgreSql / Java par Socket Unix
  • Example of fork and respawn
  • Start SSH daemon on Git portable distribution
  • Create a git mirror
  • Color diff
  • Create on Debian a Minecraft server
  • GIT/HG/SVN on multiple repos simultaneously
  • Convert Comics into CBZ format
  • Random password generator function
  • Convert to camelCase
  • DKIM and SPF
  • Migration from BackupPC 3 (Debian package) to BackupPC 4 (Standalone Installation)
  • Minimal BC for Mingw
  • Diskless Debian cluster
  • Colorize log file
  • Generate certificates with (or without) a certificate authority
Septembre 2025
Lun Mar Mer Jeu Ven Sam Dim
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          
 << <   > >>
  • Accueil
  • Récemment
  • Archives
  • Catégories
  • Derniers commentaires

Rechercher

Flux XML

  • RSS 2.0: Posts
  • Atom: Posts
What is RSS?

©2025 by Laurent Mazet • Contact • Aide • Social CMS

Community software

Cookies are required to enable core site functionality.