eshell-p10k is a modular, extensible prompt framework for eshell inspired by powerlevel10k.
- Highly customizable powerline-style prompts
- Pre-built segments: OS/distro, directory, git status, prompt counter
- Simple API for creating custom segments
- Emacs 27.1+
- nerd-icons for default config
- A Nerd Font installed and configured in your terminal
Add to your load path:
(add-to-list 'load-path "/path/to/eshell-p10k")The default prompt will be autoloaded when you use it.
Use the default prompt configuration (automatically loads on first use):
(setq eshell-prompt-function #'eshell-p10k-default-prompt
eshell-prompt-regexp eshell-p10k-prompt-regex)That’s it! The default configuration will be loaded automatically when eshell starts.
The default prompt includes:
- OS/distribution icon
- Current directory
- Git branch and status (when in a repo)
- Prompt counter
Customize the powerline separators and terminators:
(setq eshell-p10k-separator "\xe0bc" ; Separator between segments
eshell-p10k-start-terminator "\xe0b2" ; Start of each segment
eshell-p10k-end-terminator "\xe0b0") ; End of promptCustomize the prompt frame:
(setq eshell-p10k-header-string "\n┌─" ; Prefix before segments
eshell-p10k-prompt-string "└─> ") ; Input promptThe eshell-p10k-def-segment macro creates a new segment:
(eshell-p10k-def-segment segment-name
icon ; Icon to display (or nil)
form ; Expression to evaluate
face) ; Face to apply(defface my-time-face
'((t (:background "purple" :foreground "white")))
"Face for time segment.")
(eshell-p10k-def-segment time
""
(format-time-string "%H:%M:%S")
'my-time-face)(defface my-hostname-face
'((t (:background "orange" :foreground "black")))
"Face for hostname segment.")
(eshell-p10k-def-segment hostname
""
(system-name)
'my-hostname-face)Segments that return nil won’t be displayed:
(eshell-p10k-def-segment battery
""
(when (and (featurep 'battery)
battery-status-function)
(battery-format "%p%%" (funcall battery-status-function)))
'my-battery-face)Compose your own prompt from segments:
(defun my-custom-prompt ()
"My custom prompt with time and hostname."
(eshell-p10k-def-prompt '(hostname dir git time)))
(setq eshell-prompt-function #'my-custom-prompt)Use only the segments you need:
(defun my-minimal-prompt ()
"Minimal prompt with directory and git."
(eshell-p10k-def-prompt '(dir git)))
(setq eshell-prompt-function #'my-minimal-prompt)Use only the core framework without default segments (manual require needed):
(require 'eshell-p10k) ; Core framework only
;; Define your own segments
(eshell-p10k-def-segment my-segment ...)
;; Create your prompt
(defun my-prompt ()
(eshell-p10k-def-prompt '(my-segment)))
(setq eshell-prompt-function #'my-prompt)Displays an icon for your OS/distribution:
- Automatically detects Linux distros from
/etc/os-release - Supports: Arch, Debian, Ubuntu, Fedora, NixOS, and more
- Falls back to generic icons for unknown systems
Shows current directory:
- Uses
abbreviate-file-nameto shorten paths - Replaces home directory with
~
Git repository information:
- Shows current branch name
- Displays file status counts (e.g., “M 2”, “A 1”)
- Background color indicates clean (green) or dirty (red) state
- Only appears when in a git repository
Command counter:
- Increments with each command
- Resets when eshell exits
- Useful for command history navigation
(eshell-p10k-def-segment user
""
(user-login-name)
'eshell-p10k-distro-face)
(defun my-detailed-prompt ()
"Multi-line prompt with user info."
(eshell-p10k-def-prompt '(user hostname dir git prompt-num)))
(setq eshell-prompt-function #'my-detailed-prompt)(defcustom my-git-detail-threshold 50
"Show detailed git status only if repo has fewer than this many files."
:type 'integer)
(eshell-p10k-def-segment git-smart
""
(when (eshell-p10k--git-repo-p)
(let ((branch (eshell-p10k--git-branch)))
(if (< (length (eshell-p10k--git-status-counts)) my-git-detail-threshold)
(eshell-p10k--git-status)
branch)))
(if (eshell-p10k--git-clean-p)
'eshell-p10k-git-clean-face
'eshell-p10k-git-dirty-face))- Ensure you have a Nerd Font installed
- Run
M-x nerd-icons-install-fonts - Configure your terminal to use the Nerd Font
Make sure you’ve set both variables:
(setq eshell-prompt-function #'eshell-p10k-default-prompt
eshell-prompt-regexp eshell-p10k-prompt-regex)For large repositories, git operations may slow down prompt rendering. Consider:
- Disabling the git segment:
(eshell-p10k-def-prompt '(distro dir prompt-num)) - Using a simpler git segment without status counts
Contributions are welcome! Please feel free to submit issues or pull requests on GitHub.
- Modern Emacs - Fundamentals for eshell customization
- doom-modeline - Inspiration for modular segment design
- powerlevel10k - The original inspiration and powerline aesthetic
