Adding the code bellow in your .bashrc file:
google() { search=""; img=""; wiki=0; serie=0; echo "Googling: $@"; for term in $@; do if [ "$term" = "-i" ]; then img="&tbm=isch" elif [ "$term" = "-l" ]; then img="$img&btnI=I%27m+Feeling+Lucky" elif [ "$term" = "-w" ]; then wiki=1 elif [ "$term" = "-S" ]; then serie=1 else search="$search%20$term"; fi done if [ $wiki -eq 1 ]; then w3m "http://en.wikipedia.org/wiki/Special:Search/$search" elif [ $serie -eq 1 ]; then w3m "http://en.wikipedia.org/wiki/Special:Search/list%20of%20$search%20episodes" else w3m "http://www.google.com/search?hl=en&q=$search$img" fi }give you the possibility to ask for
ubuntu @ ubuntu ~ └─ $ ▶ google hello world
by adding the code bellow in your .bashrc file:
googlenow(){ search=""; for term in $@; do search="$search%20$term"; done w3m "http://www.google.com/search?hl=en&q=$search" |sed -n "/About.*results/{n;N;p;}" |sed -r 's .{23} '; }> googlenow examples (hide)
ubuntu@ubuntu:~$ googlenow birth Richard Stallman March 16, 1953 (age 60 years), Manhattan, New York City, New York, United States ubuntu@ubuntu:~$ googlenow age Richard feynman 69 (1918 1988) Richard Feynman, Age at death ubuntu@ubuntu:~$ googlenow age universe 13.8 billion years Universe, Age ubuntu@ubuntu:~$ googlenow age earth 4.54 billion years Earth, Age ubuntu@ubuntu:~$ googlenow earth diameter 7,918 miles (12,742 km) Earth, Diameter ubuntu@ubuntu:~$ googlenow moon mass • Web mass of the Moon = 7.34767309 × 10^22 kilograms ubuntu@ubuntu:~$ googlenow 5 celsius to kelvin • Web 5 degrees Celsius = 278.15 kelvin ubuntu@ubuntu:~$ googlenow 5 celsius to Fahrenheit • Web 5 degrees Celsius = 41 degrees Fahrenheit ubuntu@ubuntu:~$ googlenow 5miles to km • Web 5 miles = 8.04672 kilometers ubuntu@ubuntu:~$ googlenow height michael jordan 6' 6" (1.98 m) Michael Jordan, Height ubuntu@ubuntu:~$ googlenow height barack obama 6' 1" (1.85 m) Barack Obama, Height ubuntu@ubuntu:~$ googlenow area France 260,558 sq miles (674,843 km²) France, Area ubuntu@ubuntu:~$ googlenow president of india Pranab Mukherjee India, President ubuntu@ubuntu:~$ googlenow capital kazakhstan Astana Kazakhstan, Capital ubuntu@ubuntu:~$ googlenow population paris 2.211 million (2008) Paris, Population
Adding the code bellow in your .bashrc file:
ddg(){ search=""; bang=""; zeroc=0; for term in $@; do if [ "$term" = "-z" ]; then zeroc=1 elif [[ "$term" =~ -([A-Za-z0-9._%+-]*) ]]; then bang="!${BASH_REMATCH[1]}" else search="$search%20$term"; fi done if [ $zeroc -eq 1 ]; then w3m "https://www.duckduckgo.com/?q=$bang$search" | sed -n "/Zero-click/,/More at/p" ; else w3m "https://www.duckduckgo.com/?q=$bang$search" ; fi }short version:
ddg(){ search=""; bang=""; for term in $@; do if [[ "$term" =~ -([A-Za-z0-9._%+-]*) ]]; then bang="!${BASH_REMATCH[1]}" ; else search="$search%20$term" ; fi ; done ; w3m "https://www.duckduckgo.com/?q=$bang$search" ;}give you the possibility to ask for
ubuntu @ ubuntu ~ └─ $ ▶ ddg hello worldthat will produce a DuckDuckGo request for "hello world" and display the results using w3m.
ubuntu@ubuntu:~$ ddg -z age Richard Feynman Zero-click info: age Richard Feynman Answer: (31/10/2013 is after Richard Feynman died). More at ubuntu@ubuntu:~$ ddg -z what is the capital of France Zero-click info: what is the capital of France Answer: Paris, Ile-de-France, France. More at ubuntu@ubuntu:~$ ddg -z 17usd to eur Zero-click info: 17usd to eur Conversion result: €12.44 (euros) - $17 (US dollars). More at ubuntu@ubuntu:~$ ddg -z 5miles to km Zero-click info: 5miles to km Conversion result: 8.047 km (kilometers) - Ireland (ITU region 1). More at ubuntu@ubuntu:~$ ddg -z what is the height of Everest Zero-click info: what is the height of Everest Answer: 8848 meters. More at `WolframAlpha' ubuntu@ubuntu:~$ ddg -z what is the Earth diameter Zero-click info: what is the Earth diameter Answer: 12735 km (kilometers), assuming diameter is average diameter. More at ubuntu@ubuntu:~$ ddg -z what is the distance Earth Moon Zero-click info: what is the distance Earth Moon Answer: 385210 km (kilometers) - Current. More at ubuntu@ubuntu:~$ ddg -z what is the Moon Mass Zero-click info: what is the Moon Mass Answer: 7.3459×10^22 kg (kilograms). More at
It seems that I was not the first one to wish such a tool... A similar one (not giving direct answer as ddg -z and ggn) is already existing, and has been created by Julian Assange (the known one).
It's Surfraw, and it has quite a long list of direct research possibilities! More infos can be found on the website.
This is a "command line browser" for youtube you can find here https://github.com/intnull/videotop (I'm not the author of this!).
Using this
Pressing Enter starts the download of the vid, pressing "p" plays the downloaded video, and "s" will start the streaming in mplayer without downloading for offline use.
You can find below a list of functions you can add to your .bashrc for various purposes, some of them come from commandlinefu.com, a website repository of great shell commands.
$("a[href^='http://cmssw.cvs.cern.ch/']").attr('href', function(){ return this.href.replace(/^http:\/\/cmssw.cvs.cern.ch\/cgi-bin\/cmssw\.cgi\/CMSSW\//, "https://github.com/cms-sw/cmssw/blob/imported-CVS-HEAD/"); });
lsof -P -i -n
cmdfu () { curl "http://www.commandlinefu.com/commands/matching/$@/$(echo -n $@ | openssl base64)/sort-by-votes/plaintext" }
ubuntu@ubuntu:~$ cd ~/some/very/deep/often-used/directory ubuntu@ubuntu:~/some/very/deep/often-used/directory$ mark deep ubuntu@ubuntu:~/some/very/deep/often-used/directory$ cd ~ ubuntu@ubuntu:~$ jump deep ubuntu@ubuntu:~/some/very/deep/often-used/directory$ marks deep -> /home/johndoe/some/very/deep/often-used/directory foo -> /usr/bin/foo/bar ubuntu@ubuntu:~/some/very/deep/often-used/directory$ unmark deep ubuntu@ubuntu:~/some/very/deep/often-used/directory$ marks foo -> /usr/bin/foo/bar
kbtogb () { echo " $1/1048576 " | bc }
extractpicfromweb() { Extens=$2 : ${Extens:="png"} elinks --source $1 | sed -n "s/.*href=\"\(.*\.$Extens\)\".*/wget \1/p" }
alias checkgmail='curl -u [Your gmail username] --silent "https://mail.google.com/mail/feed/atom" | perl -ne '\''print "\t" if //; print "$2\n" if /<(title|name)>(.*)<\/\1>/;'\'''
ubuntu@ubuntu:~/$ pygmentize -l sh ~/.bashrc
showline () { sed -n "$1 p" $2 }
awk '/start_pattern/,/stop_pattern/' file.txt
ubuntu@ubuntu:~$ awk '/head/,/\/head/' hello_world.php
function latexplot(){ echo -e '\n\n'; echo '\begin{figure}'; echo ' \begin{center}'; echo ' \includegraphics[width=0.5\textwidth]{pictures/'$1'}'; echo ' \end{center}'; echo ' \caption{$'$1'$}'; echo ' \label{fig:'$1'}' ; echo '\end{figure}';echo -e '\n\n';}
ubuntu@ubuntu:~/pictures$ latexplot theorie/SM_vert.pdf \begin{figure} \begin{center} \includegraphics[width=0.5\textwidth]{pictures/theorie/SM_vert.pdf} \end{center} \caption{$theorie/SM_vert.pdf$} \label{fig:theorie/SM_vert.pdf} \end{figure}
function trns(){ w3m http://mobile-dictionary.reverso.net/francais-anglais/$(perl -MURI::Escape -e 'print uri_escape("'$1'");') | awk '/━━━━+$/,/Index alphabétique/' ;}
ubuntu@ubuntu:~$ trns obtenir ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ obtenir vt [+permission] to get, to obtain [+argent, voix] to get Ils ont obtenu cinquante pour cent des voix. They got 50% of the votes. obtenir qch à qn to get sth for sb obtenir de qn qu'il fasse to get sb to do sth obtenir de pouvoir faire to get permission to do, to obtain permission to do [+total, nombre, somme] to arrive at, to reach [+résultat] to get, to obtain Nous avons obtenu de bons résultats. We got some good results. Résultats du dictionnaire collaboratifobtenir v. obtain obtenir justice exp. to obtain justice obtenir un Master 2 v. receive a Master's degree obtenir de l'avancement vi. gain promotion obtenir gain de cause v. win the case (vi.) obtenir gain de cause v. be proved right (vi.) obtenir à l'arraché v. snatch obtenir à l'esbroufe v. blag obtenir de l'argent v. raise money obtenir un délai v. get a time extension obtenir qch par copinage exp. to get sth through contacts obtenir qch par copinage exp. to get sth through cronyism obtenir gain de cause exp. to win out obtenir qch à qn exp. to get sth for sb obtenir de qn qu'il fasse exp. to get sb to do sth ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Index alphabétique
function syno(){ echo -e "========= "$1" ===========\n"; w3m 'http://dico.isc.cnrs.fr/dico/en/search?b=1&r='$1 |awk '/\[\*\]/,/English Interface/'; echo -e "\n ===========================\n"; w3m http://www.synonym.com/synonyms/$1/ |awk '/Synonyms \(/,/Quiz/' ;}
ubuntu@ubuntu:~$ syno figure ========= figure =========== [*]appearance, believe, body, build, calculate, cast, character, chassis, cipher, compute, contour, count, count on, cypher, design, device, digit, emblem, envision, estimate, expect, fancy, fashion, figure of speech, figure out, forecast, form, guess, height, human body, image, make calculations, motif , name, number, numeral, outline, pattern, physique, picture, price, profile, project, reckon, see, shape, statue, stature, subject, sum, suspect, symbol, theme, think, torso, total, trope, value, visualize, work out [ ]decimal digit [ ]dummy [ ]enter [ ]fig [ ]opine (*) English Interface ( ) French Interface =========================== Synonyms (Grouped by Similarity of Meaning) of verb figure Sense 1: calculate, estimate, reckon, count on, figure, forecast evaluate, pass judgment, judge Sense 2: figure, enter be Sense 3: visualize, visualise, envision, project, fancy, see, figure, picture, image imagine, conceive of, ideate, envisage Sense 4: calculate, cipher, cypher, compute, work out, reckon, figure reason Sense 5: figure grok, get the picture, comprehend, savvy, dig, grasp, compass, apprehend [] Quiz Picks
ubuntu@ubuntu:~$ cat /tmp/data | histogram.py # NumSamples = 29; Max = 10.00; Min = 1.00 # Mean = 4.379310; Variance = 5.131986; SD = 2.265389 # each * represents a count of 1 1.0000 - 1.9000 [ 1]: * 1.9000 - 2.8000 [ 5]: ***** 2.8000 - 3.7000 [ 8]: ******** 3.7000 - 4.6000 [ 3]: *** 4.6000 - 5.5000 [ 4]: **** 5.5000 - 6.4000 [ 2]: ** 6.4000 - 7.3000 [ 3]: *** 7.3000 - 8.2000 [ 1]: * 8.2000 - 9.1000 [ 1]: * 9.1000 - 10.0000 [ 1]: *
ubuntu@ubuntu:distribution$ cat /usr/share/dict/words | awk '{print length($1)}' | ./distribution --char=# | sort -n Val|Ct (Pct) Histogram 3 |3254 (0.50%) ### 4 |12028 (1.85%) ######### 5 |28630 (4.40%) #################### 6 |52308 (8.04%) #################################### 7 |73556 (11.30%) ################################################## 8 |88559 (13.61%) ############################################################ 9 |90700 (13.94%) ############################################################## 10|82816 (12.73%) ######################################################## 11|67593 (10.39%) ############################################## 12|51650 (7.94%) ################################### 13|36747 (5.65%) ######################### 14|25066 (3.85%) ################# 15|16020 (2.46%) ########### 16|9800 (1.51%) ####### 17|5501 (0.85%) ####
#Display stock data for S&P 500 ubuntu@ubuntu:spark$ curl http://www.optiontradingtips.com/resources/historical-data/sp500/%5EGSPC.TXT --silent | grep "20100331" -A 31 | awk -F' ' '{print $5/20}' | ./spark ▅▅▆▆▆▆▆▆▆██▆▆█████▆▆█▆█▅▅▂▁▃▃▅▃▂
curl -s 'http://fr.wikipedia.org/wiki/Ville_de_Belgique'
scrape -be 'table.wikitable > tr:not(:first-child)'
xml2json
jq -c '.html.body.tr[] | {city: .td[0].a.title, population: .td[3]."$t"}'
json2csv -d=' ' -k city,population
sed 's;\([0-9]\) \([0-9]\);\1\2;g'
./distribution --tokenize='[\t]' -g=kv -size=large --char=ba
ubuntu@ubuntu:~$ curl -s 'http://fr.wikipedia.org/wiki/Ville_de_Belgique' | scrape -be 'table.wikitable > tr:not(:first-child)' | xml2json | jq -c '.html.body.tr[] | {city: .td[0].a.title, population: .td[3]."$t"}' |json2csv -d=' ' -k city,population |sed 's;\([0-9]\) \([0-9]\);\1\2;g' | ./distribution --tokenize='[\t]' -g=kv -size=large --color --char=ba Val |Ct (Pct) Histogram Anvers |506922 (10.37%) ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ Gand |249008 (5.09%) ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ Charleroi |204670 (4.19%) ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ Liège |197013 (4.03%) ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ "Ville de Bruxelles" |168230 (3.44%) ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ Bruges |117639 (2.41%) ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ Namur |110691 (2.26%) ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ Louvain |98002 (2.00%) ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ Mons |93366 (1.91%) ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ Malines |82573 (1.69%) ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ Alost |82037 (1.68%) ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ "La Louvière" |78895 (1.61%) ▬▬▬▬▬▬▬▬▬▬▬▬▬▬ Courtrai |75645 (1.55%) ▬▬▬▬▬▬▬▬▬▬▬▬▬ "Hasselt (Belgique)" |74694 (1.53%) ▬▬▬▬▬▬▬▬▬▬▬▬▬ "Saint-Nicolas (Flandre-Orientale)"|73317 (1.50%) ▬▬▬▬▬▬▬▬▬▬▬▬▬ Ostende |70618 (1.44%) ▬▬▬▬▬▬▬▬▬▬▬▬▬ Tournai |69751 (1.43%) ▬▬▬▬▬▬▬▬▬▬▬▬ Genk |65321 (1.34%) ▬▬▬▬▬▬▬▬▬▬▬▬ Seraing |63968 (1.31%) ▬▬▬▬▬▬▬▬▬▬▬ Roulers |59147 (1.21%) ▬▬▬▬▬▬▬▬▬▬▬ Verviers |56594 (1.16%) ▬▬▬▬▬▬▬▬▬▬ Mouscron |56023 (1.15%) ▬▬▬▬▬▬▬▬▬▬ Termonde |44546 (0.91%) ▬▬▬▬▬▬▬▬ Beringen |43697 (0.89%) ▬▬▬▬▬▬▬▬ Turnhout |41708 (0.85%) ▬▬▬▬▬▬▬▬ Vilvorde |41097 (0.84%) ▬▬▬▬▬▬▬▬ Saint-Trond |40357 (0.83%) ▬▬▬▬▬▬▬ Lokeren |39967 (0.82%) ▬▬▬▬▬▬▬ Herstal |39242 (0.80%) ▬▬▬▬▬▬▬ Geel |37884 (0.77%) ▬▬▬▬▬▬▬ Ninove |37325 (0.76%) ▬▬▬▬▬▬▬ "Hal (Belgique)" |36922 (0.76%) ▬▬▬▬▬▬▬ Waregem |36822 (0.75%) ▬▬▬▬▬▬▬ "Châtelet (Belgique)" |36191 (0.74%) ▬▬▬▬▬▬▬ Ypres |35242 (0.72%) ▬▬▬▬▬▬▬
rolandg () { watch -t "w3m http://m.rolandgarros.com/mobile/fr_FR/scores/index.html |egrep -A5 '$1'" } rolandgall () { watch -t "w3m http://m.rolandgarros.com/mobile/fr_FR/scores/index.html |egrep -A58 'Rafraichir '" }
ubuntu @ ubuntu └─ $ ▶ rolandg Chatrier
Simple Messieurs - Final - Court Philippe Chatrier Statistiques Match joué Pts 1 2 3 4 5 R.Nadal (ESP) [3] ● 6^ 6^ 6^ ^ ^ D.Ferrer (ESP) [4] 3^ 2^ 3^ ^ ^
rolandg () { watch -t "elinks http://m.rolandgarros.com/fr_FR/scores/index.manual.html| grep -A22 '$1' | sed -e 's/^[ ]*\[[0-9]*\]/\nPlayer /g' |sed -e 's/\[[0-9]*\]//g' | tr -s '\n' ' ' | sed -e 's/$/\n/' |sed -e 's/Player/\nPlayer/g' | sed -e 's/\(([A-Z]*)\)/\1\n/g' | sed -e 's/ Pts 1 2 3 4 5//' |sed -e 's/\([0-9]\) \([0-9]\)/\1\t\2/g' " }
australop () { watch -t "elinks http://m.ausopen.com/en_AU/scores/index.manual.html | grep -A22 '$@' | sed -e 's/^[ ]*\[[0-9]*\]/\nPlayer /g' |sed -e 's/\[[0-9]*\]//g' | tr -s '\n' ' ' | sed -e 's/$/\n/' |sed -e 's/Player/\nPlayer/g' | sed -e 's/\(([A-Z]*)\)/\1\n/g' | sed -e 's/ Pts 1 2 3 4 5//' |sed -e 's/\([0-9]\) \([0-9]\)/\1\t\2/g'" } australopall() { watch -t "elinks http://m.ausopen.com/en_AU/scores/index.manual.html | egrep -A22 '\-.+ [a-zA-Z\ \x27]+ \- ' | sed -e 's/^[ ]*\[[0-9]*\]/\nPlayer /g' |sed -e 's/\[[0-9]*\]//g' | tr -s '\n' ' ' | sed -e 's/$/\n/' |sed -e 's/Player/\nPlayer/g' | sed -e 's/\(([A-Z]*)\)/\1\n/g' | sed -e 's/ Pts 1 2 3 4 5//' |sed -e 's/\([0-9]\) \([0-9]\)/\1\t\2/g' |sed -e 's/--/\n\n/g'" }
ubuntu @ ubuntu └─ $ ▶ australop Margaret
Margaret Court Arena - Men's Singles - Round 1 Player M.Baghdatis (CYP) 15 4^ 5^ 3^ ^ ^ Player D.Istomin (UZB) 30 6^ 7^ 4^ ^ ^