tmux
I followed Getting 256 colors to work in tmux:
- I have
alias tmux='TERM=xterm-256color tmux'
in~/.bashrc
- and also
set-option -g default-terminal "screen-256color"
in~/.tmux.conf
In konsole
:
$ echo $TERM
xterm
In tmux
:
$ echo $TERM
screen-256color
Still colors doesn't work in tmux
:
boris@vasilisa:~$ PROMPT_GREEN=`tput setf 2`
boris@vasilisa:~$ PROMPT_RED=`tput setf 4`
boris@vasilisa:~$ PROMPT_BLACK=`tput setf 8`
boris@vasilisa:~$ PS1='\[$PROMPT_RED\]\w\[$PROMPT_GREEN\]:\[$PROMPT_BLACK\] '
Results in a black-and-white color prompt. Also no color with ls
.
screen
I have force_color_prompt=yes
in ~/.bashrc
. Still:
boris@vasilisa:~$ PROMPT_GREEN=`tput setf 2`
boris@vasilisa:~$ PROMPT_RED=`tput setf 4`
boris@vasilisa:~$ PROMPT_BLACK=`tput setf 8`
boris@vasilisa:~$ PS1='\[$PROMPT_RED\]\w\[$PROMPT_GREEN\]:\[$PROMPT_BLACK\] '
Doesn't make prompt colorful. But in contrast to tmux
-- ls
lists files with color.
So
I guess tput setf
just shouldn't work with terminal multiplexers?
Edit
I had to change setf
to setaf
, and also change the color codes:
PROMPT_BLACK=`tput setaf 0`
PROMPT_RED=`tput setaf 1`
PROMPT_GREEN=`tput setaf 2`
PS1='\[$PROMPT_RED\]\w\[$PROMPT_GREEN\]:\[$PROMPT_BLACK\] '
I don't need to aliase tmux
, setting
set-option -g default-terminal "screen-256color"
in ~/.tmux.conf
is suffice.
So I put
# colorful prompt
PROMPT_BLACK=`tput setaf 0`
PROMPT_RED=`tput setaf 1`
PROMPT_GREEN=`tput setaf 2`
PS1='\[$PROMPT_RED\]\w\[$PROMPT_GREEN\]:\[$PROMPT_BLACK\] '
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto --group-directories-first'
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# man pages with color!
export LESS_TERMCAP_mb=$'\E[01;31m'
export LESS_TERMCAP_md=$'\E[01;31m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;44;33m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;32m'
# enable colors:
force_color_prompt=yes
in both: ~/.bashrc
and ~/.bash_login
and then colors work in tmux
.