UPDATED: Including
zsh
&oh my zsh
bash_profile is a configuration file for bash shell. When bash is invoked as an interactive login shell it first reads and executes commands from:
open -e ~/.bash_profile
nano ~/.bash_profile
source ~/.bash_profile
open -e ~/.zshrc
nano ~/.zshrc
source ~/.zshrc
The idea is to share best practices, suggestions, tricks and keep the same profile across multiple development platforms easily cloning from the repository.
Both
bash
andzsh
(OSX default) are popular Unix shells, but they have different configuration files and some distinct features. When we talk about.bash_profile
and.zshrc
, we are referring to the "startup files" (or configuration files) used by these shells.
~/.bash_profile: Read and executed only by login shells.
~/.bashrc: Read and executed by non-login shells (like when you open a new terminal tab).
In many setups, ~/.bash_profile sources (or includes) ~/.bashrc to ensure commands and settings are consistent across login and non-login shells.
~/.zshrc: This is the primary configuration file for interactive use of zsh. It's analogous to ~/.bashrc in bash.
~/.zprofile: Read before .zshrc during a login, similar to .bash_profile in bash.
echo $SHELL
Apple has changed the default shell to zsh
. Therefore you have to rename your configuration files: .bashrc
is now .zshrc
and .bash_profile
is now .zprofile
.
nano ~/.zshrc
If you for some reason (like me) don't want to rename/move the
~/.bash_profile
file you can do the next things:
// having a copy of `.bash_profile` and `.zprofile`
edit_p
cp ~/.bash_profile ~/.zprofile
source ~/.bash_profile
source ~/.zshrc
You can use it with or without Catalina+ OSX, and also in combination of the normal terminal.
// install zsh
sudo apt install zsh
// Make default shell set and logout
chsh -s $(which zsh)
// If you want to make zsh our default shell
chsh -s $(which zsh)
// install oh my zsh
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
// In order to enable a theme, set ZSH_THEME to the name of the theme in your: ~/.zshrc
(open ~/.zshrc). Then edit the: ZSH_THEME="robbyrussell"
based on any theme from: https://github.com/ohmyzsh/ohmyzsh/wiki/Themes then: reload .zshrc:
// reload zsh
source ~/.zshrc
// example themes
ZSH_THEME="bira"
ZSH_THEME="dallas"
ZSH_THEME="half-life"
ZSH_THEME="aussiegeek"
ZSH_THEME="avit"
Choose from the list: https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins
add the plugin
to your plugins array in ~/.zshrc
(SHIFT, cmd, .) view all files there, paste plugin into plugin folder. Standard plugins can be found in $ZSH/plugins/
// example
plugins=(vscode zsh_reload git)
If you like some of these command, you may find the NodeJS Playground scrips pool useful as well: NodeJS-playground
A typical install of OSX won't create a .bash_profile
for you. When you want to run functions from your command line, this is a must-have.
// go to your home folder
cd ~/
// create your new file if you don't have it
touch .bash_profile
// open with textEditor or nano
open -e ./bash_profile
nano ./bash_profile
If we need to inject just a line we could use
>>
echo "alias python='python2.7'" >> ~/.zshrc
open -e ~/.bash_profile
touch ~/.bash_profile
Note:
Use double quotes instead of single one
!!
git config --global alias.ci "commit -v"
git config --global alias.log "log --pretty=oneline"
git config --global alias.log1 "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"