Explain .bashrc code

Paste a .bashrc and Vibe explains what each line sets up for a new terminal: aliases, functions, PATH, history and what PS1 puts in your prompt.

.bashrc

Up to 1,500 characters (about 60 lines). Your code is sent to Unvibe and Anthropic to write the explanation. Don't paste keys or passwords. Common key formats are refused.

Vibe22 lines selected

Press Explain it for the sample, or paste your own code first.

What this .bashrc sample shows

interactive shells
bash reads ~/.bashrc each time it starts an interactive shell, the kind you type into. $- holds the shell's options and has an i only when it's interactive, so a script that ran source ~/.bashrc stopped at that line: its next line still ran, but type ll said ll: not found.
variables and PATH
export hands a variable on to every program the shell starts, while HISTSIZE and HISTCONTROL are settings for bash itself. PATH is the list of folders searched for a command, in order, so with $HOME/bin put first, command -v hello found the hello script in ~/bin.
aliases and functions
An alias swaps a short word for a longer command: type ll reported that ll is aliased to ls -lah. A function can take arguments, which an alias can't: mkcd a/b made both folders and moved into them, so pwd printed ~/a/b.
the prompt
PS1 is the prompt. \u, \h and \w stand for your user name, the computer's name and the current folder, and $(...) runs a command each time the prompt is drawn. In a repo on the feature/login branch, the prompt ended in ~/proj (feature/login)$.

Good to know

  • Run with GNU bash 5.3.15 on a test home folder, so nothing touched a real ~/.bashrc. Changes reach new terminals; in an open one, source ~/.bashrc reads the file again.
  • Aliases are for typing, not for scripts: a script that defined alias ll="ls -lah" and then ran ll stopped with ll: command not found. Write a function when a script needs the shortcut.
  • The bash manual on the history lines: erasedups "causes all previous lines matching the current line to be removed from the history list before that line is saved", and with histappend "the history list is appended to the file named by the value of the HISTFILE variable when the shell exits, rather than overwriting the file."

Watch out: A login shell doesn't read ~/.bashrc. Started as bash -l, type ll printed ll: not found, because a login shell reads ~/.bash_profile instead. With [ -f ~/.bashrc ] && . ~/.bashrc in ~/.bash_profile, the same login shell had the alias.

Explain .bashrc code beside your editor

Unvibe is a free app for Mac and Windows. In the app there is no pasting: select code in any app and press Control+U (Ctrl+Alt+U on Windows).

Install on Mac

curl -fsSL https://unvibe.site/install.sh | bash

Paste into Terminal. Unvibe isn't notarized by Apple yet, so this is the smooth path.

Opening the .dmg the first time
  1. Open the .dmg and drag Unvibe to Applications.
  2. Open it once; macOS says it can't verify it. Click Done.
    macOS dialog: Unvibe Not Opened, with Done and Move to Trash
    Real screen, macOS 15
  3. System Settings › Privacy & Security › Open Anyway. Confirm, then enter your Mac password. The button shows for about an hour after you try to open Unvibe.
    macOS Privacy & Security, Security section: Unvibe was blocked to protect your Mac, with the Open Anyway button
    Real screen, macOS 15

The Terminal line checks the download against the published SHA-256 and Unvibe's self-signed signature before it installs anything. More help with the first open