Linux: Bash Prompt Setup

By Xah Lee. Date: . Last updated: .

Add Date/Time Stamp to Prompt

linux lxde lxterminal
bash prompt with color and date.

Here's how to add date/time stamp to your bash prompt. Type this in terminal:

PS1='\u@\H • \D{%Y-%m-%d} • \A • \w\n';

Here's what the escape means:

Date in “yyyy-mm-dd” format.
Hour and minute in 24-hour “hh:mm” format.

To make it permanent, put the line in ~/.bash_profile.

[see Difference Between .bashrc, .profile, .bash_profile, …?]

For basic bash prompt setting and parameters, see man bash, search for PS1. (type h for help.)

ISO Date/Time Format for ls

make ls display datetime stamp in ISO date/time format, like 2015-11-22

alias l='ls -AlF --color --time-style=long-iso'
-A or --almost-all
Do not list current directory . and parent directory ...
-F or --classify
Append indicator (one of {/, ->, *, =, |}) to entries.
Use a long listing format. That is, display perm, owner, group, date, etc. [see Linux: File Permissions]

What the indicator mean:

Symbolic link
Unix domain socket
Named pipe

Ignore Duplicates in History

How to make bash not save duplicates in history?
# don't save duplicate lines or lines starting with space

Shell Prompt Setup

Linux Shell Basics

Sys Admin


Linux Desktop