This script has been working perfectly for me since the day I wrote it. However, the problem was that my "directory" file had started to grow a little out of proportion, and I started having trouble remembering all the aliases I put in it. So I wanted to enable custom tab completions on the script.
Enter this tiny bit of code.
All you have to do is insert the following at the end of your bashrc file (usually in ~/.bashrc)
complete -F _bdwsmscomplete websms _bdwsmscomplete() { local CUR PRE OPTS CONTACTS local WSMSDIR="$HOME/.wsmsdir" #change accordingly CUR="${COMP_WORDS[COMP_CWORD]}" PRE="${COMP_WORDS[COMP_CWORD-1]}" OPTS="-h -v -s -d -u -p -n" CONTACTS="$(cut -f1 -d',' ${WSMSDIR})" if [[ ${CUR} = -* ]] then COMPREPLY=($(compgen -W "${OPTS}" -- ${CUR})) return 0 fi case ${PRE} in -n) COMPREPLY=($(compgen -W "${CONTACTS}" -- ${CUR})) return 0 ;; websms*) COMPREPLY=($(compgen -W "-n" -- ${CUR})) return 0 ;; esac return 0 }
If everything went well, you should be able to hit the [TAB] key while at the -n option and it'll automatically try to fill in the name of your contact.Enjoy!
P.S You'll need to re-open the terminal.
4 Comments:
Recently a video has been posted on youtube showing a disgusting renewal of vows in the Maldives. The way the international media, daily mail and the evening standard took the story gave the wrong impression of Maldivians to the world.
Heres a video response to that: http://www.youtube.com/watch?v=GD7rOxXvPmk
This video shows a side of Maldivian culture that is true and hardly ever spoken of. The TRUE MALDIVIAN. Its taboo because we are supposed to be a 100% muslim country. But see for yourself..
campaign hingiyas bodu varu! saabas.
Since most people copy and paste believing in the coder and not checking the code, I think you should change ' local WSMSDIR="/home/kudanai/.wsmsdir" #change accordingly' to 'local WSMSDIR="~/.wsmsdir"'!
noted. Done. lazy work on my part.
Post a Comment