Differences

This shows you the differences between two versions of the page.

Link to this comparison view

bashaliasesandfunctions [2016/12/26 16:44] (current)
yassine chaouche created
Line 1: Line 1:
 +\\
 +[[:​index|Home]] > [[:​computers|computers]] > [[:​linux|linux]] > [[:​bash|bash]] > [[BashAliasesAndFunctions]] | [[:​about|About]]
 +
 +<​code>​
 +# 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'
 +</​code>​
 +
 +Some useful functions too 
 +<​code>​
 +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"​
 +}
 +</​code>​
 +
 +
 +----
 +
 +contact : [[http://​twitter.com/​ychaouche|@ychaouche]] yacinechaouche at yahoocom
  

QR Code
QR Code bashaliasesandfunctions (generated for current page)