Monday, February 23, 2015

set up color prompt in csh tcsh on FreeBSD

# vim ~/.cshrc

  set colorRed = "%{\033[0;31m%}"
  set colorGreen = "%{\033[0;32m%}"
  set colorGreenBold = "%{\033[1;32m%}"
  set colorYellow = "%{\033[0;33m%}"
  set colorBlue = "%{\033[0;34m%}"
  set colorMagenta = "%{\033[0;35m%}"
  set colorCyan = "%{\033[0;36m%}"
  set colorWhite = "%{\033[0;37m%}"
  set colorEnd = "%{\033[0m%}" # This is needed at the end.

  ### default prompt
  #set prompt = "%n@%m:%/ %# "

  ### color prompt
  set prompt = "${colorBlue}%n${colorCyan}@%m ${colorCyan}%/ %#${colorEnd} "

  set promptchars = "%#"

  # Clean up after ourselves...
  unset colorRed colorGreen colorGreenBold colorYellow colorBlue colorMagenta colorCyan colorWhite colorEnd

%n
  The username.

%m
  The hostname up to the first . dot.

%/
  The current working directory.

%~
  The current working directory, but with one's home directory represented by `~' and other users' home directories represented by `~user' as per Filename substitution. `~user' substi- tution happens only if the shell has already used `~user' in a pathname in the current ses- sion.

%#
  A `#' if the shell is running  with  privileges,  a `%' if not.

Reference:
http://www.cs.umd.edu/~srhuang/teaching/code_snippets/prompt_color.tcsh.html
http://www.nparikh.org/unix/prompt.php

No comments: