Prompt

From ThorxWiki
(Difference between revisions)
Jump to: navigation, search
(update a tad)
m (added exec time counter)
Line 14: Line 14:
   
 
* Verbose date/time and $USER greeting on the very first prompt. This detail never recurs. I don't need $USER every prompt, since this custom prompt is enough to indicate to me that it's my account. I do not use this prompt on any other user accounts, nor as UID=0. (despite being configured to handle that usage gracefully)
 
* Verbose date/time and $USER greeting on the very first prompt. This detail never recurs. I don't need $USER every prompt, since this custom prompt is enough to indicate to me that it's my account. I do not use this prompt on any other user accounts, nor as UID=0. (despite being configured to handle that usage gracefully)
  +
* wall clock execution time of command if it's longer than one minute
 
* last job exit status (invisible when zero)
 
* last job exit status (invisible when zero)
 
* host:path in network friendly (ish) format
 
* host:path in network friendly (ish) format
Line 29: Line 30:
 
** "live" for both of these is at a = "20 second refresh"
 
** "live" for both of these is at a = "20 second refresh"
 
** this refresh ensures that an abandoned prompt will keep-alive a remote shell over dodgy NAT :)
 
** this refresh ensures that an abandoned prompt will keep-alive a remote shell over dodgy NAT :)
** first prompt after a command shows time with seconds in favour of the TTY, and following refresh forces a newline. The upshot of this is that you have both start (to the minute) and end (to the second) time of every command run. Think of it as the poor-mans `time $0` (with the caveat that the right-prompt does not show if the $PWD or $0 is too long)
 
 
* current tty
 
* current tty
  +
** first prompt after a command shows time with seconds in favour of the TTY
   
 
=== under consideration / TODO ===
 
=== under consideration / TODO ===

Revision as of 14:41, 26 June 2011

Contents

As a commandline junkie, my prompt is important. It is a key element to my interface.

It needs to be both informative and terse (I can't stand 2line prompts for eg)

I have used ZSH as my shell of preference since roughly the turn of the century. (previously: bash). Part of the incentive to switch was the prompt interface features found in zsh that were not in bash at the time. (my memory has right-aligned-prompt as notable, but I'm sure there were more reasons than just that ;)

The prompt I use dates it's heritage back to an old dos (specifically: 4DOS) prompt that I setup in... 1994, for a guess.

Features

currently implemented

(thumbnail)
prompt action
  • Verbose date/time and $USER greeting on the very first prompt. This detail never recurs. I don't need $USER every prompt, since this custom prompt is enough to indicate to me that it's my account. I do not use this prompt on any other user accounts, nor as UID=0. (despite being configured to handle that usage gracefully)
  • wall clock execution time of command if it's longer than one minute
  • last job exit status (invisible when zero)
  • host:path in network friendly (ish) format
  • path shortening to last three components, plus subtle visual indication when this occurs (deliminating colon changes from host colour to directory colour, and '…' appears as the first element)
    • this shortening balances path context needs with space limitations. and is why the preceeding 'network friendly' format is "ish" :)
  • path colourisation to indicate whether $PWD is RW or not (not usually means RO, but may also mean 'directory does not exist')
  • count of background jobs (invisible if zero)
  • ^ and $ reminder mnemonic for regex start/end line matching (I have a dyslexia about this!)
  • priveliged user (usually UID=0) indication. Using # instead of $
  • bang (!) hints (ie, history event number)
  • VIM keybinding 'command' mode indication
  • version control system repository information (supports bzr, git, svn, cvs... others?)
  • live updating load average (colourised with thresholds. invisible below 0.4)
  • live updating of time
    • "live" for both of these is at a = "20 second refresh"
    • this refresh ensures that an abandoned prompt will keep-alive a remote shell over dodgy NAT :)
  • current tty
    • first prompt after a command shows time with seconds in favour of the TTY

under consideration / TODO

these have been suggested, but not yet implemented. Or maybe I wont implement them - but I haven't decided yet

  • make priv user prompt (#) be an alternate colour
  • make the first prompt reset wipe the visibility of any half-written command in that location
  • remove history event hint, or change format to eventnum@time ?


ignored / NOT be implemented

note: some of these I just don't use (or at least, ever expect to), others were clearly suggested in jest :)


Configuration

My current prompt config is findable here:

http://wiki.thorx.net/~nemo/m/zfunk/

Using single quotes around $PS1 and $RPS1 to delay evaluation of variables until the prompt is displayed requires that you have the PROMPT_SUBST option set.

If the output of $RPS1 isn't remaining on the line with $PS1 after a command is executed, unset TRANSIENT_PROMPT option.

Personal tools
Namespaces

Variants
Actions
Navigation
meta navigation
More thorx
Tools