Home > computers > linux > bash > BashAliasesAndFunctions | About
# Count the number of files in current dir alias lsc='ls -l | wc -l' # Sort directories by sizes alias dush='du -h --max-depth=1 | sort -h' # Can't see all the files in one page ? alias lsless='ls | less' # Make a video capture of the desktop alias capturedesktop='avconv -f x11grab -r 25 -s 1900x1000 -i :0.0+0,24 -vcodec libx264 -threads 0' # Capture desktop, with sound alias capturedesktop_withsound='avconv -f x11grab -r 25 -s 1900x1000 -i :0.0+0,24 -vcodec libx264 -threads 0 -f alsa -i hw:0 ' # pastebin from the command line, use it like this : # somecommand | some pipe work | pastebin alias pastebin='curl -F "clbin=<-" "https://clbin.com"' # Only print actual code/configuration alias removeblanks="egrep -v '(^[[:space:]]*#|^$|^[[:space:]]*//)'" # Useful when you want to scp to your own machine from a remote server alias myip='ifdata -pa eth1'
Some useful functions too
function timedelta { d1=$1 d2=$2 echo $(( ($(date +%s -d $d1) - $(date +%s -d $d2)) / (60 * 60 * 24) )) } #ychaouche@ychaouche-PC 16:33:12 ~/TMP/NETWORK $ timedelta 2016-12-26 2014-11-16 #771 #ychaouche@ychaouche-PC 16:33:42 ~/TMP/NETWORK $ #It's been 771 days since I work in this place. # Searches inside PDF files # searchpdf "term" file1 file2 file3... function searchpdf { term="$1" shift 1 for file in $@ do echo ============================ echo $file echo ============================ pdftotext "$file" - | grep "$term" done } # Converts any video to a gif and compresses it. function vid2gif () { video=$1 name=${video%.*} gif="$name".gif echo avconv -i "$video" -pix_fmt rgb24 -r 5 -f gif "$gif"- avconv -i "$video" -pix_fmt rgb24 -r 5 -f gif "$gif"- echo gifsicle -O3 -U "$gif"- -o "$gif" gifsicle -O3 -U "$gif"- -o "$gif" }
contact : @ychaouche yacinechaouche at yahoocom