Skip to content

bash_profile, based on a Front-End Web Developer POV. I'm sharing best practices, tricks and keep the same profile across multiple development platforms

License

Notifications You must be signed in to change notification settings

leolanese/bash_profile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

.bash_profile

UPDATED: Including zsh & oh my zsh

What is the .bash_profile

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:

Shortcut

open -e ~/.bash_profile
nano ~/.bash_profile
source ~/.bash_profile

open -e ~/.zshrc
nano ~/.zshrc
source ~/.zshrc

Why common .bash_profile

The idea is to share best practices, suggestions, tricks and keep the same profile across multiple development platforms easily cloning from the repository.

zsh and .bash

Both bash and zsh (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.

Startup Files:

bash

~/.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.

zsh

~/.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.

Determinate what I'm currently using

echo $SHELL

The .zsh

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

Getting the .zsh

You can use it with or without Catalina+ OSX, and also in combination of the normal terminal.

Instalation

// 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)

oh my zsh

// install oh my zsh
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Themes

// 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"

Pluggins

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)

Executing commands as script on the NodeJS Playground

If you like some of these command, you may find the NodeJS Playground scrips pool useful as well: NodeJS-playground


System Operation Versions

MAC version:

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.

Setup Startup Terminal with .bash

// 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

Alternative modificaton

If we need to inject just a line we could use >>

echo "alias python='python2.7'" >> ~/.zshrc

Commands and alliases:

edit bash_profile

open -e ~/.bash_profile

if you don't have this file, create it!

touch ~/.bash_profile

PS1 terminal bash options

  • PS1 option 1
    PS1 option 1

  • PS1 option 2
    PS1 option 2


Windows version

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"

πŸ’― Thanks!

Now, don't be an stranger. Let's stay in touch!

πŸ”˜ linkedin: @LeoLanese
πŸ”˜ Twitter: @LeoLanese
πŸ”˜ Portfolio: www.leolanese.com
πŸ”˜ DEV.to: dev.to/leolanese
πŸ”˜ Blog: leolanese.com/blog
πŸ”˜ Questions / Suggestion / Recommendation: developer@leolanese.com

About

bash_profile, based on a Front-End Web Developer POV. I'm sharing best practices, tricks and keep the same profile across multiple development platforms

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages