Archive for shell

[tekwalk] xopen : shell function to have verbose xdg-open : Mac’s “open” alternative for Linux

Posted in AbhishekKr, Blogroll, install-on-linux with tags , , , , , , , on March 4, 2014 by abhishekkr

tekwalk.blogspot.in [13/Feb/2014]

http://tekwalk.blogspot.in/2014/02/xopen-shell-function-to-have-verbose.html

I have been using xdg-open for sometime now, it’s a utility similar to “open” utility popular among MacOSx users.

It enables you to open any file in the default “open with” program assigned to it’s type. So, just passing any type of file to this utility would let you open it in the program it’s supposed to open.

What is xdg-open?
source[1]: https://wiki.archlinux.org/index.php/xdg-open
source[2]: http://linux.die.net/man/1/xdg-open

There is just this little shell function, that makes your xdg-open usage a bit more verbose in case of errors (bad-syntax/ghost-file/ghost-program/open-failure) faced about the reason for it. And also shortens the access util name obviously.

xopen ()
{
xdg-open “$@”;
_TMP_EXITCODE=$?;
if [ “${_TMP_EXITCODE}” == “1” ]; then
echo “[ERROR:] Error in command line syntax”;
else
if [ “${_TMP_EXITCODE}” == “2” ]; then
echo “[ERROR:] One of the files passed on the command line did not exist”;
else
if [ “${_TMP_EXITCODE}” == “3” ]; then
echo “[ERROR:] A required tool could not be found”;
else
if [ “${_TMP_EXITCODE}” == “4” ]; then
echo “[ERROR:] The action failed”;
fi;
fi;
fi;
fi;
return $_TMP_EXITCODE
}

…read full blogpost here

Advertisements

[tekwalk] console and json

Posted in Blogroll, tutorial with tags , , , , , , , , on April 30, 2013 by abhishekkr

tekwalk.blogspot.com [12/Apr/2013]

http://tekwalk.blogspot.in/2013/04/console-and-json.html

recently Alan posted a very nice aticle around prettifying json, reminded me of <this draft>… he posted 2 out of 3 utilities I was gonna mention… so here is 3rd and the shell profile way to use first 2

$ sudo wget -c -O /etc/profile.d/a.json.sh https://raw.github.com/abhishekkr/tux-svc-mux/master/shell_profile/a.json.sh

it contains 2 functions available at shell

# usage example:
# $ json_me ‘echo {“a”: 1, “b”: 2}’
# $ json_me ‘curl http://127.0.0.1/my.json&#8217;
json_me(){
bash -c $@ | python -mjson.tool
}

# requirement: $ pip install pjson
# usage example:
# $ pjson_me ‘echo {“a”: 1, “b”: 2}’
# $ pjson_me ‘curl http://127.0.0.1/my.json&#8217;
pjson_me(){
bash -c $@ | pjson
}

…click here to read full post

[a.Bionic] shell.function to auto-clone all Repositories from a GitHub account

Posted in Blogroll, tutorial with tags , , , , , , , on April 30, 2013 by abhishekkr

abionic.blogspot.com [13/Jan/2013]

http://abionic.blogspot.in/2013/01/shellfunction-to-download-all.html

a shell utility to download all repositories managed under any GitHub account in the current directory…
if the current directory has any of the repositories already cloned, it pulls the latest

usage:   $ clone-github github
would download all the repositories managed under ‘github’ account

shell function at https://gist.github.com/abhishekkr/4428447/raw/7afb0cc878b6c95d6af37dcdd5e13f62a00befdb/a.github.sh

…click here to read full post

[a.Bionic] download all files embedded from GitHub Gist URL

Posted in ABK Labs with tags , , , , , on December 3, 2012 by abhishekkr

abionic.blogspot.in []

http://abionic.blogspot.in/2012/11/shellfunction-to-download-all-files.html

a shell utility to download all parts of a GIST url at provided download path

usage e.g. $ ddl-gist https://gist.github.com/4165864 /etc/profile.d/

howTo install
$ curl -L -o /etc/profile.d/ddl-gist.sh https://gist.github.com/4165864

actually, if you had this utlity… the usage example would install the utlity… chicken-egg

…..click here to read full post

[a.Bionic] auto-download all media from any RSS – eg. DefCon20 Talk Videos

Posted in ABK Labs with tags , , , , , , on November 28, 2012 by abhishekkr

@ abionic.blogspot.in [27/Nov/2012]

http://abionic.blogspot.in/2012/11/auto-download-all-media-from-rss.html

a shell utility code for download all media present as enclosures in any RSS

eg. usage to download all slides video of DefCon20
$ ddl-rss-media https://www.defcon.org/podcast/defcon-20-slides.rss

to install it
$ sudo curl -L -o /etc/profile.d/ddl-rss-media.sh https://gist.github.com/4156364#file_gistfile1.sh

…..click here to read full post

[a.Bionic] auto-download all videos of any Event at Confreaks.com

Posted in ABK Labs with tags , , , , , , , , , on November 28, 2012 by abhishekkr

@ abionic.blogspot.in [27/Nov/2012]

http://abionic.blogspot.in/2012/11/auto-download-all-videos-of-any-event.html

Auto-Download all smallest size Videos of any provided Event in Confreaks.com

to install it either run
$ sudo curl -L -o /etc/profile.d/ddl-confreaks.sh https://gist.github.com/raw/4137843/e6c6c93ef1c4cbf4cb735de821b74fcec467c170/gistfile1.sh

or copy+paste the shell function below in your shell-load-conf file.

suppose the event resides at URL:
http://confreaks.com/events/rubyconf2012

and you just need to run
$ ddl-confreaks rubyconf2012 ~/Downloads

and it will download all Talk Videos from Ruby Conference 2012 at your ~/Downloads directory…

…..click here full post

[justfewtuts.blogspot.com] automate process ‘kill’ of multiple instances

Posted in Blogroll, tutorial with tags , , , , , , , , , , on August 11, 2010 by abhishekkr

@ justfewtuts.blogspot.com [11/August/2010]

http://justfewtuts.blogspot.com/2010/08/linux-to-kill-multiple-instances-of.html

aw(Kill) all instances:

it has been happening in Linux where sometimes I need to…….
…….automated it with help of AWK

so here is a command/script you can use to automate it in …click here to read full BlogPost