Prompt
(link to prompt online) |
m (jottings are now on zork) |
||
(25 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | == my personal (zsh) prompt setups has, on one line == |
+ | {{TOCright}} |
+ | 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: [[wikipedia:4DOS|4DOS]]) prompt that I setup in... 1994, for a guess. |
||
+ | |||
+ | == Features == |
||
+ | |||
+ | === currently implemented === |
||
+ | [[Image:Zshprompt.png|thumb|400px|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) |
* last job exit status (invisible when zero) |
||
* host:path in network friendly (ish) format |
* host:path in network friendly (ish) format |
||
− | * path shortening to last three components, plus subtle visual indication when this occurs |
+ | * 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" :) |
** 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') |
* 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) |
* 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 $ |
− | * live time and load average (load gets dynamic colourisation also, but is invisible below threshold (set to 0.3 for me) |
+ | * bang (!) hints (ie, history event number) |
− | ** for values of "live" that = "20 second refresh" |
+ | * VIM keybinding 'command' mode indication |
− | ** this refresh ensures that an abandoned prompt will keep-alive a remote shell over dodgy NAT :) |
+ | * version control system repository information (supports bzr, git, svn, cvs... others?) |
+ | ** Note: this is almost entirely untested |
||
+ | * live updating load average (colourised with thresholds. invisible below 0.4) |
||
+ | * live updating of time (or, if on battery, then battery discharge/charge info (I show minutes remaining for either when < 1hour, otherwise % of battery. Colour indicated charging (green/greenbold) vs discharging (yellow/yellowbold/redbold/redboldinverted). Battery required 'acpi' command with expected output to parse. |
||
+ | * live updating of 'biff'. ie, number of mailboxes with unread mail (Maildir++ format mailboxes only. Notes in [[Mutt]] indicate the basis of this) |
||
* current tty |
* current tty |
||
− | == ideas I don't currently implement == |
+ | ==== Extra Notes ==== |
+ | * The initial greeting recurs if the '$msg' variable is non-empty. It is echoed to the screen, then the prompt cleared to a new line with a refresh after only 1second. |
||
+ | * All "live" updates are at a 20 second refresh rate. Live updating also ensures that an abandoned prompt will keep-alive a remote shell over dodgy NAT :) |
||
+ | * The first prompt after any command always shows time with seconds, and does NOT show TTY or battery. They appear only after the first refresh |
||
+ | |||
+ | === 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 ? |
||
+ | |||
+ | * moving the vcs_info to replace the host:path element, since within a vcs, it's often a different command namespace. |
||
+ | ** [http://bewatermyfriend.org/media/vcs_info0.png example of vcs_info] |
||
* per-host auto-colourisation |
* per-host auto-colourisation |
||
− | ** http://screwtape.jottit.com/per-host_prompt_colouring |
+ | ** http://zork.net/~st/jottings/Per-Host_Prompt_Colouring.html |
− | * vcs_info (I would probably replace tty info with this, with a colourisation to help the glancing eye notice) |
||
** http://ft.bewatermyfriend.org/comp/zsh/functions/prompt_ft_setup.html |
** http://ft.bewatermyfriend.org/comp/zsh/functions/prompt_ft_setup.html |
||
− | *** [http://bewatermyfriend.org/media/vcs_info0.png example of vcs_info] |
||
− | ---- |
+ | ** note comment from screwtape: http://identi.ca/conversation/31704527#notice-31817077 |
+ | * active group when not default |
||
+ | |||
+ | |||
+ | === 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 :) |
||
+ | |||
+ | * count of subshells |
||
+ | * http://www.facebook.com/#!/nemothorx?v=wall&story_fbid=121814377837169&ref=mf |
||
+ | ** Free disk, highest mem and CPU process, length of current prompt! -- Norgus |
||
+ | ** current Dow, weather and TV listings -- Julian |
||
+ | |||
+ | |||
+ | = Configuration = |
||
+ | |||
+ | My current prompt config is findable here: |
||
− | here is my prompt: |
+ | http://pub.thorx.net/zsh/ |
− | http://wiki.thorx.net/~nemo/s/zsh_ps1.txt |
+ | 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. |
− | warning: it's full of comments and code cruft, both from old revisions, and also future plans. |
+ | If the output of $RPS1 isn't remaining on the line with $PS1 after a command is executed, unset TRANSIENT_PROMPT option. |
Latest revision as of 12:19, 3 June 2016
|
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.
[edit] Features
[edit] currently implemented
- 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)
- 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?)
- Note: this is almost entirely untested
- live updating load average (colourised with thresholds. invisible below 0.4)
- live updating of time (or, if on battery, then battery discharge/charge info (I show minutes remaining for either when < 1hour, otherwise % of battery. Colour indicated charging (green/greenbold) vs discharging (yellow/yellowbold/redbold/redboldinverted). Battery required 'acpi' command with expected output to parse.
- live updating of 'biff'. ie, number of mailboxes with unread mail (Maildir++ format mailboxes only. Notes in Mutt indicate the basis of this)
- current tty
[edit] Extra Notes
- The initial greeting recurs if the '$msg' variable is non-empty. It is echoed to the screen, then the prompt cleared to a new line with a refresh after only 1second.
- All "live" updates are at a 20 second refresh rate. Live updating also ensures that an abandoned prompt will keep-alive a remote shell over dodgy NAT :)
- The first prompt after any command always shows time with seconds, and does NOT show TTY or battery. They appear only after the first refresh
[edit] 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 ?
- moving the vcs_info to replace the host:path element, since within a vcs, it's often a different command namespace.
- per-host auto-colourisation
- note comment from screwtape: http://identi.ca/conversation/31704527#notice-31817077
- active group when not default
[edit] 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 :)
- count of subshells
- http://www.facebook.com/#!/nemothorx?v=wall&story_fbid=121814377837169&ref=mf
- Free disk, highest mem and CPU process, length of current prompt! -- Norgus
- current Dow, weather and TV listings -- Julian
[edit] Configuration
My current prompt config is findable here:
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.