Ignore CVS and svn directories in bash autocompletion.
CVS and SVN directories are something that really cause lot of un-necessary nuisance. So, simple solution just ignore them 🙂
export FIGNORE=CVS:~:.o:.svn bind 'set match-hidden-files off'
CVS and SVN directories are something that really cause lot of un-necessary nuisance. So, simple solution just ignore them 🙂
export FIGNORE=CVS:~:.o:.svn bind 'set match-hidden-files off'
Sometime back, we had looked at using colors in bash script and here is a way to create a array of all the colors.
#!/bin/bash - #=============================================================================== # # FILE: colorarray.sh # # USAGE: ./colorarray.sh # # DESCRIPTION: # # OPTIONS: --- # REQUIREMENTS: --- # BUGS: --- # NOTES: --- # AUTHOR: Amit Agarwal (aka), amit.agarwal@roamware.com # COMPANY: Roamware India Pvt Ltd # CREATED: 16/04/12 17:24:09 IST # Last modified: Mon Apr 16, 2012 05:39PM # REVISION: --- #=============================================================================== count=0 for i in 40m 41m 42m 43m 44m 45m 46m 47m do for l in 0 1 do echo -n "l=$l " for k in 0 1 do # echo -n "k=$k " for j in {30..37} do carr[$count]="\033[$k;$j;$l;$i" echo -ne "${carr[$count]}$count \033[00m" ((count++)) done done echo done echo done
You can add this script to any script of your choice and you have all the 256 colors available to you in the script without additional coding. Happy coding.
Continue readingI have been trying to understand the color codes for bash for a pretty long time, but somehow never got time to understand this clearly. So this time around when I was writing a script to analyze some logs. I thought I will give it a go and finally understood some part of this.
So, first we will start with this script. This is taken from here.
Continue readingHere are some pretty good links on the subject. Since there are already so many blog posts, does not make sense to add one more 🙂
http://tldp.org/HOWTO/Bash-Prompt-HOWTO/c816.html
http://www.gilesorr.com/bashprompt/prompts/
https://bbs.archlinux.org/viewtopic.php?id=84386
Bash themes – http://onlamp.com/onlamp/2006/02/02/bash_themes.html
Here is a nice link on BASH History Expansion. There are lot of examples in this page and some of them might be quite useful. But here are my list of favourites:
!!
This is probably the most used one by me. This will repeat the last command. And this works even in conjunction with other commands like
Continue readingThere are some commands that take file name and there are some case where you need to give file name. But there are some cases where you want to modify the file before passing it to the command. What do you do in these case’s?
I had a file containing huge amount of data and for some testing I wanted to pass only the first few lines of the file and not the complete file. And since the file only accepted filename and would not take any input from the STDIN so only option was to create a file with the required data in a temporary file. So, I sat back to figure out some way to do it and finally found I can use this:
Continue readingI was trying to debug some bash scripts yesterday and learnt something new 😉
There are lot of things in bash that you can use to debug and to start with you can enable xtrace mode as follows:
set -x
With this set you will see that all the commands are printed along with all other information as they are executed.
This you can do for any line or for the function or for the whole script. Once you set the option you can turn it
off with