loading...

TIL about zshell startup

nirnaeth profile image Monica ・1 min read

Learning while Doing (4 Part Series)

1) TIL about tree 2) TIL about zshell startup 3) TIL about Ruby command line execution 4) TIL about testing commands

This is a walk-with-me-while-I-do-things series, I'm going to tell you what I learned while I'm learning

You might remember about my ordeal with bash and Catalina and zshell and iTerm. I bit the bullet and switched to zshell.

I have an alias for starting the postgres server that on bash resides on .bashrc (by the way, did you know that rc stands for run commands?). With zshell, you can use .zshrc for the same purpose.

zshell at startup reads these files for the user in the following order:

  1. .zshenv - always read when launching the shell, no matter from where. you want the important stuff here.
  2. .zshprofile - read at login. don't use, use .zshlogin instead. the purpose is the same.
  3. .zshrc - read when interactive. this is where you should put aliases, key bindings, coloring, etc.
  4. .zshlogin - read at login, use it for things needed once the shell is set up, to execute external commands.
  5. .zshlogout - read when the login shell exits, it should be used to release resources acquired during login.

Before each of these, zshell runs the matching files that can be found in /etc/ for all users on the machine.

More info here (official documentation), here on StackOverflow, and here (switching to zshell because of Catalina).

Learning while Doing (4 Part Series)

1) TIL about tree 2) TIL about zshell startup 3) TIL about Ruby command line execution 4) TIL about testing commands

Posted on by:

nirnaeth profile

Monica

@nirnaeth

I still answer "developer". Italian living in Germany. proud MC of Euruko [2016], Ruby on Ice [2017, 2018], BalkanRuby [2017], Italian Ruby Day [2016, 2018].

Discussion

markdown guide
 

I have this in my .bashrc, .bash_profile and .zshrc:

[ -f ~/.aliases ] && . ~/.aliases

That way I keep my aliases in a common file. Sure, some are shell specific but more likely they're OS specific, so inceptionally inside the .aliases file, I have stuff like this:

case $OSTYPE in
  linux-gnu)
    alias ls='ls --color --group-directories-first -FhN'
    ;;
  darwin*)
    alias ls='ls -FhG'
  ;;
esac
 

oh this is so simple and yet so great!

I'll steal your idea :D

 

by the way, did you know that rc stands for run commands?

Huh! I always assumed it was "remote configuration"!

 

at first I was also thinking that, but then the “remote” part was really not fitting... why remote if this is running on my machine? 🤔

I looked for it and ta-da! TIL inception!