Display the history and optionally grep

2010-05-19 1 min read Bash

Ever wondered how good it would be to have a command/function that would display the history or display the history with <a class="zem_slink" title="Grep" rel="wikipedia" href="http://en.wikipedia.org/wiki/Grep">grep.

Would be really good right, well someone thought about this 🙂

$ h() { if [ -z &#8221;$1&#8221; ]; then history; else history | grep &#8221;$@&#8221;; fi; }

Place this in your .bash_profile and you can use it two different ways. If you issue &#8217;h&#8217; on its own, then it acts like the history command. If you issue:

Continue reading

bash script to change icon theme to check out all the installed themes (personal)

2010-05-19 2 min read Fedora GNOME Linux

I am really annoyed with the time that is required and the number of clicks that it takes to change the gnome icon theme. So here&#8217;s a small script that I wrote to quickly check out all the icon themes that I have in my ~/.icons folder.

#!/bin/bash
[[ &#8221;$1&#8221; == &#8221;&#8221; ]] && time=5 || time=$1
[[ &#8221;$2&#8221; == &#8221;&#8221; ]] && (
cd ~/.icons
cont=&#8221;y&#8221;
echo &#8221;Select one of the icon themes&#8221;
echo &#8221;When you like some theme just press Ctrl+c&#8221;
for i in *
do
[[ -d $i/cursors ]] || (
echo &#8221;Now trying …. : $i&#8221;
gconftool-2 –type string -s  /desktop/gnome/interface/icon_theme &#8221;$i&#8221;
sleep $time
)
done
) || gconftool-2 –type string -s  /desktop/gnome/interface/icon_theme &#8221;$2&#8221;

Continue reading

Get the most favourite commands from commandlinefu

2010-05-12 1 min read Bash

For those of you who don&#8217;t know, commandlinefu should be one place you should watch to learn new things for command line. Everyday a lot of people post commands to better the previously posted commands. If you want to get the best voted commands from the archieves of commandlinefu then you can use the command:

curl -O &#8221;<a rel="nofollow" href="http://www.commandlinefu.com/commands/browse/sort-by-votes/plaintext/%5B0-2400:25%5D">http://www.commandlinefu.com/commands/browse/sort-by-votes/plaintext/[0-2400:25]&#8221;

Suggested by Dynetrekk ****<a href="http://www.commandlinefu.com/commands/view/2740/get-all-these-commands-in-a-text-file-with-description" target="_blank">here.

Easier Reinstalls

2010-05-10 1 min read Bash Fedora Linux

<span style="font-size: x-large;"><a href="http://www.howtoforge.com/easier-reinstalls">E<a href="http://www.howtoforge.com/easier-reinstalls">asier Reinstalls

Easier Reinstalls

I typically reinstall my computer operating system every six months. The reasons for this are that it cleans out the system and reinstalls require me to be in front of the computer for a total of about ten minutes so it&#8217;s painless. Notice I said &#8221;in front of the computer&#8221;, the system does all of the work for me with some specially crafted bash scripts.

Continue reading

coproc help - a new feature in bash

2010-05-10 0 min read Bash Fedora Linux
\"Screenshot
Image via Wikipedia

In the <a class="zem_slink freebase/en/bash" title="Bash" rel="homepage" href="http://tiswww.case.edu/php/chet/bash/bashtop.html">bash version 4.0, there is a new concept called coproc. This is very useful for some of the daily tasks.

co-<a class="zem_slink freebase/guid/9202a8c04000641f800000000005a409" title="Process (computing)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Process_%28computing%29">process starts a process in the background, optionally with a NAME, with which other processes can communicate. This can be a very <a class="zem_slink freebase/en/substitute_good" title="Substitute good" rel="wikipedia" href="http://en.wikipedia.org/wiki/Substitute_good">good substitution for <a class="zem_slink freebase/guid/9202a8c04000641f800000000048fac5" title="Pipeline (Unix)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Pipeline_%28Unix%29">pipes in lots of cases. You can learn more about coproc in the link below:

Continue reading

Download with browse with bash and wget

2010-05-09 1 min read Bash Fedora

Been pretty busy for last couple of days. Will be busy for another few days, but here&#8217;s something to munch in the meantime (Script may need changes depending on the type of file you want to download or the site you are browsing, but the chnages should be minimal):

file=&#8221;/tmp/temp.dir&#8221;
url=&#8221;URL Here&#8221;
IFS=&#8217;
&#8217;
cont=&#8221;y&#8221;
while [ $cont != &#8221;n&#8221; ]
do
name=&#8221;&#8221;
wget &#8221;$url&#8221; -O $file -o /dev/null
for i in $(grep href $file |grep -v Parent)
do
name=${i##href=&#8221;}
name=${name%%&#8221;>
}
echo $name
if [[ $name == *gz ]]
then
cont=&#8221;n&#8221;
fi
done
if [ ! $name ]
then
echo &#8221;No files here.. Exiting&#8221;
exit -1
fi
echo
if [ $cont == &#8221;n&#8221; ]
then
echo &#8221;Enter the filename for download :&#8221;
read file
fi
echo &#8221;Select one of the options:&#8221;
read product
url=&#8221;$url/$product&#8221;
echo &#8221;About to get $url&#8221;
done
wget &#8221;$url&#8221; -O $file -o /dev/null

Continue reading
Older posts Newer posts