Move the ... functions to a new file
#############
# Functions #
#############
# Commande tres pratique pour formatter un fichier .man
# exemple : mf prog.1
function mf() { tbl $* | nroff -mandoc | less -s }
# ,,(), ,,,() for quickly changing $CWD {{{1
# http://www.shell-fu.org/lister.php?id=769
# Go up n levels:
# ,, 3
function ,, (){
local arg=${1:-1};
local dir=""
while [ $arg -gt 0 ]; do
dir="../$dir"
arg=$(($arg - 1));
done
cd $dir >&/dev/null
}
# Go up to a named dir
# ,,, usr
function ,,, (){
if [ -z "$1" ]; then
return
fi
local maxlvl=16
local dir=$1
while [ $maxlvl -gt 0 ]; do
dir="../$dir"
maxlvl=$(($maxlvl - 1));
if [ -d "$dir" ]; then
cd $dir >&/dev/null
fi
done
}
# genpass()
# Generates a tough password of a given length
# Borrowed (and slightly modifed) from Seth House github repository.
function genpass() {
if [ ! "$1" ]; then
echo "Usage: $0 20"
echo "For a random, 20-character password."
return 1
fi
dd if=/dev/urandom count=1 2>/dev/null | tr -cd 'A-Za-z0-9' | cut -c-$1
}