Giter Site home page Giter Site logo

leolanese / bash_profile Goto Github PK

View Code? Open in Web Editor NEW
24.0 5.0 19.0 245 KB

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: MIT License

Shell 100.00%
bash-script profile shell zsh darwin linux-shell powershell

bash_profile's Introduction

.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: [email protected]

bash_profile's People

Contributors

leolanese avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.