#!/usr/bin/perl -w use strict; my $EDITOR = 'elvis'; my $index = @ARGV ? shift(@ARGV) :0; my $clear = 1; my $hide_help = 0; my $homedir = $ENV{HOME}; my $sandbox = $ENV{SANDBOX}; my $STUDYPATH = "$homedir/$sandbox"; $EDITOR = which($EDITOR); my $color = colorize('GREEN'); my $reset = colorize('reset'); while (1){ my @files = glob "$STUDYPATH/*"; system ('clear') unless $clear == 0; $clear++; $index =~ s/[A-Za-z]/0/g; $index = 0 if $index < (0-$#files)-1 || $index > $#files; printf ( "%50s <- (%5s)\n", $files[$index], $index); print " ",$color,"[C]",$reset,"hange editor. Currently $EDITOR ",$color,"[E]",$reset,"dit to open the snippet in an editor ",$color,"[G]",$reset,"oto to select file index: -", ($#files+1)," to $#files ",$color,"[H]",$reset,"elp to (un)hide this menu ",$color,"[N]",$reset,"ext to skip this snippet ",$color,"[R]",$reset,"edo to revisit the previous snippet co",$color,"[L]",$reset,"or to change the menu item color ",$color,"[Q]",$reset,"UIT to exit ",$color,"[T]",$reset,"ext to change the menu text color e",$color,"[X]",$reset,"ecute Any other key +",$color," ",$reset,"to print out the snippet -> " unless $hide_help==1; my $input = <>; if ($input =~ /^N/i){ ++$index; next; }elsif($input =~ /^G/i){ print "enter a number from -",$#files+1," to $#files -> "; $index = <>; chomp $index; }elsif($input =~ /^H/i){ $hide_help = $hide_help?0:1; }elsif($input =~ /^C/i){ $EDITOR = <>; chomp $EDITOR; $EDITOR = which ($EDITOR); # redo STUDY; }elsif($input =~ /^R/i){ --$index; }elsif($input =~ /^L/i){ print "change menu item color to: "; my $newcolor = <>; chomp $newcolor; $color = colorize($newcolor); }elsif($input =~ /^T/i){ print "change menu text color to: "; my $textcolor = <>; chomp $textcolor; $reset = colorize($textcolor); }elsif($input =~ /^(SANDBOX)/i){ print "$homedir/"; my $sandbox = <>; chomp $sandbox; $STUDYPATH = change_snippet_dir($sandbox); }elsif($input =~ /^E/i){ system ($EDITOR,$files[$index]); }elsif($input =~ /^X/i){ do $files[$index]; print "\n"; $clear = 0; }elsif($input =~ /^Q/i){ last; }else{ $clear=0; open (SCRIPT,"< $files[$index]") or warn "can't open file: $!"; print while