Skip to content

Instantly share code, notes, and snippets.

@lucascaton
Last active May 6, 2022 06:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucascaton/9faa81fcfad80bf7393e93c7f2dd23a4 to your computer and use it in GitHub Desktop.
Save lucascaton/9faa81fcfad80bf7393e93c7f2dd23a4 to your computer and use it in GitHub Desktop.
require "io/console"
COLORS = {
black: 0,
red: 31,
green: 32,
blue: 34
}
loop do
print "❯ "
command = ""
loop do
char = $stdin.getch
break if char == "\r" # User pressed <enter>
color = char == "e" ? COLORS[:red] : COLORS[:black] # Letter "e" will show up in red
printf "\033[#{color}m#{char}\033[#{COLORS[:black]}m"
command << char
end
break if command == "exit"
puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment