Wednesday, March 20, 2013

Spring Cleaning

Hello faithful reader(s)!

Though this blog began as a documentation of my foray into digital signal processing, I've decided I would like to continue posting on this site. While the entries I write henceforth may not be related to DSP and audio programming, I may return to the topic in the future.

So, I'd like to begin (again) with a short, neat little script to pimp out your bash prompt on Ubuntu. This configuration will randomly select a word from the Ubuntu dict and provide a definition  at startup of the terminal emulator. Follow these steps to get everything set up:

  1. Ensure that dict is installed, using sudo apt-get -y install dict.
  2. Install sdcv, a command line dictionary. Along with it, download several of the dictionary "packs". You can follow the instructions in this forum post:
    http://askubuntu.com/questions/191125/is-there-an-offline-command-line-dictionary
  3. Add the following lines to your .bashrc:
 random_word=$(sed -n "$(($RANDOM % 99999)) p" /usr/share/dict/words)  
 word=$random_word  
 if [[ $word == *\'s ]]  
 then  
      word=$(echo $word | cut -c-$(echo `expr ${#word} - 2` ))  
 fi  
 export word  
 PS1='[$word]: '  
 echo -e "\033[1;34m$(sdcv -n $word)\033[0;37m"  

That's it! It's not the most robust; sometimes it'll grab a word that can't be defined. Take it, improve upon it, do whatever! Enjoy!

-- End transmission --