diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-12-19 17:36:19 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-12-19 17:36:19 +1300 |
commit | afce604605df4a91b4ebbf548812f147c1d235ed (patch) | |
tree | b1d44f171e5d582284e7eb607635e6897f9f2254 /ksh/kshrc.d | |
parent | Allow .gz completion for text fns, but not .tar.gz (diff) | |
download | dotfiles-afce604605df4a91b4ebbf548812f147c1d235ed.tar.gz dotfiles-afce604605df4a91b4ebbf548812f147c1d235ed.zip |
Attempt at properly escaping non-printing chars
This is supposed to be the equivalent of \[ \] in Bash PS1...
>Note that since the command line editors try to figure out how long the
>prompt is (so they know how far it is to edge of the screen), escape
>codes in the prompt tend to mess things up. You can tell the shell not
>to count certain sequences (such as escape codes) by prefixing your
>prompt with a non-printing char- acter (such as control-A) followed by
>a carriage return and then delimiting the escape codes with this
>non-printing character. If you don't have any non-printing characters,
>you're out of luck... BTW, don't blame me for this hack; it's in the
>original ksh.
<http://blog.0xpebbles.org/ksh-prompt-coloring-example>
Diffstat (limited to 'ksh/kshrc.d')
-rw-r--r-- | ksh/kshrc.d/prompt.ksh | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/ksh/kshrc.d/prompt.ksh b/ksh/kshrc.d/prompt.ksh index 8b460136..2ebe1099 100644 --- a/ksh/kshrc.d/prompt.ksh +++ b/ksh/kshrc.d/prompt.ksh @@ -81,8 +81,13 @@ function prompt { } >/dev/null 2>&1 + # Play ball with ksh's way of escaping non-printing characters + typeset es nl + es=$(printf '\00') + nl=$(printf '\n') + # String it all together - PS1="${format}${PS1}${reset}"' ' + PS1="${es}${nl}${es}${format}${es}${PS1}${es}${reset}${es}"' ' PS2='> ' PS3='? ' PS4='+<$?> $LINENO:' |