Welcome to .bashrc Generator

Create professional Bash configuration files with our free online tool. Customize your Linux & macOS terminal experience in minutes.

✨ Visual Prompt Builder with live preview | πŸ”§ Shell Options & Aliases | πŸ“Š History Management | πŸ› Debug Tools

No installation required. Generate, download, and copy your custom .bashrc instantly.

Configure your bash shell with powerful features including command history management, time-saving aliases, customizable PS1 prompts, advanced shell options (shopt), PATH customization, and debugging tools. Perfect for developers, sysadmins, and power users who want to optimize their terminal workflow.

HISTFILESIZE

HISTSIZE

HISTIGNORE

HISTCONTROL

HISTTIMEFORMAT

HISTFILE

Enable appending to history

Enable shared history

Enable pushd, popd acting as cd

Enable cd aliases

Enable safer {rm,mv,cp,ln} commands

Enable sudo expanding aliases

Enable mkdir with parent and verbose aliases

Enable vi -> vim alias

Enable colorized greps

Enable diff->colordiff alias

Enable pbcopy / pbpaste (requires xclip)

Enable now alias

Enable my_ip alias

EDITOR and VISUAL

PAGER

Auto Logout Timeout (seconds)

Disable write access to your terminal (mesg n)

Ensure checkwinsize is enabled

Add IGNOREEOF

Username

Hostname

Current Directory

Exit Code (show if non-zero)

Timestamp

Prompt Symbol

Colors

Separators

Newline before prompt

PATH Management

Prepend to PATH

Separate multiple paths with colons (:)

Append to PATH

Separate multiple paths with colons (:)

Debug Settings

Enable PS4 Debug Prompt


Shell Options (shopt)

Enable globstar (recursive ** wildcards)

Enable extglob (extended pattern matching)

Enable nocaseglob (case-insensitive globbing)

Enable autocd (cd by typing directory name)

Enable cdspell (auto-correct minor typos in cd)

Enable dirspell (auto-correct directory names during completion)

Enable dotglob (include hidden files in wildcards)

Enable nullglob (unmatched patterns expand to nothing)

Enable cdable_vars (cd to variables as directories)

Generated .bashrc

Bash Configuration Options Reference Guide

Complete documentation for all .bashrc settings available in this generator. Learn what each option does, see examples, and find links to the official GNU Bash manual β†— for in-depth information.

History Settings

HISTFILESIZE
Maximum number of lines kept in the history file (~/.bash_history). When the limit is exceeded the oldest entries are pruned. manual β†—
HISTSIZE
Number of commands remembered in the in-memory history list for the current session. Each new terminal loads up to this many entries from HISTFILE. manual β†—
HISTIGNORE
Colon-separated list of glob patterns. Any command matching a pattern is silently dropped from the history list. Useful for noisy commands (ls, cd) or to avoid accidentally recording secrets. manual β†—
HISTCONTROL
Controls duplicate handling. ignoredups β€” skip adjacent duplicates; ignorespace β€” skip commands prefixed with a space; ignoreboth β€” both of the above; erasedups β€” remove all earlier duplicates of each new entry. manual β†—
HISTTIMEFORMAT
When set, history prepends a timestamp (formatted via strftime) to every entry. Must end with a space character so the command text is separated from the timestamp. Example: %Y-%m-%d %T manual β†—
HISTFILE
Path to the file where history is persisted between sessions. Defaults to ~/.bash_history. Useful if you want separate history files per project or machine role. manual β†—
histappend (shopt)
By default Bash overwrites HISTFILE on exit. With histappend set, Bash appends instead, preserving history from other open sessions. manual β†—
Shared history
Hooks PROMPT_COMMAND to flush (history -a), clear (history -c), and reload (history -r) the history list before every prompt, so commands from all open terminals are immediately visible everywhere. manual β†—

Aliases

pushd / popd as cd
Replaces cd with pushd so every directory change is recorded on the directory stack. Use back to return to the previous directory. Both builtins are silenced to keep output clean. manual β†—
cd aliases (.., ..., ....)
Shortcuts for navigating up the directory tree: .. (one level up), ... (two), .... (three), ..... (four).
Safer rm / mv / cp / ln
Adds -i (prompt before overwrite) to mv, cp, and ln. Uses -I (prompt once before removing more than 3 files) and --preserve-root (refuse to operate recursively on /) on rm.
sudo alias
The trailing space in alias sudo='sudo ' instructs Bash to check the next word for alias expansion, so your other aliases continue to work correctly after sudo. manual β†—
mkdir -pv
Creates all intermediate parent directories as needed (-p) and prints each directory as it is created (-v), giving you a clear audit trail.
vi β†’ vim
Redirects the classic vi command to vim, the improved editor, without having to retrain muscle memory.
Colorized grep
Passes --color=auto to grep, egrep, and fgrep so pattern matches are highlighted in terminal output. Only activates when output goes to a terminal (not a pipe).
colordiff
If colordiff is installed, replaces the plain unified diff output with a syntax-colored version. The hash guard makes the alias a no-op when colordiff is absent.
pbcopy / pbpaste
Brings macOS-style clipboard commands to Linux using xclip. Requires xclip to be installed (sudo apt install xclip).
now
Prints the current date, time, and ISO week number in one shot. Handy for quickly stamping notes or log entries.
my_ip
Queries the ifconfig.co API and pretty-prints your public IP information as JSON using Python's built-in json.tool module.

Options

EDITOR and VISUAL
The preferred text editor invoked by programs such as git commit, crontab -e, and visudo. VISUAL is intended for full-screen editors; most modern tools check it first and fall back to EDITOR. manual β†—
PAGER
The program used to display multi-page output (e.g. man, git log). Common choices: less (feature-rich, the default on most distros), most (colour support, multiple windows), more (simple, always available).
Auto Logout Timeout (TMOUT)
When set to a positive integer, Bash automatically exits after that many seconds of inactivity. A useful security measure on shared, public, or unattended terminals. manual β†—
mesg n
Prevents other logged-in users from writing messages to your terminal with write or wall. Reduces interruptions and provides a small privacy/security benefit on multi-user systems.
checkwinsize (shopt)
After each command, Bash checks the terminal window size and updates the LINES and COLUMNS variables accordingly. Without this, text can wrap incorrectly after resizing the terminal window. manual β†—
IGNOREEOF
The number of consecutive Ctrl-D (EOF) signals Bash ignores before actually exiting. Setting it to 2 means you must press Ctrl-D three times in a row to quit, preventing accidental logouts. manual β†—

Prompt (PS1)

PS1
The primary prompt string displayed before each command. Bash interprets special escape sequences like \u (username), \h (hostname), \w (working directory), and \$ ($ for users, # for root). manual β†—
Username (\u)
Expands to the current username. Useful for identifying which account you're logged in as, especially in multi-user environments or when using su.
Hostname (\h / \H)
\h shows the short hostname (up to the first dot); \H shows the fully-qualified domain name. Helps you remember which machine you're working on when managing multiple servers.
Directory (\w / \W)
\w displays the full current working directory path with ~ shorthand for home; \W shows only the basename (final directory component). Essential for navigation context.
Exit Code
Conditional display using command substitution to show the previous command's exit status only when non-zero. Helps catch errors without cluttering the prompt.
Timestamp (\D{format})
Inserts the current date/time formatted per strftime. Useful for timestamping terminal sessions or correlating shell activity with logs.
ANSI Colors
Escape sequences \[\e[...m\] set text color/style. The \[...\] brackets tell readline to ignore non-printing characters so line wrapping and editing work correctly. manual β†—

PATH Management

PATH
Colon-separated list of directories where Bash searches for executables. When you type a command name, Bash checks each PATH directory in order until it finds a matching executable (or reports "command not found"). manual β†—
Prepend to PATH
Adding directories at the start of PATH gives them highest priority. Use this for custom tools or newer versions that should override system defaults. Example: export PATH="/usr/local/bin:$PATH"
Append to PATH
Adding directories at the end of PATH gives them lowest priority, used only if the command isn't found earlier. Safe for optional tools or fallback locations. Example: export PATH="$PATH:$HOME/.local/bin"

Debug Settings

PS4 (Debug Prompt)
The prompt displayed before each command when running Bash in debug/trace mode (set -x or bash -x). The enhanced PS4 shows the source file, line number, and function name for each executed command, making script debugging much easier. Essential for understanding script flow and identifying where errors occur.
Format: +(source_file:line_number): function_name():
Example output: +(myscript.sh:42): main(): echo "Hello"
Bash Bushido Book: Debug Bash Scripts β†— | GNU Bash manual β†—

Shell Options (shopt)

globstar
Enables the ** glob pattern to match all files and directories recursively. **/*.txt finds every .txt file in the current tree. Requires Bash 4.0+. manual β†—
extglob
Enables extended pattern matching operators: ?(pattern) (zero or one), *(pattern) (zero or more), +(pattern) (one or more), @(pattern) (exactly one), !(pattern) (anything except). Powerful for complex filename filters. manual β†—
nocaseglob
Makes filename globbing case-insensitive. *.TXT matches readme.txt, README.TXT, etc. Useful on case-insensitive filesystems or when dealing with inconsistent naming. manual β†—
autocd
Typing a directory name alone (no cd command) automatically changes to that directory. /etc becomes equivalent to cd /etc. Requires Bash 4.0+. manual β†—
cdspell
Auto-corrects minor spelling mistakes in cd arguments: transposed characters, missing characters, or one extra character. Helps when you type cd /sur/local/bin instead of /usr/local/bin. manual β†—
dirspell
Auto-corrects directory name spelling during tab completion (similar to cdspell but for readline). Requires Bash 4.0+. manual β†—
dotglob
Includes files starting with . (hidden files) in glob expansion. Without this, * skips .bashrc, .config, etc. Useful for operations on all files including hidden ones. manual β†—
nullglob
When a glob pattern has no matches, it expands to nothing (empty string) instead of the literal pattern. Prevents errors in for loops when no files match. Use carefullyβ€”can cause unexpected behavior if not handled. manual β†—
cdable_vars
If cd argument isn't a directory, treat it as a variable name and cd to that variable's value. Lets you define shortcuts: export proj="$HOME/projects"; cd proj. manual β†—