Skip to content
Minard-JulesPublic

About

An advanced and highly configurable bash prompt with memory, CPU, temperature, Git, Conda display and more.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Custom Bash Prompt

An advanced and highly configurable bash prompt with memory, CPU, temperature, Git, Conda display and more.


Preview


File Structure

~/.bash_prompt     ← main prompt script
~/.color           ← ANSI color definitions

Installation

git clone https://github.com/Minard-Jules/My_prompt.git
mv My_prompt/.bash_prompt ~/
mv My_prompt/.color ~/
rm -rf My_prompt

Activation

Add the following line at the end of ~/.bashrc:

if [ -f ~/.bash_prompt ]; then
    . ~/.bash_prompt
fi

Configuration

All options are located at the top of the ~/.bash_prompt file:

# ── Display ──────────────────────────────────────────────────
__show_memory_usage=true    # Display memory usage
__show_cpu_usage=false      # Display CPU usage
__show_cpu_temp=false       # Display CPU temperature

# ── Memory Unit ──────────────────────────────────────────────
__memory_unit="MiB"         # Display unit (see table)
__memory_unit_fr=true       # Use French units

# ── CPU Smoothing ────────────────────────────────────────────
__cpu_history_size=5        # Moving average window

Available Memory Units

Base 1024 — IEC

Value English French
B B o
KiB KiB Kio
MiB MiB Mio
GiB GiB Gio

Base 1000 — SI

Value English French
KB KB Ko
MB MB Mo
GB GB Go

Bits

Value Unit
bits bits
Kbits Kbits
Mbits Mbits
Gbits Gbits

Values read from /proc/meminfo are in KiB (base 1024), despite the kB notation used by the Linux kernel.


Features

Line 1 — System Information

Element Description
 /  /  Distribution logo (Debian / Ubuntu / Arch)
user@hostname Current user — red if root, black otherwise
14:32:05 Current time
 3840/7887Mio 48% RAM used / total + percentage (if enabled)
󰍛 12% Moving average CPU load (if enabled)
55°C CPU temperature (if enabled)
󱦟 2.03s Last command duration
 master Current Git branch (if in a repository)
⚙ 2 Number of background jobs (if > 0)
• / • (ERROR 1) Return code — green if success, red if error
  • distribution

  • RAM and CPU

Git

git.mp4
  • Jobs and exit code

exit code

error.mp4

Line 2 — Current Directory

Displays the path of the working directory.


Line 3 — Environment & Symbol

Element Description
No active environment
 base Base Conda environment
󱈚 Fortran_env Fortran environment
 Python_env Python environment
 C_env C environment
 Cpp_env C++ environment
$ / # User symbol — $ normal, # root

Conda env

conda_env.mp4

Root

root.mp4

Execution Time

The execution time of the last command is measured accurately and automatically formatted based on duration:

Duration Format Example
< 1 second ms 423ms
< 1 minute s 12.34s
< 1 hour min:sec 2m05s
≥ 1 hour h:min:sec 1h02m30s

Memory Usage

Real-time reading from /proc/meminfo:

RAM used = MemTotal - MemAvailable

MemAvailable is used (not MemFree) because it accounts for caches that can be reclaimed by the system.


CPU Load

  • Calculated from /proc/stat between each prompt display
  • Moving average over the last cpu_history_size readings
  • 3% update threshold to avoid spurious variations
  • Early readings won't be displayed until the history is full

CPU Temperature

Read from /sys/class/thermal/thermal_zone0/temp. Automatically ignored if the file doesn't exist (virtual machine, etc.).


Git Integration

Displays the current Git branch if the directory is a Git repository. Branch caching in update_prompt_data avoids a double git call per prompt display.


Conda Environments

Automatic detection of $CONDA_DEFAULT_ENV with dedicated icons per environment. Easily extensible for new environments.


Dependencies

Tool Usage Optional
bash ≥ 4.0 Arrays, (( )) No
git Current branch Yes
awk Reading /proc/meminfo No
bc Decimal calculations (GiB, MB…) No
conda Virtual environments Yes
Nerd Fonts Prompt icons No

🔤 Recommended Font

Icons require a Nerd Fonts font.

Recommended fonts:

  • Cascadia Mono Nerd Font
  • JetBrainsMono Nerd Font
  • FiraCode Nerd Font
  • Hack Nerd Font

About

An advanced and highly configurable bash prompt with memory, CPU, temperature, Git, Conda display and more.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors