How to remove color from zsh ls? - macos

I met some problems when configure zsh with oh-my-zsh on MAC OSX.
When I type 'ls -l' command, some of the output is blue. I don't know where it's from. I didn't set anything like this:
I guess is it from $CLICOLOR, when I 'echo $CLICOLOR' ,it returns 1. While I didn't find where to modify it.
And by the way, how to customize the color of ls output when using zsh? I tried environment variable like $LSCOLORS in ~/.zshrc which does not work.
Playing with zsh is quiet different from bash and I'm new to zsh. Hope somebody can help me with that. Thanks a lot.

Problem is solved, but I still want to tell some difference between CLICOLOR and 'ls -G' after I tried them many times.
The problem I presented could be raised by both 'CLICOLOR' and 'ls -G' on MAC. If
export CLICOLOR = 1
is added to ~/.bashrc or ~/.zshrc, it means you allowed to use
export LSCOLOR = 'blabla'
to define the colors of ls command. This is independent to 'ls -G', which can also highlight 'ls' output but you cannot customize the color of it. (perhaps there is a not known way you can).
So try both when you meet this problem.

Related

Why does Fish shell have dark blue as the default color for directories

Is it just me?
I have just installed fish using brew install fish and I'm using iTerm2.
The color is absolutely unreadable. How do I change it to something nicer?
I realized my mistake was with iTerm and not with Fish.
Press CMD+i with an iTerm window open, then click the Colors tab and set it something nicer.
Not sure why this problem didn't show up before, but it seems like it was triggered by the new Fish installation.
Technically that isn't fish doing the coloring. It's the ls command. However, fish does wrap the command in a ls function which tells the command to color the output and use the colors specified by the dircolors command if it is installed. If you don't want the coloring you can create your own ls function that omits the --color=auto flag. Or you can define your own $LS_COLORS env var to keep from using the colors provided by dircolors.
Just add alias ls="ls" to your ~/.config/fish/config.fish file.
if you don't have config.fish on your fish directory, create it!
This trick will change ls command's color to white.

zsh tab completion of directory stack not working

In cd -1, -2, -3 etc in Z shell it appears you can do cd -<tab> and cd +<tab> to do tab-completion of the directory stack. I think it's supposed to work out of the box on zsh?
However this doesn't work for me. I've even tried the suggestions in https://unix.stackexchange.com/a/157773 and that doesn't work either.
I'm using zsh 5.2 (x86_64-unknown-linux-gnu) on archlinux.
The output of setopt is
alwaystoend
autocd
autopushd
cdablevars
extendedhistory
histignorealldups
nohup
interactive
interactivecomments
monitor
nonomatch
promptsubst
pushdminus
shinstdin
zle
How can I make tab completion of the directory stack work?
So, I didn't realize this was a feature but when I tried it in a new tab, it didn't work for me either. But then, after I cd'd around a bit, the tab completion worked as expected. Maybe that's your only issue?
Also, as an alternative method, if you're not using the z plugin, you should check it out. It keeps a global history of all the directories you cd into so that in the future you only have to type a small part of the directory name to get back to it.

Aliases in .bash_profile not working properly [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I have been trying to alter the .bash_profile that is in my root directory, but have been running into some problems. I am on OS X, Yosemite, on a Macbook Pro. As I understand it, the .bash_profile file contains the script that is called automatically whenever the Terminal app is opened and the bash shell starts.
This is what I currently have written in that file:
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
This works perfectly fine. However, I want to add an alias (right underneath the above two lines) as follows:
alias test='cd ..'
However, when I save this and start up the Terminal, I get the following message:
-bash: alias: ..": not found
Replacing the single quotes with double quotes doesn't help, nor does taking them away altogether. Curiously however, the following alias works:
alias c=clear
When I type c into the terminal, it clear the screen, as you would expect. However, if I instead entered this line with quotes in the bash profile as:
alias c='clear'
Then I will get the following whenever I enter c into the Terminal:
-bash: 'clear': command not found
Note that I do not get an error message on startup for this alias.
What am I doing wrong? Is there a setting I need to change somewhere to get aliases to work properly? I have seen previous examples of aliases and they simply do not work for me.
It looks like shell is not accessing your .bash_profile when logging via terminal.
.bash_profile is a config file of bash shell. When bash shell starting, shell will execute the commands in .bash_profile. But there are many kinds of shells, and different shells execute different config file.
Terminal is a software to receive user input, shell will execute commands.You can use cat /etc/shells to list acceptable shells. For example:
$ cat /etc/shells
/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
The default shell is bash shell on Mac OX. But if you have installed zsh, the default shell is zsh, when zsh shell starting, shell will find out the file named .zshrc, and execute the commands in .zshrc.
You can use echo $SHELL to determine the current shell:
$ echo $SHELL
/bin/bash
-> echo $SHELL
/bin/zsh
If your default shell is zsh, .bash_profile don't work. The config file of zsh is .zshrc. And I guess your problem is that your default shell is not bash shell. For example, if your default shell is zsh, you should config the .zshrc , just add
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
or other config to ~/.zshrc.
Then source ~/.zshrc, and the config will work immediately.
Wrapping the command with double quotation worked for me. I was trying with every possible way mentioned in this thread and none of them worked. Then I replaced single quote to double and that worked.
alias mysql_start="sudo /path/to/server/mysql.server start"
For me, it didn't work in the same terminal. I had to open a new one to get it work.
The killer for me was space and single quotes.
alias test="cd .." worked.
Don't put any spaces between alias_name=
User level 'system' files need to contain 'plain text'. How to set/configure this for your 'editor-of-choice' can vary (I don't use a Mac so I'm not much help with that.) Soo,
create your profile 'from the shell' by appending lines directly, i.e. remove the 'bad lines and then:
echo "some command string" >> ~/path/bash_profile
use 'vi' or 'vim' ## should be 'safe'
review your file via:
cat -v ~/path/bash_profle | more ## see any 'funny chars'? or
cat -ve ~/path/bash_profle | more ## see any 'funny chars'? or
or
vi ~/path/bash_profle # then set 'control codes' to 'on'
set list ## see any 'funny chars' for your 'quotes'?
What I realised is that Mac has option for smart quotes and dashes.
alias ..='cd ../' is different from alias ..=‘cd ../‘, where the former works but the latter doesn't.
You can run alias custom auto startup in ~/.bash_profile or ~/.alias_file... by paste file name alias in ~/.bashrc if you use bash or ~/.zshrc if you use zsh.
Ex:
if [ -s ~/.bash_profile ]; then
source ~/.bash_profile;
fi
I fixed this by editing my .bash_profile in vim or nano something about text edited messed it up unsure why.
I tried to edit in in notepad just using "open .bash_profile" however something about the symbols translated wrong. So you have to either "vim .bash_profile" or "nano .bash_profile"
Doing this corrected this problem for me.
Make sure that the alias commands are together in the .bash_profile too. That is what was wrong with mine.
Also, if you just type in alias in the terminal, it should list all the known alias commands, so if you don't see your command you know something is wrong.
If alias is not recognizing, first identify what shell you're using when you open up your terminal or commandlineprompt echo $SHELL. For me it's /bin/bash so i'll input my aliases in ~/.bash_profile
Take note, the file ~/.bash_profile can store both aliases to call out during a terminal session and autorun those same aliases upon opening up a terminal session. The example below would be to open up a file to edit by text via vim-software. You may change it other text-editors as you wish. You can see the difference by closure-method.
ALIAS CALLOUT (uses parenthesis)
alias editbp="vim ~/.bash_profile"
ALIAS AUTORUN (uses tilda)
alias editbp=`vim ~/.bash_profile`

tcsh 'ls_colors' not working

I am using tcsh as my default shell. However, the LS_COLORS env doesn't seem to work. Here is my related env for ls:
setenv CLICOLOR "true"
setenv LS_COLORS "di=37:fi=00"
Directories are suposed to be coloured white, but the result is they are coloured blue/cyan. Any idea?
I was having the same problem. I am required to use tcsh and xterm. I also didn't have luck with setenv CLICOLOR.
try:
alias ls ls --color=always
source: ls man page
This thread on the web might help on the syntax of LS_COLORS in general.
In your particular case it looks ok. Did you set color in your shell?

Messed up my path in Zsh?

I'm trying out zsh as an alternative to bash, and I seem to have messed up my system path on my MacBook Air. Here's the path I have in my .zshrc:
export PATH=/usr/local/bin:/usr/local/sbin/:usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin
Some commands like vim work properly, but standards like ls and sed are returning errors like the following:
zsh: command not found: ls
I'm pretty sure it's not just a zsh problem, as launching a bash terminal produces similar results.
It seems like I'm missing an important directory in there somewhere. Any suggestions?
export PATH=/usr/local/bin:/usr/local/sbin/:usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin
there is a / missing in-front of usr/bin
so it should be
export PATH=/usr/local/bin:/usr/local/sbin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin
maybe this solves your problem.

Resources