Editing the ~/.zshrc file
Asked Answered
T

6

23

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!

Tolerable answered 22/3, 2016 at 14:50 Comment(2)
do you have the sources of these tutorials?Oxonian
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.Demonolater
L
37

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.

Lilla answered 21/5, 2020 at 5:3 Comment(0)
E
31
  1. $ open ~/.zshrc
  2. Make changes in the .zshrc file window that opens
  3. Save file
  4. $ source ~/.zshrc
Ethno answered 3/11, 2021 at 0:46 Comment(1)
This is much easier.Drucill
O
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.

Oxonian answered 22/3, 2016 at 15:9 Comment(1)
Update: In 2019, Starting with macOS Catalina, Mac began using zsh as the default login shell and interactive shell. source: support.apple.com/en-us/HT208050Romulus
V
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

Venepuncture answered 5/10, 2022 at 0:26 Comment(0)
J
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

Janeenjanek answered 29/8, 2021 at 16:48 Comment(0)
D
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

Dorsum answered 29/12, 2021 at 7:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.