Previous post:

Next post:

Hack 36. Display output of any command in the prompt

by Ramesh

You can display output of any Linux command in the prompt. The following example displays three items separated by | (pipe) in the command prompt:

  • \!: The history number of the command
  • \h: hostname
  • $kernel_version: The output of the uname -r command from $kernel_version variable
  • \$?: Status of the last command
ramesh@dev-db ~> kernel_version=$(uname -r)

ramesh@dev-db ~> export PS1="\!|\h|$kernel_version|\$?> "

473|dev-db|2.6.25-14.fc9.i686|0>
Vim 101 Hacks Book

Previous post:

Next post:

Leave a Comment

Previous post:

Next post: