![]() ![]() If something is stuck outputting colour when you don't want it to, I use this sed line to strip the escape sequences: sed "s/\*//gi" (For best results, also use alias clear="echo -e '\e[2J\n\n'".) Puts a bar at the top of your terminal with some random info. You can set your PS1 (shell prompt) to use colours. ![]() If you use -color=always, it'll use colour even when piping, which confuses things.Ĭolors specified by: export LS_COLORS='rs=0:di=01 34:ln=01 36:mh=00:pi=40 33' You can also use export GREP_OPTIONS='-color=auto' to make it persistent without an alias. You can also syntax highlight code on the terminal by using Pygments as a command-line tool. bashrc and answer my own question Jeopardy Style.Ī lot of editors have syntax highlighting support. For example: alias less='less -RAW-CONTROL-CHARS' These commands seem to use the standard " ANSI escape sequences". Use color for some Unix commands ( ls, grep, less, vim) and the Bash prompt. Instead, I tweak my terminal's color configuration. Many OSs set things like dircolors and by default, and I don't want to modify this on a hundred different hosts.I do a bunch of work using GNU screen, which adds another layer of fun.I'm trying to keep things simple and generic, if possible. I use everything from macOS X, Ubuntu Linux, RHEL/CentOS/Scientific Linux and FreeBSD. I work on a number of different hosts, different OS versions, etc.I tend to set TERM=xterm-color, which is supported on most hosts (but not all).Here are some tips from my setup, after a lot of experimentation: Unfortunately, support for color varies depending on terminal type, OS, TERM setting, utility, buggy implementations, etc. What options exist to add color to my terminal environment? What tricks do you use? What pitfalls have you encountered? ![]() I try to use color on the command line, because color makes the output more useful and intuitive. In addition to colors, my prompt has a few other features, such as abbreviated directory names (see the function bash_prompt_shortener), automatic display of the last command's exit status if nonzero (function checkExitStatus), and display of the time in the rightmost columns (function print_prompt_time).I spend most of my time working in Unix environments and using terminal emulators. Now you can display the complete directory path without problem, and it makes it more clear where a new command starts, in case of long output.Īnother update, as ZSH is now the default shell on Macos. It adds a newline after the prompt, and an empty newline before. I use different format for my local computer: export \t \\\w\\ > \" Server root: export \\\t\\ \W]\\$ \"Īnd if needed you can change hostname color to reflect different type of servers. With the generated code you can change the colors yourself. I've noticed that the colors defined here may be different from your own system, but that's a small issue. This is by far the easiest way to get a prompt like you want. For example, lets change the user to purple, the to black and host to green. Pay attention at the part it is saying and the number before it \ indicates the color. Look for the line below if then that should looks like: ' Look for the line with #force_color_prompt=yes and uncomment (delete the #). ![]() You can edit the settings editing the file: ~/.bashrc. ![]()
0 Comments
Leave a Reply. |