37 ms·
local green="$(tput setaf 2)" local reset="$(tput sgr0)" export PS1="\[$green\]>>\[$reset\] " Could be this in zsh: export PS1="%{%F{green}%}>>%{%f%} "
by pyre 14y ago
local green="$(tput setaf 2)"
local reset="$(tput sgr0)"
export PS1="\[$green\]>>\[$reset\] "
Could be this in zsh:
export PS1="%{%F{green}%}>>%{%f%} "
- %{%} replace \[\]
- %F{color} sets the foreground colour
- %f resets the foreground colour
I would go with something like:
export PS1="%{%(?.%F{green}.%F{red})%}>>%{%f%} "
It will be green if the last command exiting successfully, otherwise it will be red.
There's also better history support (from my zsh config):
# History
# ~~~~~~~
HISTSIZE=1000
SAVEHIST=1000
HISTFILE=$HOME/.zsh_history
setopt SHARE_HISTORY # Share history across sessions
setopt HIST_IGNORE_SPACE # commands starting w/ a space don't go into history
# SHARE_HISTORY seems to imply both of these, at least that's how the manpage
# reads, so let's comment them out for now.
#
# setopt INC_APPEND_HISTORY # Incrementally append history to file
# setopt EXTENDED_HISTORY # Save the timestamp and duration of commands to history file
- hk__2 14y agoActually, except the `SHARE_HISTORY` option (which can be emulated), everything else is available in Bash.
- pyre 14y agoSorry, I just copy-pasted the whole thing. I know that most of the other options are available, though I didn't know that the HIST_IGNORE_SPACE was available in bash.
- mnarayan01 14y agoIn bash you'd use HISTCONTROL=ignorespace
- pyre 14y agoAccording to the manpage, ignorespace doesn't treat multi-line commands very nicely.
- mnarayan01 14y agoYou would have to disable the cmdhist option for that to matter: shopt -u cmdhist Or I guess be working with a bash old enough to not support cmdhist.
- sliverstorm 14y agoActually, I just tried the foreground/background stuff (similar to yours, but my own code, slightly different) and it works fine in bash 4.
- pyre 14y agoI'm unclear what you mean by foreground/background stuff. I'm looking at the manpage for bash 4.2, and I don't see any short-hand for the color escape codes in prompts.