I wanted to make custom colors for the ls command with zsh, but I find that all the previous answers to this do not work for me.  I tried all these options:  Option 1)  #LS_COLORS='no=00;37:fi=00:di=00;33:ln=04;36:pi=40;33:so=01;35:bd=40;33;01:' #export LS_COLORS #zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}   Option 2)  #LS_COLORS='di=1:fi=96:*.m=31:*.py=32:*.txt=36:*.out=35' #export LS_COLORS #zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}    Option 3)  #zstyle ':completiom:*' list-colors 'di=1:fi=96:*.m=31:*.py=32:*.txt=36:*.out=35'   Option 4)  #zstyle ':completion:*' list-colors 'di=34:ln=35:so=32:pi=33:ex=31:bd=46;34:cd=43;34:su=41;30:sg=46;30:tw=42;30:ow=43;30'   but all result of the ls command are displayed as if no color option was turned on.  The only thing that seems to work to change the colors at all is this:  unset LSCOLORS export CLICOLOR=1 export CLICOLOR_FORCE=1   which I found from another answer somewhere that I can't find. However, what I want is to use my own custom colors indicated by:  #LS_COLORS='di=1:fi=96:*.m=31:*.py=32:*.txt=36:*.out=35'     Appendix   For completness I also saw someone suggest to use gls but I had issues brew installing it so I gave up on that. Sorry can't find the link to that anymore.     Cross posted:   reddit:  Quora:
120787
I know that a similar question has been asked in:        although I didn't really understand the answer and couldn't really make it work.  However, I have tried something different. I decided to read the manual page for ls and it mentions different environment variables that can be set when dealing with the ls command. If one goes to the -G option it says to look at the CLICOLOR environment variables. I did and that one links you to documentation for the LSCOLORS environment variable. I went to it and it mentions:     "The value of this variable describes what color to use for which attribute when colors are enabled with CLICOLOR. This string is a concatenation of pairs of the format fb, where f is the foreground color and b is the background color. "   It also mentions that the default value of LSCOLORS is "exfxcxdxbxegedabagacad" and that each part specifies the color of some specific thing in the ls command. For example, the first pair ex in example specifies the color of directories. the second fx the color of symbolic links etc... e means blue and x means default "foreground".  1) First what does this mean: "when colors are enabled with CLICOLOR"?  2) What does "foreground" mean?  What must environment variables be for the ls command to color the output however I desire?    I also tried:  ls --color   But it threw me the following error:  ls: illegal option -- - usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]   The same error happened when I did ls --color=auto: it alone also throws an error. I have no idea why, and am not sure if it was due to iTerm2 or OS X or why that happened. It seems it works on other systems...
11530
I want to set my path (and some other environment variables) based on a certain directory, so I have the following file in my home directory  export MY_DIR="/path/to/dir" export PATH=$MY_DIR/bin:$PATH export MY_OTHER_VAR="$MY_DIR/folder"   I source that in my ~/.zshrc with the following line: [[ -e ~/my_file.sh ]] &amp;&amp; emulate sh -c ' source ~/my_file.sh  However, when I log in, $MY_DIR/bin is not in my path. If I echo $PATH, I get %F{51}~%f where $MY_DIR/bin should be. However, both MY_DIR and MY_OTHER_VAR were set correctly.  Have I done something wrong, or is this some weird bug in zsh (it seems to work as expected with bash)?  Edit  I have used both source and ~ elsewhere in my zshrc without issue. However, I tried moving the file to /etc/zsh/my_file.sh and sourcing it from etc/zsh/zprofile. I also tried using . rather than source, but even with those changes, I still see the same %F{51}~%f in my path variable. Actually, I've noticed that I see whatever my current directory is in the PATH variable, so for example, if I navigate to /etc/zsh/ and echo $PATH, I see %F{51}/etc/zsh%f.  Full code to reproduce:  /etc/zsh/zprofile:  [[ -e /etc/zsh/my_file.sh ]] &amp;&amp; emulate sh -c ' . /etc/zsh/my_file.sh'   /etc/zsh/my_file.sh:  export MY_DIR="/home/matt/code" export PATH="$MY_DIR/bin:$PATH" export MY_PYTHON="$MY_DIR/python"   EDIT 2  So I am using a custom prompt which prints my current path in cyan. If I disable that prompt, my PATH variable gets set properly. In the script for the prompt, I use a variable that I call path (lowercase). Apparently, while bash doesn't confuse it with PATH, zsh does. Thanks to all for the help.
88156
I want to view (and/or edit) colorized text in emacs, such as is output by ls -l --color=always, tree..., or whatever.   The text I refer to exists in a file. When I open that file in emacs, I want to be able to see it colorized, or toggle it to show ANSI (SGR) escape sequences.     ansi-color.el seems be be what I need, but I haven't been able to get it to do any colorizing of the ANSi escape sequences, but I do see blue-bold for individual contol bytes (eg. ^A and ^[)... I'm not sure if that is a feature of ansi-color, but I think it is.       According to the , it can work with strings and regions, but even that doesn't seem to work.. For example the function ansi-color-apply-on-region is not recognized by M-x. It says, "No match"     I've added (require 'ansi-color) to my .emacs file and even (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on). I get no error or warning when emacs starts, so I'm stuck.        How can I get the standard functions to work, and can it be made to automatically apply when opening a file whose name is suffixed with .col?
82592
\documentclass{article} \usepackage{listings} \usepackage{color} \begin{document} \definecolor{light-gray}{gray}{0.95} \lstset{basicstyle=\ttfamily\footnotesize,     backgroundcolor=\color{light-gray}, xleftmargin=0.7cm,     frame=tlbr, framesep=0.2cm, framerule=0pt,   } \begin{lstlisting}[mathescape] k = $\lfloor (10\log n \cdot \log\log n)^{1/3} \rfloor$; k = $\lfloor (4\log n \cdot \log n)^{1/3} \rfloor$; \end{lstlisting} \end{document}   produces    An answer to a similar question said that "this line is just an artifact of the viewer". But this line appears in two viewers and various zoom steps. On top of that, one can clearly see that the 1/3 overlaps with the white line. So I do not accept it as a mere artifact anymore.  How could this problem be approached? Is it possible to somehow put another grey layer underneath the lstlisting environment which would "eat up" any white lines?  edit: Is there a solution that would not involve editing every line of the code?
43483
Few years ago, I changed color scheme of command prompt. Now, I have forgotten how exactly I did this.   It's permanent. So, COLOR command is out of question. It's intact no matter from where I launch cmd. So, changing color from shortcut properties is out of question because I get the color scheme even when I launch cmd from Run or from original location. It doesn't let me override it by shortcut properties. And, this is the problem. I create a cmd shortcut and change its color scheme from properties. But, this isn't reflected even after reboot.   So, the only option I have left: Use the same method I used few years ago. How did I change cmd color?
31135
I'm currently logged into a server via ssh with ssh -Y and running a tmux session. If I start vim and run :colorscheme elflord the color scheme is changed. (Although the colors are not exactly what I would expect although they are I think 256 color. If I create a ~/.vimrc file and put a single line colorscheme elflord  in it then when I run vim it shows no color (just white text) and I cannot change the color with the :colorscheme command.
21636
There are two directories shown by 'ls'.  Normally directories anywhere are blue on black background.  But the first one is blue on green and impossible to read.  Why is this?  How to make it blue on black, or at least something light on something dark?  This is on Ubuntu 12.04, using bash in Gnome Terminal.  In Konsole, the blue is slightly darker, and possible to read, though could be way better.
122736
I'm a bit new to bash scripting, and I'm wondering if there is a program or built-in command to pipe to that will print in a specified color? Or is there an echo argument to do so?  Like I could do:  echo Hi | commandhere -arguement blue   and it would print "Hi" in the color blue?
31667
Currently ZSH displays a menu when I first hit tab and the completion is ambiguous. So, if I have 'cd ' in the command prompt and I hit tab, it will show the different available completions. If I hit tab again, it will select the first available completion.   I would like to merge these two steps into a single press of the tab key. So, if I'm at 'cd ' and I tab, I would like ZSH to insert the first available match (when ambiguous) and display the menu, which I can then tab through if the first match wasn't the directory I had in mind.  The ZSH setup tool put this in my .zshrc, in case any of this is affecting the behavior of my shell:   zstyle ':completion:*' completer _expand _complete _ignored zstyle ':completion:*' list-colors '' zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' '' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' zstyle ':completion:*' menu select=5 zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s zstyle :compinstall filename '/home/robb/.zshrc'
48952
With PowerShell 5.0, there are lot of customization options. Presently I have created my own color scheme. But I couldn't figure it out how to set these color options permanently.  Set-PSReadlineOption -TokenKind Operator -ForegroundColor "Magenta" Set-PSReadlineOption -TokenKind Command -ForegroundColor "DarkYellow" Set-PSReadlineOption -TokenKind Parameter -ForegroundColor "Magenta"   Now I kept these commands in Profile script, so that they will be loaded automatically, however it doesn't work in all cases when the shell is reset and if I want to load another Profile. Irrespective of profiles, the background color and other options which are available in PowerShell UI remain consistent. I want the same thing.  How do I permanently set these color options for PowerShell Console.
26646
I need  to use the less command with the syntax highlighting of the vim command for python, C, bash and other languages.  How do I apply syntax highlighting colors according to vim colors for less command?
110221
I've actually a problem with my document.  I redefined the listing for my ruby code:  \usepackage{listings} \renewcommand\lstlistingname{Quellcode} \lstloadlanguages{Ruby} \lstset{% basicstyle=\small\ttfamily\color{black}, commentstyle = \ttfamily\color{red}, keywordstyle=\ttfamily\color{blue}, stringstyle=\color{orange}, backgroundcolor=\color{grey}, columns=fullflexible}  \DeclareCaptionFont{white}{\color{white}} \DeclareCaptionFormat{listing}{\colorbox{gray}{\parbox{\textwidth}{#1#2#3}}} \captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white}   And redefined the lstlistoflistings.  \renewcommand\lstlistlistingname{Quellcodeverzeichnis}  \addcontentsline{toc}{section}{Quellcodeverzeichnis}  \lstlistoflistings  \newpage   But the lstlistoflistings isn't showing the name, only the number of the lst.  Here is the actually lstlistoflistings:    Can anyone help me and show me how I can get the lstlistingname (Quellcode)  in every line of lstlistoflistings?  Thanks  UPDATE:  Here a MWE:  \documentclass[12pt, a4paper, oneside]{scrartcl}  \usepackage[utf8]{inputenc} \usepackage{textcomp} \usepackage[ngerman]{babel} \usepackage[hidelinks=true]{hyperref} \usepackage[final]{pdfpages}  \definecolor{grey}{gray}{0.9}  \usepackage{listings} \renewcommand\lstlistingname{Quellcode-Ausschnitt} \lstloadlanguages{Ruby} \lstset{% basicstyle=\small\ttfamily\color{black}, commentstyle = \ttfamily\color{red}, keywordstyle=\ttfamily\color{blue}, stringstyle=\color{orange}, backgroundcolor=\color{grey}, columns=fullflexible}  \usepackage{color} \usepackage{xcolor}  \usepackage{caption} \DeclareCaptionFont{white}{\color{white}} \DeclareCaptionFormat{listing}{\colorbox{gray}{\parbox{\textwidth}{#1#2#3}}} \captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white}  \usepackage{geometry} \geometry{a4paper, top=25mm, left=25mm, right=25mm, bottom=20mm, headsep=10mm, footskip=12mm}  \begin{document}   \renewcommand\lstlistlistingname{Quellcodeverzeichnis}  \addcontentsline{toc}{section}{Quellcodeverzeichnis}  \lstlistoflistings  \newpage    \begin{lstlisting}[language=Ruby, caption=StatusCalculator Initialize, label=initialize]   def initialize(project_id)     @project = Project.find(project_id)   end   \end{lstlisting}  \end{document}
105906
I have a custom PS1 colour where I have the actual shell commands in a distinct colour, just so I can quickly see what commands I typed and separate it from the command output itself.  Suppose the colour in PS1 is set to 'blue' for command prompt and the default colour in my shell is white.    I type a command e.g. ls, (ls -l is coloured blue) The output it generates, first line is still blue All remaining line comes as white   What I want is all the output after the command to be 'white'.  Another example:   I type a command 'cat ', colour is blue The output comes, the whole output is blue   I would like the output to be 'white' while keeping the command prompt I typed 'blue'  On some commands, it is fine, other commands, the same colour overflows into the first line of the output and then the default colour kicks in and some other commands, the whole output (e.g. cat) has the same colour.   Is there a way to keep just the commands I typed in one colour and the rest to the default?  I'm on OSX.  EDIT #1  Here's a screenshot that @derobert's linked to in the comments that shows what I'm looking for.  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
17757
It might be useful to allow comments in zsh commands written on the command line, as in bash, but  % echo test # test zsh: bad pattern: #   Any way to get the same behaviour as in the bash shell?
87833
I switched to zsh completely on a previous arch install and I LOVED it mainly because arch is one of the distros that capitalizes your Documents, Downloads, Music and such directories in your ~ directory. Since I wasn't used to that and I use tab completion for almost everything in the terminal zsh was like heaven for me compared to bash.... I swear this feature used to be active automatically because I don't remember having to tweak anything to make it work that way. I probably figured it out on accident. xD But I would greatly like to have this feature restored on my new pc using zsh as my main shell, and if anyone knows how to do this I would really appreciate a reply. I tried activating every option in the completion configuration and that didn't seem to do the trick... so that brought me here. PS: I used to be a lot more up to date with my Linux know-how, and my knowledge has grown stale... I'm trying to remedy that... (without the use of the shift key, as much as possible... haha)
75076
Following on from  about stripping newlines out of text, I want to turn this into a zsh alias as follows:  alias striplines=' awk " /^$/ {print \"\n\"; } /./ {printf( \" %s \",$0);}"'   I've tried escaping the quotes inside the awk script, but I'm getting this error:  awk: (FILENAME=bspsrobustness FNR=1) fatal: division by zero attempted   (The file is called bspsrobustness)  Is there a way to do what I want? I suppose I could turn this into an awk script rather than a zsh alias, is that my best option?
47349
Sometimes when I simply type a valid command like 'find ...', or anything really, I get back the following, which is completely unexpected and confusing (... is command name I type): sh: $'\302\211...': command not found  There is some corruption going on I think. I don't use color in my prompt, I am using the Bash shell in POSIX mode as sh (chsh to /bin/sh and so on - $SHELL is sh). What is going on and why does this keep happening? Anything I can debug? I think this is more of an xterm issue than sh, or at least a combination of the two. Files, for context: My /etc/profile, as distributed with Arch Linux x86-64: # /etc/profile  #Set our umask umask 022  # Set our default path PATH=&quot;/usr/local/sbin:/usr/local/bin:/usr/bin&quot; export PATH  # Load profiles from /etc/profile.d if test -d /etc/profile.d/; then         for profile in /etc/profile.d/*.sh; do                 test -r &quot;$profile&quot; &amp;&amp; . &quot;$profile&quot;         done         unset profile fi  # Source global bash config if test &quot;$PS1&quot; &amp;&amp; test &quot;$BASH&quot; &amp;&amp; test -r /etc/bash.bashrc; then         . /etc/bash.bashrc fi  # Termcap is outdated, old, and crusty, kill it. unset TERMCAP  # Man is much better than us at figuring this out unset MANPATH  My /etc/shrc follows below. It's something I created as a way to have sh parse some file on startup, for a non-login shell; it is achieved using ENV variable set in /etc/environment with the line ENV=/etc/shrc: PS1='\u@\H \w \$ ' alias ls='ls -F --color' alias grep='grep -i --color' [ -f ~/.shrc ] &amp;&amp; . ~/.shrc  My ~/.profile, I am launching X when logging in through first virtual tty: [[ -z $DISPLAY &amp;&amp; $XDG_VTNR -eq 1 ]] &amp;&amp; exec xinit -- -dpi 111  My ~/.xinitc, as you can see I am using the system as a Virtual Box guest: xrdb -merge ~/.Xresources  VBoxClient-all  awesome &amp;  exec xterm  And finally, my ~/.Xresources, no fancy stuff here I guess: *faceName: Inconsolata *faceSize: 10 xterm*VT100*translations: #override &lt;Btn1Up&gt;: select-end(PRIMARY, CLIPBOARD, CUT_BUFFER0)  xterm*colorBDMode: true xterm*colorBD: #ff8000 xterm*cursorColor: S_red  Since ~/.profile references among other things /etc/bash.bashrc, here is its content: # # /etc/bash.bashrc #  # If not running interactively, don't do anything [[ $- != *i* ]] &amp;&amp; return  PS1='[\u@\h \W]\$ ' PS2='&gt; ' PS3='&gt; ' PS4='+ '  case ${TERM} in   xterm*|rxvt*|Eterm|aterm|kterm|gnome*)     PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf &quot;\033]0;%s@%s:%s\007&quot; &quot;${USER}&quot; &quot;${HOSTNAME%%.*}&quot; &quot;${PWD/#$HOME/~}&quot;'                                                              ;;   screen)     PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf &quot;\033_%s@%s:%s\033\\&quot; &quot;${USER}&quot; &quot;${HOSTNAME%%.*}&quot; &quot;${PWD/#$HOME/~}&quot;'     ;; esac  [ -r /usr/share/bash-completion/bash_completion   ] &amp;&amp; . /usr/share/bash-completion/bash_completion  I have no idea what that case statement does, by the way, it does look a bit suspicious though, but then again, who am I to know.