You are not logged in.
Pages: 1
How do I get a read prompt in color? Escape sequences seem to fail here.
read -p "Type something: "
Offline
Oh, I can't use echo beforehand here because I'm trying to get a command history going. When I send up/down keys, it erases the prompt.
#!/bin/bash
HISTORYFILE=".buildpkgs_history"
BUILDPKGEXEC="./buildpkg"
ext () {
history -w $HISTORYFILE
exit
}
trap ext SIGINT
history -r $HISTORYFILE
for (( ; ; ))
do
#echo -ne '\E[36;40m'"==> "; tput sgr0; echo -n "Which package to build? "
read -ep "Which package to build? " pkgtobuild; history -s $pkgtobuild
$BUILDPKGEXEC $pkgtobuild
done
Offline
I'm away from a shell right now, but I think this might work.
#!/bin/bash
HISTORYFILE=".buildpkgs_history"
BUILDPKGEXEC="./buildpkg"
ext () {
history -w $HISTORYFILE
exit
}
trap ext SIGINT
history -r $HISTORYFILE
prompt=$(tput setaf 6; echo -n '==> '; tput sgr0; echo -n 'Which package to build? ')
for (( ; ; ))
do
read -ep "$prompt" pkgtobuild; history -s $pkgtobuild
$BUILDPKGEXEC $pkgtobuild
done
Basically, just cache your prompt and the necessary escape sequences in a variable, then pass that to the read builtin.
Last edited by bcat (2010-06-29 16:37:38)
Running Arch on a Dell Studio 1735. xmonad FTW! Dotfiles here.
Want free cloud-based file sharing? Sign up for Dropbox and we both get some bonus storage!
Offline
I'm away from a shell right now, but I think this might work.
#!/bin/bash HISTORYFILE=".buildpkgs_history" BUILDPKGEXEC="./buildpkg" ext () { history -w $HISTORYFILE exit } trap ext SIGINT history -r $HISTORYFILE prompt=$(tput setaf 6; echo -n '==> '; tput sgr0; echo -n 'Which package to build? ') for (( ; ; )) do read -ep "$prompt" pkgtobuild; history -s $pkgtobuild $BUILDPKGEXEC $pkgtobuild done
Basically, just cache your prompt and the necessary escape sequences in a variable, then pass that to the read builtin.
I tested it and it works.
Offline
Cool!
Running Arch on a Dell Studio 1735. xmonad FTW! Dotfiles here.
Want free cloud-based file sharing? Sign up for Dropbox and we both get some bonus storage!
Offline
Yeeeah! Thanks!
Offline
Pages: 1