• Stars
    star
    195
  • Rank 199,374 (Top 4 %)
  • Language
    Go
  • License
    MIT License
  • Created over 2 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🧭 A fast, clean, customisable shell prompt for zsh, bash, fish, and more...

🧭 bearings

A fast, clean, super-customisable shell prompt.

  • Supports zsh, bash, fish, and more.
  • Easily write your own modules using any language.
  • Simple configuration with YAML - works out of the box with a sensible default configuration too.

Examples Gallery

prompt demoDefault
prompt demoHalf Life
prompt demoTraditional
prompt demoFire
prompt demoUkraine
prompt demoPirate
prompt demoWasteland
prompt demoHive

Feel free to PR your own screenshots onto this list!

Installation

You can download the latest binaries here. Make sure you chmod +x the binary and place it somewhere in your PATH. Then follow the instructions for your shell below.

It is recommended to install font(s) which include powerline characters, especially nerd-fonts.

Configuration

Automatic (recommended)

You can automatically configure your shell by running bearings install. This will modify your shell configuration files in order to set bearings as your PS1 generator. For advanced configurations (e.g. templated dotfiles), you should use the manual methods below. It's always a good idea to back up your config files first!

If you'd like to install bearings to a shell other than the one you're using, you can specify it with the -s/--shell flag, e.g. bearings install -s fish.

ZSH

#bearings-auto:start
function preexec() {
  if [[ $OSTYPE == 'darwin'* ]]; then
    btimer=$(($(date +%s)*1000))
  else
    btimer=$(($(date +%s%N)/1000000))
  fi
}
function configure_bearings() {
    last=$?
    elapsed=0
    if [ $btimer ]; then
      if [[ $OSTYPE == 'darwin'* ]]; then
        now=$(($(date +%s)*1000))
      else
        now=$(($(date +%s%N)/1000000))
      fi
      elapsed=$(($now-$btimer))
      unset btimer
    fi
    PROMPT="$(bearings prompt -s zsh -e ${last} -d ${elapsed} -j $(jobs | wc -l))"
}
[ ! "$TERM" = "linux" ] && precmd_functions+=(configure_bearings)
#bearings-auto:end

Bash

#bearings-auto:start
if [[ $OSTYPE == 'darwin'* ]]; then
    PS0='$(echo "$(($(date +%s)*1000))" > /tmp/bearings.$$)';
else
    PS0='$(echo "$(($(date +%s%N)/1000000))" > /tmp/bearings.$$)';
fi
bearings_prompt() { 
    if [[ $OSTYPE == 'darwin'* ]]; then
        NOW=$(($(date +%s)*1000))
    else
        NOW=$(($(date +%s%N)/1000000))
    fi
    START=$NOW
    [[ -f /tmp/bearings.$$ ]] && START=$(cat /tmp/bearings.$$) && rm /tmp/bearings.$$
    DURATION=$(($NOW - $START));
    export PS1=$(bearings prompt -s bash -e $? -d $DURATION -j $(jobs -p | wc -l)); 
}
[[ ! "$TERM" = "linux" ]] && export PROMPT_COMMAND=bearings_prompt
#bearings-auto:end

Fish

#bearings-auto:start
function fish_prompt
    bearings prompt -s fish -e $status -d $CMD_DURATION -j (count (jobs -p))
end
#bearings-auto:end

Customisation

The config file is read from ~/.config/bearings/config.yml. You can create a default config file by running bearings prompt for the first time.

For completeness, here is the default config file:

padding: 1
end: ξ‚°
divider: ξ‚°
fg: white
bg: black
lines_above: 1
modules:
- type: exitcode
  failure_bg: '#bb4444'
  failure_fg: '#ffffff'
  show_success: true
  success_bg: '#000000'
  success_fg: '#ffffff'
  success_output: οš‹
- type: duration
  bg: '#ffffff'
  fg: '#334488'
  threshold: 3s
- type: cwd
  bg: '#334488'
  fg: '#aaaaaa'
  label: ξ˜“ %s
  max_depth: 3
- type: git
  bg: '#393939'
  fg: '#777777'

You can find example configurations with screenshots for each in the examples directory.

Property Default Description
padding 1 Number of spaces before and after each module. Can be overriden on a per-module basis.
end ξ‚° (powerline character) The string to render at the end (right) of the prompt.
divider ξ‚° (powerline character) The string to render between modules. Can be overriden on a per-module basis.
fg white Default foreground colour for all modules. Can be overridden on a per-module basis.
bg black Default background colour for all modules. Can be overridden on a per-module basis.
lines_above 1 Number of blank lines to render above the prompt.
modules exitcode, cwd, git A list of modules and their configurations.

Colours can be specified in hexadecimal, e.g. #ffffff. You can also refer to your terminal colour scheme colours using default (for default fg/bg), red, green, yellow, blue, magenta, cyan, white, black, lightred, lightgreen, lightyellow, lightblue, lightmagenta, lightcyan, lightwhite, lightblack

All modules support the following options:

Property Default Description
label %s Text to render alongside the module output. Use %s as the placeholder for the module content.
fg inherits from top-level fg Module foreground colour.
bg inherits from top-level bg Module background colour.
padding_before inherits from top-level padding Number of spaces to output before the module content.
padding_after inherits from top-level padding Number of spaces to output after the module content.
divider inherits from top-level divider Divider string to output after the module, to separate it fro mthe next module. If there is no next module, will not be shown.
bold false Turns on bold text.
italic false Turns on italic text.
faint false Turns on faint text.
underline false Turns on underlined text.

Available Modules

Current Working Directory (cwd)

Show the current working directory.

cwd

Property Default Description
max_depth 0 The maximum number of directories to render in the path. If this number is exceeded, the output will be truncated to show ... followed by the lowest max_depth number of directories.
separator ξ‚± The string to separate directories with.
separator_fg inherits from module fg Foreground colour of the separator.
deep_prefix  Output to prefix the path with when the max depth is reached.
home_text ~ Text to represent home directory.
separator_at_start false Show the separator at the start of the path.

Exit Code (exitcode)

Show the exit code of the previous command. By default will only show when the command fails, but can also show a success icon/message.

exit code

Property Default Description
show_success false Show the module when the previous command succeeded (exit code zero).
success_bg inherits from bg, top-level bg Background colour for the module when the previous command succeeded.
failure_bg inherits from bg, top-level bg Background colour for the module when the previous command failed.
success_fg green Foreaground colour for the module when the previous command succeeded.
failure_fg red Foreground colour for the module when the previous command failed.
success_output  Output for the module when the previous command succeeded.
failure_output  Output for the module when the previous command failed.

Git Overview (git)

Show an overview of the current git status. Displays the branch name, a set of possible icons, and the number of commits ahead/behind of the base branch.

Property Default Description
icon_stashed S The icon/text to display when stashed changes are available.
icon_untracked ? The icon/text to display when untracked files are present.
icon_modified M The icon/text to display when tracked files are modified.
icon_staged A The icon/text to display when changes are staged.
icon_conflicts ! The icon/text to display when conflicts are present.
clean_bg inherit Background colour when there are no changes.
clean_fg inherit Foreground colour when there are no changes.
dirty_bg inherit Background colour when there are changes.
dirty_fg inherit Foreground colour when there are changes.

Command (command)

Run a shell command and use the combined output streams as the module output.

Property Default Description
command none The shell command to run.

Duration

Shows the duration of the previous shell command. Can be configured to only show duration when over a certain threshold.

Duration example

Property Default Description
threshold 3s Show duration when over this threshold.

Jobs

Shows the number of background jobs (if > 0).

Hostname (hostname)

Show the current hostname.

Languages

Show icons for discovered languages/technologies in the current directory.

Property Default Description
separator The separator between the icons.

New line (newline)

Output a single new line. Before/after padding values default to 0 for convenience.

Text (text)

Output the specified text.

Property Default Description
text none The text to output.

Username (username)

Show the current username.

More Repositories

1

traitor

⬆️ ☠️ πŸ”₯ Automatic Linux privesc via exploitation of low-hanging fruit e.g. gtfobins, pwnkit, dirty pipe, +w docker.sock
Go
6,575
star
2

darktile

🌘 Darktile is a GPU rendered terminal emulator designed for tiling window managers.
Go
2,743
star
3

gitjacker

πŸ”ͺ :octocat: Leak git repositories from misconfigured websites
Go
1,532
star
4

tml

πŸŒˆπŸ’»πŸŽ¨ A tiny markup language for terminal output. Makes formatting output in CLI apps easier!
Go
729
star
5

shox

🍫 A customisable, universally compatible terminal status bar
Go
700
star
6

dismember

πŸ”ͺ Scan memory for secrets and more. Maybe eventually a full /proc toolkit.
Go
593
star
7

furious

😠 Go IP/port scanner with SYN (stealth) scanning and device manufacturer identification
Go
569
star
8

scout

πŸ”­ Lightweight URL fuzzer and spider: Discover a web server's undisclosed files, directories and VHOSTs
Go
516
star
9

memit

πŸš«πŸ’Ύ Run binaries straight from memory in Linux
Go
305
star
10

grace

πŸͺ› It's strace, with colours.
Go
250
star
11

siphon

βš—οΈ Intercept stdin/stdout/stderr for any process
Go
187
star
12

pax

πŸ’€ πŸ”“ CLI tool for PKCS7 padding oracle attacks
Go
135
star
13

comet

β˜„οΈ Command line tool to help you use conventional commit messages (https://www.conventionalcommits.org)
Go
109
star
14

memoryfs

🧠 πŸ—„οΈ In-memory filesystem implementation of io/fs.FS
Go
87
star
15

extrude

πŸ•΅οΈ Analyse binaries for missing security features, information disclosure and more...
Go
69
star
16

gifwrap

πŸ™ GIFs in your terminal
Go
54
star
17

flinch

A collection of terminal-based widgets for richer Golang CLI apps.
Go
44
star
18

loading

A collection of highly customisable loading bars for Go CLI apps.
Go
34
star
19

guerrilla

πŸ“¨πŸ‘€ Guerilla Mail CLI + Go module
Go
28
star
20

sunder

βœ‚οΈ terminal multiplexer in golang // a minimalist tmux alternative
Go
27
star
21

magic

πŸŽ©πŸ‡ Toolkit for detecting and verifying file type using magic bytes in pure Golang
Go
24
star
22

peridot

Developer machine management for Linux/OSX. Think Terraform/Ansible for your dotfiles/packages! βš™οΈπŸ 
Go
20
star
23

clinch

Go CLI toolkit πŸ”¨
Go
19
star
24

github-profile-terminal-action

Create a GitHub profile README nested inside a terminal nested inside a GIF
Go
17
star
25

gobless

Build beautiful terminal dashboards/GUIs in golang.
Go
16
star
26

lyric

🎡 Song lyrics in your terminal via Genius
Go
16
star
27

js-nes-emulator

NES emulator in javascript.
JavaScript
13
star
28

lambo

Test your API gateway routed lambdas locally and in CI
Go
8
star
29

sshotp

Enter passwords to commands non-interactively
Go
8
star
30

hackerone

Go HackerOne API Client
Go
8
star
31

raytracing

3D Raytracing in Go
Go
8
star
32

thisisfine

This is fine.
Makefile
7
star
33

darktile-themes

A repository of themes for https://github.com/liamg/darktile
Shell
7
star
34

liamg

GitHub profile (auto-updated every 4 hours)
6
star
35

gomoon

🌚 πŸŒ’ πŸŒ“ πŸŒ” 🌝 πŸŒ– πŸŒ— 🌘 🌚
Go
6
star
36

jfather

JSON parsing with extra metadata
Go
6
star
37

happen

Go
5
star
38

termutil

Terminal utilities
Go
4
star
39

philter

Personal home DNS with ad blocking
Go
4
star
40

iris-layout

A UK coding layout for the Iris rev4 keyboard
C
4
star
41

bfc

A compiler for brainfuck by someone who has no idea how compilers work
Go
4
star
42

waitforhttp

Tiny package to wait for an HTTP server to be up
Go
4
star
43

iamgo

Parse/assemble AWS IAM policy documents and their various quirks
Go
4
star
44

fontinfo

Go package to list/match available fonts on a Linux system
Go
4
star
45

rope

〰️ A rope data-structure implementation designed for UTF-8 text manipulation.
Go
3
star
46

dotfiles

Shell
2
star
47

lcd

Go module for driving (non-I2C) LCD devices
Go
2
star
48

nvim-config

Lua
2
star
49

go-project-template-cli

A template for my Go CLI projects
Makefile
2
star
50

ecs

Entity Component System architecture implementation in Go
Go
2
star
51

golume

Go
1
star
52

dnsaur

DNS client/server components in node.
JavaScript
1
star
53

postMessageSniffer

Simple chrome extension to console.log all received postMessage payloads.
JavaScript
1
star
54

reversing

Reverse engineering challenge hackery
C
1
star
55

adtechblogs

The Best Ad Tech Blogs
1
star
56

torrentialjs

BitTorrent library in Node
JavaScript
1
star
57

gca

πŸ”¬πŸŽ² Go Cellular Automata
Go
1
star
58

.github

My default .github miscellany
1
star
59

sidestep

↔️ Tunnel TCP/UDP over DNS: Evade firewalls for fun and profit
1
star
60

dijits

JavaScript library to convert between numbers and words: 407 -> Four hundred and seven
JavaScript
1
star
61

tls

πŸ”’ Custom TLS implementation for no good reason
Go
1
star
62

gomega

A Sega Mega Drive (Genesis) Emulator in Go.
1
star
63

writeups

1
star
64

xu

Modern Hex Editor
Go
1
star