Skip to content

Koss86/tokyobash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

97 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Tokyobash

A configurable bash prompt inspired by the Tokyo Night Theme for Neovim.

Requires a Nerd Font

Features

πŸ–ŒοΈ Highlighting

Highlights the current directory and changes the color of User@Host depending on whether you're in HOME/, root/, or /mnt.

🎨 Themes

There are currently three themes to choose from.

  • Tokyonight:

    Tokyobash_tokyonight_noBg
  • Catppuccin:

    Tokyobash_catppuccin_noBg
  • Kanagawa:

    Tokyobash_kanagawa_noBg

Themes can be changed via the theme Config setting.

🌈 Backgrounds

There are optional backgrounds that can be enable via the background Config setting.

There are three variatons to choose from:

Pointed
  • Tokyonight

    Tokyobash_tokyonight_Bg_pointed
  • Catppuccin

    Tokyobash_catppuccin_Bg_pointed
  • Kanagawa

    Tokyobash_kanagawa_Bg_pointed
Rounded
  • Tokyonight

    Tokyobash_tokyonight_Bg_rounded
  • Catppucin

    Tokyobash_catppuccin_Bg_rounded
  • Kanagawa

    Tokyobash_kanagawa_Bg_rounded
Slanted
  • Tokyonight

    Tokyobash_tokyonight_Bg_slanted
  • Catppuccin

    Tokyobash_catppuccin_Bg_slanted
  • Kanagawa

    Tokyobash_kanagawa_Bg_slanted

🀏 Abbreviate Path

Abbreviates paths longer than 50 characters.

Tokyobash_abv

🌱 Branch Name

If the current directory is a repository it will display the current branch name.

Tokyobash_branchname

πŸ” Status Bar

An icon bar that displays changes in the current repository.

Tokyobash_statusbar

Displays (in order):

  • Number of untracked files
  • Number of files with unstaged changes
  • Number of staged files
  • Number of local commits
  • Number of remote commits.
Tokyobash_statusbar_explained

Note

The feature to auto-fetch commits is disabled by default.

Can be enabled via the fetch Config setting.

And modified with the fetchtimer Config setting.

πŸ”§ Installation

The easiest way would be to have make and gcc/clang installed on your system. For instructions on how to install without make click here.

In the root of the tokyobash repository, there are three commands to use:

  • make Will build the tokyobash binary and place it in /bin in the root of the tokyobash repository.
  • make install Will build tokyobash, create and then move the config file to $XDG_CONFIG_HOME/tokyobash if one is not already present.
    • The config directory defaults to $XDG_CONFIG_HOME. If for any reason $XDG_CONFIG_HOME can't be resolved, the config directory will default to $HOME/.config.
  • make install prefix=custom/path Will build tokyobash, create and move config file, then move tokyobash to prefix/bin.

Add this to your .bashrc (usually located at $HOME/.bashrc):

export PROMPT_COMMAND='PS1="$(path/to/tokyobash)"'

Replace path/to/tokyobash above with the acutal path to the compiled tokyobash binary.

If tokyobash was placed somewhere that's in your $PATH, then your PROMPT_COMMAND can look like this.

export PROMPT_COMMAND='PS1="$(tokyobash)"'

Now save and restart your terminal!

Config

Config file uses standard key = value pairs.

# or // can be used for comments.

Spaces, single, and double quotes are ignored.

1 = enabled 0 = disabled - except for background, time, and fetchtimer, which have multiple options explained below.

Default config:

theme       = tokyonight
#theme      = catppuccin
#theme      = kanagawa

background  = 0  # 0 = Off, 1 = pointed, 2 = rounded, 3 = slanted.
time        = 1  # 0 = Off, 1 = 24-hour clock, 2 = 12-hour clock.
abvpath     = 1  # Abberviate path on/off
branchname  = 1  # Turn the display of branch name on/off.
statusbar   = 1  # Turn statusbar on/off.
fetch       = 0  # Turn fetching of commits on/off.
fetchtimer  = 1d # See below.
icon        = ξ―†  # Change icon or set to 0 to remove.

fetchtimer will accept #d, #h, or #m. d = days h = hours and m = minutes.

For example:
  • If fetchtimer = 25m repository will update after 25 minutes, when the prompt reloads.
  • If fetchtimer = 2h repository will update after 2 hours, when the prompt reloads.
  • If fetchtimer = 3d repository will update after 3 days, when the prompt reloads.
  • fetchtimer = 1h30m is not vaild. Only one Day, Hour, or Minute modifier is allowed.

No Make

All you really need is a C compiler to build Tokyobash.

So, if you dont have make you can use these commands in the top level of the tokyobash repository.

For gcc:

gcc -c src/tokyobash.c
gcc -c src/lib/tokyobashlib.c
gcc -c src/lib/gitlib.c
gcc -c src/lib/shouldFetchlib.c
gcc -c src/lib/printlib.c
gcc -O3 tokyobash.o tokyobashlib.o gitlib.o shouldFetchlib.o printlib.o -o tokyobash
rm tokyobash.o tokyobashlib.o gitlib.o shouldFetchlib.o printlib.o

For clang:

clang -c src/tokyobash.c
clang -c src/lib/tokyobashlib.c
clang -c src/lib/gitlib.c
clang -c src/lib/shouldFetchlib.c
clang -c src/lib/printlib.c
clang -O3 tokyobash.o tokyobashlib.o gitlib.o shouldFetchlib.o printlib.o -o tokyobash
rm tokyobash.o tokyobashlib.o gitlib.o shouldFetchlib.o printlib.o
Config File

You will need to manually create the directory tokyobash in ~/.config or wherever you may have $XDG_CONFIG_HOME set.

Try these commands in your terminal. They will create the tokyobash/config directory and file in your XDG_CONFIG_HOME directory loaded with the defaults.

mkdir -p $XDG_CONFIG_HOME/tokyobash/
{
    printf 'theme      = tokyonight\n'
    printf '#theme     = catppuccin\n'
    printf '#theme     = kanagawa\n\n'
    printf 'background = 0\n'
    printf 'time       = 1\n'
    printf 'abvpath    = 1\n'
    printf 'branchname = 1\n'
    printf 'statusbar  = 1\n'
    printf 'fetch      = 0\n'
    printf 'fetchtimer = 1d\n'
    printf 'icon       = ξ―†\n'
} >$XDG_CONFIG_HOME/tokyobash/config

🚧 Disclaimer

I'm not sure if this will run on all linux distros. I believe it should work on most if not all.

I'm also new to programming so any feedback is welcomed. So if I'm doing somthing stupid (I'm sure I am somewhere) please let me know.

All screenshots were taken with: ghostty terminal with tokyonight theme.

About

A custom bash prompt written in C. Inspired by the Neovim theme Tokyo Night.

Resources

License

Stars

Watchers

Forks

Contributors