DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Bash Title Random Quote Routine

04.24.2008
| 4094 views |
  • submit to reddit
        #
#this is a script in my .bash_profile that gets a random
#quote .txt file and assigns it to the terminal title.
#

quote_path="/Users/glynch/Documents/quotes/*"
files=($quote_path)
N=${#files[@]}
((N=RANDOM%N))
randomfile=${files[$N]}
quote=""
while read line; do quote="$quote $line"; done < $randomfile
echo -n -e "\033]0;$quote\007"