20

I'm a complete newbie, so I think I'm just missing a step, but have no idea.

I'm following tutorials for Rails. Lots of steps say, "and then editing the ~/.zshrc file." but I don't have any ~/.zshrc file. I'm looking at the folders in Sublime. Also none of the following ~/.zprofile, ~/.zlogin, ~/.zlogout exist. Though, under my home files, there is .zprezto folder. No zshenv either...

Do I just create the files? Seems like they should be downloaded from somewhere. I'm using Terminal with OS X. So lost.

echo 'write whatever' >.zshrc

Thanks in advance!

alex
  • 479,566
  • 201
  • 878
  • 984
k.Rox
  • 211
  • 1
  • 2
  • 4
  • do you have the sources of these tutorials? – maniacalrobot Mar 22 '16 at 15:10
  • 1
    Are you actually using `zsh`? You can check by opening a terminal and running the command `echo $0 $ZSH_VERSION`. If you are using `zsh` this should output something like "`/bin/zsh 5.0.2`". If it just says "`/bin/bash `" you are in fact using `bash`, the default shell in OS X, and adding anything to `~/.zshrc` will have no effect. Unless it uses commands, syntax or options that work only in zsh, you probably could add it to `~/.bashrc` instead. – Adaephon Mar 23 '16 at 07:51

6 Answers6

34

You will get ~/.zshrc file only when you use zsh shell on your Mac OS. If you're not sure which shell you're using, open terminal and issue the following command.

echo $SHELL

if you get response like /bin/zsh then you're using zsh shell on your Mac. You can edit ~/.zshrc file using vim editor on your Mac which is the default for Mac OS.

to open ~/.zshrc file using vim editor, issue the following command on your terminal.

vim ~/.zshrc

Then you can do any configurations you need. Or else you can use open -t .zshrc command to open ~/.zshrc file from your general TextEdit on Mac OS.

Kalhara Tennakoon
  • 1,302
  • 14
  • 20
26
  1. $ open ~/.zshrc
  2. Make changes in the .zshrc file window that opens
  3. Save file
  4. $ source ~/.zshrc
Gwen Au
  • 859
  • 9
  • 10
4

The .zshrc file is used to configure your terminal prompt if you're using zsh (z-shell) login shell (n.b., a "login shell" is the command line presented to you when running the terminal application). If you're using a standard OSX terminal, then you're probably using bash (the BASH Shell), so editing .zshrc wouldn't affect anything. Bash uses .bashrc and .bash_profile` for it's configuration. These file are run overtime you open terminal window and setup things the command aliases, setup your prompt and maybe run scripts to initial other programs.

You almost certainly don't need to edit terminal config files to develop with Ruby on Rails, especially as editing these files incorrectly can mess up your system, or at least make it hard to return the system to a stable state.

maniacalrobot
  • 2,413
  • 2
  • 18
  • 20
  • Update: In 2019, Starting with macOS Catalina, Mac began using zsh as the default login shell and interactive shell. source: https://support.apple.com/en-us/HT208050 – Mark Gavagan Aug 09 '21 at 20:49
2

I usually use the vi(vim) editor to edit the .zshrc file.

1)To open ~/.zshrc

vi .zshrc
or
vi ~/.zshrc
or
You can open the file in VsCode, and it would be easier to edit it.
code .zshrc

2)To update the edited .zshrc file:

source ~/.zshrc
or
source .zshrc

ArAsH
  • 122
  • 10
0

If you are using zsh shell , run the below lines in the terminal:

echo 'setopt PROMPT_CR' >.zshrc

echo 'setopt PROMPT_SP' >.zshrc

echo 'export PROMPT_EOL_MARK=""' >.zshrc

zikadow
  • 1
  • 1
0

You can edit zshenv instead of zshrc for appending PATH . Please check whether file already exists

cat ~/.zshevn

You can edit file using below command

vi ~/.zshenv

You can refer this to see how to add an entry in PATH

GPopat
  • 445
  • 4
  • 14