Hack 30. PS2 – Continuation Interactive Prompt

by Ramesh

A very long command can be broken down to multiple lines by giving \ at the end of the line. The default interactive prompt for a multi-line command is “> “. Let us change this default behavior to display “continue->” by using PS2 environment variable as shown below.

  1. ramesh@dev-db ~> myisamchk --silent --force --fast --update-state \
  2. > --key_buffer_size=512M --sort_buffer_size=512M \
  3. > --read_buffer_size=4M --write_buffer_size=4M \
  4. > /var/lib/mysql/bugs/*.MYI
  5.  
  6. [Note: This uses the default ">" for continuation prompt]
  7.  
  8. ramesh@dev-db ~> export PS2="continue-> "
  9.  
  10. ramesh@dev-db ~> myisamchk --silent --force --fast --update-state \
  11. continue-> --key_buffer_size=512M --sort_buffer_size=512M \
  12. continue-> --read_buffer_size=4M --write_buffer_size=4M \
  13. continue-> /var/lib/mysql/bugs/*.MYI
  14.  
  15. [Note: This uses the modified "continue-> " for continuation prompt]

I found it very helpful and easy to read, when I break my long commands into multiple lines using . I have also seen others who don’t like to break-up long commands.