2011-04-01 15:12:48 +02:00
|
|
|
#Search on Google
|
|
|
|
google() {
|
|
|
|
emulate -L zsh
|
|
|
|
${=BROWSER} "http://www.google.com/search?&num=100&q=$*"
|
|
|
|
}
|
|
|
|
|
|
|
|
#Search French Wiktionary
|
|
|
|
wikdic_fr() {
|
|
|
|
emulate -L zsh
|
|
|
|
${=BROWSER} http://fr.wiktionary.org/wiki/${(C)1// /_}
|
|
|
|
}
|
|
|
|
#Search English Wiktionary
|
|
|
|
wikdic_en() {
|
|
|
|
emulate -L zsh
|
|
|
|
${=BROWSER} http://en.wiktionary.org/wiki/${(C)1// /_}
|
|
|
|
}
|
|
|
|
|
|
|
|
#Search French Wikipedia
|
|
|
|
wiki_fr() {
|
|
|
|
emulate -L zsh
|
|
|
|
${=BROWSER} "http://fr.wikipedia.org/w/index.php?title=Special%3ASearch&search=$*"
|
|
|
|
}
|
|
|
|
#Search English Wikipedia
|
|
|
|
wiki_en() {
|
|
|
|
emulate -L zsh
|
|
|
|
${=BROWSER} "http://en.wikipedia.org/w/index.php?title=Special%3ASearch&search=$*"
|
|
|
|
}
|
|
|
|
|
|
|
|
#French conjugaison
|
|
|
|
verbe() {
|
|
|
|
emulate -L zsh
|
|
|
|
${=BROWSER} "http://www.la-conjugaison.fr/du/verbe/${*}.php"
|
|
|
|
}
|
|
|
|
|
|
|
|
weather() {
|
|
|
|
emulate -L zsh
|
|
|
|
[[ -n "$1" ]] || {
|
|
|
|
print 'Usage: weather <station_id>' >&2
|
|
|
|
print 'List of stations: http://en.wikipedia.org/wiki/List_of_airports_by_ICAO_code'>&2
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
local VERBOSE="yes" # TODO: Make this a command line switch
|
|
|
|
|
|
|
|
local ODIR=`pwd`
|
|
|
|
local PLACE="${1:u}"
|
|
|
|
local DIR="${HOME}/.weather"
|
|
|
|
local LOG="${DIR}/log"
|
|
|
|
|
|
|
|
[[ -d ${DIR} ]] || {
|
|
|
|
print -n "Creating ${DIR}: "
|
|
|
|
mkdir ${DIR}
|
|
|
|
print 'done'
|
|
|
|
}
|
|
|
|
|
|
|
|
print "Retrieving information for ${PLACE}:"
|
|
|
|
print
|
|
|
|
cd ${DIR} && wget -T 10 --no-verbose --output-file=$LOG --timestamping http://weather.noaa.gov/pub/data/observations/metar/decoded/$PLACE.TXT
|
|
|
|
|
|
|
|
if [[ $? -eq 0 ]] ; then
|
|
|
|
if [[ -n "$VERBOSE" ]] ; then
|
|
|
|
cat ${PLACE}.TXT
|
|
|
|
else
|
|
|
|
DATE=$(grep 'UTC' ${PLACE}.TXT | sed 's#.* /##')
|
|
|
|
TEMPERATURE=$(awk '/Temperature/ { print $4" degree Celcius / " $2" degree Fahrenheit" }' ${PLACE}.TXT | tr -d '(')
|
|
|
|
echo "date: $DATE"
|
|
|
|
echo "temp: $TEMPERATURE"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
print "There was an error retrieving the weather information for $PLACE" >&2
|
|
|
|
cat $LOG
|
|
|
|
cd $ODIR
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
cd $ODIR
|
|
|
|
}
|
|
|
|
|
|
|
|
battery() {
|
|
|
|
if [[ $BATTERY -gt 0 ]] ; then
|
|
|
|
PERCENT="${${"$(acpi 2>/dev/null)"}/(#b)[[:space:]]#Battery <->: [^0-9]##, (<->)%*/${match[1]}}"
|
|
|
|
if [[ -z "$PERCENT" ]] ; then
|
|
|
|
PERCENT='acpi not present'
|
|
|
|
else
|
|
|
|
if [[ "$PERCENT" -lt 20 ]] ; then
|
|
|
|
PERCENT="warning: ${PERCENT}%%"
|
|
|
|
else
|
|
|
|
PERCENT="${PERCENT}%%"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
2013-12-13 10:46:31 +01:00
|
|
|
|
|
|
|
mgrep () {
|
|
|
|
find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -regextype posix-egrep -iregex '(.*\/Makefile|.*\/Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -type f -print0 | xargs -0 grep --color -n "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
cgrep () {
|
2014-09-01 14:36:19 +02:00
|
|
|
find . -name .repo -prune -o -name .git -prune -o -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \) -print0 | xargs -0 grep --color -n "$@"
|
2013-12-13 10:46:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
jgrep () {
|
|
|
|
find . -name .repo -prune -o -name .git -prune -o -type f -name "*\.java" -print0 | xargs -0 grep --color -n "$@"
|
|
|
|
}
|
|
|
|
|
2014-12-22 16:22:01 +01:00
|
|
|
cjgrep () {
|
|
|
|
find . -name .repo -prune -o -name .git -prune -o -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp' -o -name "*.java" \) -print0 | xargs -0 grep --color -n "$@"
|
|
|
|
}
|
|
|
|
|
2013-12-13 10:46:31 +01:00
|
|
|
resgrep () {
|
|
|
|
for dir in `find . -name .repo -prune -o -name .git -prune -o -name res -type d`
|
|
|
|
do
|
|
|
|
find $dir -type f -name '*\.xml' -print0 | xargs -0 grep --color -n "$@"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
gettop ()
|
|
|
|
{
|
|
|
|
local TOPFILE=build/core/envsetup.mk;
|
|
|
|
if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ]; then
|
|
|
|
echo $TOP;
|
|
|
|
else
|
|
|
|
if [ -f $TOPFILE ]; then
|
|
|
|
PWD= /bin/pwd;
|
|
|
|
else
|
|
|
|
local HERE=$PWD;
|
|
|
|
T=;
|
|
|
|
while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
|
|
|
|
\cd ..;
|
|
|
|
T=`PWD= /bin/pwd`;
|
|
|
|
done;
|
|
|
|
\cd $HERE;
|
|
|
|
if [ -f "$T/$TOPFILE" ]; then
|
|
|
|
echo $T;
|
|
|
|
fi;
|
|
|
|
fi;
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
croot ()
|
|
|
|
{
|
|
|
|
T=$(gettop);
|
|
|
|
if [ "$T" ]; then
|
|
|
|
\cd $(gettop);
|
|
|
|
else
|
|
|
|
echo "Couldn't locate the top of the tree. Try setting TOP.";
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-08-02 01:08:24 +02:00
|
|
|
function zsh_stats() {
|
|
|
|
fc -l 1 | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n20
|
|
|
|
}
|
2014-12-22 16:22:01 +01:00
|
|
|
|
|
|
|
function secure_chromium {
|
|
|
|
echo "make sure to have run \"ssh -TND 4711 $USER@host\" before"
|
|
|
|
port=4711
|
|
|
|
export SOCKS_SERVER=localhost:$port
|
|
|
|
export SOCKS_VERSION=5
|
|
|
|
chromium-browser &
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
2015-06-11 11:18:17 +02:00
|
|
|
sdocker (){
|
|
|
|
if [ -n "$SSH_AUTH_SOCK" ]; then
|
|
|
|
SSH_AUTH_ARGS="-v $SSH_AUTH_SOCK:/tmp/ssh_auth -e SSH_AUTH_SOCK=/tmp/ssh_auth"
|
|
|
|
fi
|
|
|
|
AOSP_ARGS=${AOSP_ARGS:--it}
|
|
|
|
img=$(docker ps | grep $1 | awk '{print $1}');
|
|
|
|
if [ -z $img ]; then
|
|
|
|
img=$(docker ps -a | grep $1 | awk '{print $1}') | head -1;
|
|
|
|
if [ -z $img ]; then
|
|
|
|
echo "Running a new container"
|
|
|
|
docker run ${AOSP_ARGS} ${=SSH_AUTH_ARGS} -v /home/mmaret/Project:/aosp/Project $1
|
|
|
|
else
|
|
|
|
echo "Starting $img"
|
|
|
|
docker start -i -a $img
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Attach to $img"
|
|
|
|
docker exec -it $img /bin/bash
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_sdocker () {
|
|
|
|
local cur
|
|
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
|
|
COMPREPLY=( $(compgen -W "$(docker images | tail -n +2 | grep -v "<none>" | awk '{print $1}')" -- ${cur} ) )
|
|
|
|
}
|
|
|
|
|
|
|
|
complete -o default -F _sdocker sdocker
|