Przejdลบ do treล›ci

๐Ÿ›  Configuring Shell Profiles

Shell profiles allow you to customize your interactive session โ€” define aliases, set environment variables, and load helper functions automatically.

๐Ÿ—ƒ File Types Overview

Different shells look for different startup files depending on whether theyโ€™re login shells or interactive non-login shells.

Common Files

File Used By When Loaded
.profile sh, bash (login) Login shells
.bash_profile bash Login shells
.bashrc bash (non-login) Interactive non-login shells
.zshrc zsh Always loaded
.zprofile zsh (login) Login shells

Note: On macOS since Catalina, zsh is default; older versions used bash.


๐Ÿ” Loading Order Example (Bash)

  1. Login shell loads:
  2. /etc/profile
  3. First found among: ~/.bash_profile, ~/.bash_login, ~/.profile

  4. Non-login interactive shell loads:

  5. ~/.bashrc

So many developers put this in their ~/.bash_profile:

1
2
3
if [ -f ~/.bashrc ]; then
    source ~/.bashrc
fi

๐Ÿงฐ Practical Customizations

Aliases

Add shortcuts for frequently used commands:

1
2
3
alias ll='ls -la'
alias gs='git status'
alias dc='docker-compose'

Environment Variables

Set global settings:

1
2
3
export EDITOR=vim
export HISTSIZE=10000
export PS1='\u@\h:\w\$ '

Functions

Define reusable logic:

1
2
3
mkcd() {
    mkdir -p "$1" && cd "$1"
}

Path Extensions

Add custom directories to $PATH:

1
export PATH="$HOME/bin:$PATH"

๐Ÿงผ Keeping Things Organized

As your config grows, split it into logical parts:

1
2
3
4
5
~/.config/shell/
โ”œโ”€โ”€ aliases.sh
โ”œโ”€โ”€ env.sh
โ”œโ”€โ”€ functions.sh
โ””โ”€โ”€ prompt.sh

Then source them from your main profile:

1
2
3
for file in ~/.config/shell/*.sh; do
    source "$file"
done

๐Ÿ‘‰ Continue to: Cross-Platform Testing Setup