Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Signed-off-by: Beau Hastings <[email protected]>
  • Loading branch information
Beau Hastings committed Nov 7, 2016
0 parents commit 28c7181
Show file tree
Hide file tree
Showing 17 changed files with 379 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Beau Hastings

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
132 changes: 132 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# kawasaki

`kawasaki` is a [fish][fish] theme that emphasizes a simple and useful prompt without useless cluttter.

[![Oh My Fish](https://img.shields.io/badge/Framework-Oh_My_Fish-blue.svg?style=flat)](https://github.com/oh-my-fish/oh-my-fish)
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](/LICENSE)

![kawasaki][screenshot]


## Installation

#### Requirements
* [Fish shell][fish] - a smart and user-friendly command line
shell for OS X, Linux, and the rest of the family
* [Oh My Fish][omf] - The Fishshell Framework

Once Oh My Fish is installed:

omf install kawasaki

This theme was inspired by [bira][bira].

#### Notes

To use kawasaki's virtualenv prompt instead of the default virtualenv prompt append `set -x VIRTUAL_ENV_DISABLE_PROMPT 1` to your [init.fish][dotfiles]


## Features

* Completely customizable.
* Display status of the working tree for Git projects.
* Read/write indicator of the current working directory.
* Background jobs indicator.
* Virtualenv prompt indicator.


## Customizing

#### Override defaults

You can override the default display settings by specifying any of the following settings in your [init.fish][dotfiles]:

```fish
## Enable the time to be displayed.
set -g theme_display_time yes
## Disable playing the user's current group.
set -g theme_display_group no
## Disable Git-awareness.
set -g theme_display_git no
## Don't disable jobs indicator.
set -g theme_display_jobs no
## Always display the jobs indicator, even if there are no jobs.
set -g theme_display_jobs_always yes
## Hide the current directory read/write indicator.
set -g theme_display_rwt no
## Don't display the VirtualEnv prompt.
set -g theme_display_virtualent no
```

#### Look and feel

Nearly every aspect of kawasaki can be customized. The following can be set to adjust the look and feel of kawasaki:

```fish
set -g theme_color_error red
set -g theme_color_superuser red
set -g theme_color_user white
set -g theme_color_group 666666
set -g theme_color_host brgreen
set -g theme_color_separator brblack
set -g theme_color_bracket brblue
set -g theme_color_normal normal
set -g theme_color_time 666666
set -g theme_color_path brwhite
set -g theme_color_prompt white
set -g theme_color_virtualenv bryellow
set -g theme_color_status_prefix brblue
set -g theme_color_status_jobs brgreen
set -g theme_color_status_rw brwhite
set -g theme_prompt_char_normal '$'
set -g theme_prompt_char_superuser '#'
set -g theme_prompt_char "$theme_prompt_char_normal"
set -g theme_prompt_superuser_glyph \u2605
set -g theme_prompt_userhost_separator ':'
set -g theme_prompt_segment_separator_char ' '
set -g theme_prompt_segment_separator_color normal
set -g theme_prompt_status_jobs_char '%'
set -g theme_prompt_status_rw_char '.'
set -g theme_prompt_status_separator_char '/'
set -g theme_prompt_virtualenv_char_begin '('
set -g theme_prompt_virtualenv_char_end ')'
set -g theme_prompt_virtualenv_color_char_begin normal
set -g theme_prompt_virtualenv_color_char_end normal
set -g theme_display_time_format '+%I:%M'
set -g __fish_git_prompt_color_merging red
set -g __fish_git_prompt_color_branch brblue
set -g __fish_git_prompt_showcolorhints yes
set -g __fish_git_prompt_show_informative_status yes
set -g __fish_git_prompt_char_stateseparator ' '
set -g __fish_git_prompt_char_branch_begin ''
set -g __fish_git_prompt_char_branch_end ''
set -g __fish_git_prompt_color_branch_begin bryellow
set -g __fish_git_prompt_color_branch_end bryellow
```

## License

kawasaki is released under [The MIT License (MIT)][license]

Copyright (c) 2016 Beau Hastings

[license]: /LICENSE
[fish]: https://github.com/fish-shell/fish-shell
[omf]: https://github.com/oh-my-fish/oh-my-fish
[screenshot]: https://cloud.githubusercontent.com/assets/195790/20061473/9545bd4c-a4c5-11e6-83da-8b0a954b8a5a.gif
[bira]: https://github.com/oh-my-fish/theme-bira
[dotfiles]: https://github.com/oh-my-fish/oh-my-fish#dotfiles
1 change: 1 addition & 0 deletions fish_greeting.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
function fish_greeting;end
120 changes: 120 additions & 0 deletions fish_prompt.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#!/usr/bin/fish
#
# kawasaki.theme
#
# A theme for the fish shell.
#
# Copyright (c) 2016 Beau Hastings.
# License: GNU General Public License v2
#
# Author: Beau Hastings <[email protected]>
#

#
# Notes:
# To use the theme's virtualenv prompt indicator you should add the following to your init.fish (https://github.com/oh-my-fish/oh-my-fish#dotfiles)
# set --export VIRTUAL_ENV_DISABLE_PROMPT 1

# Override default options
#
## Display the local time
#set -g theme_display_time yes
#
## Display the user's current group
#set -g theme_display_group no
#
## Display git branch status
#set -g theme_display_git no
#
## Display job count
#set -g theme_display_jobs no
#
## By default job count won't display if there are no jobs
#set -g theme_display_jobs_always yes
#
## Don't display if the current working directory is readable/writable
#set -g theme_display_rw no
#
## Don't display virtualenv
#set -g theme_display_virtualenv no
#

# Colors
# TODO: consider displaying colors in the following order: cyan, green, yellow, orange, purple
#
set -g theme_color_error red
set -g theme_color_superuser red
set -g theme_color_user white
set -g theme_color_group 666666
set -g theme_color_host brgreen
set -g theme_color_separator brblack
set -g theme_color_bracket brblue
set -g theme_color_normal normal
set -g theme_color_time 666666
set -g theme_color_path brwhite
set -g theme_color_prompt white
set -g theme_color_virtualenv bryellow

set -g theme_color_status_prefix brblue
set -g theme_color_status_jobs brgreen
set -g theme_color_status_rw brwhite

set -g theme_prompt_char_normal '$'
set -g theme_prompt_char_superuser '#'
set -g theme_prompt_char "$theme_prompt_char_normal"

set -g theme_prompt_superuser_glyph \u2605
set -g theme_prompt_userhost_separator ':'

set -g theme_prompt_segment_separator_char ' '
set -g theme_prompt_segment_separator_color normal

set -g theme_prompt_status_jobs_char '%'
set -g theme_prompt_status_rw_char '.'
set -g theme_prompt_status_separator_char '/'

set -g theme_prompt_virtualenv_char_begin '('
set -g theme_prompt_virtualenv_char_end ')'
set -g theme_prompt_virtualenv_color_char_begin normal
set -g theme_prompt_virtualenv_color_char_end normal

set -g theme_display_time_format '+%I:%M'

#set -g __fish_git_prompt_color_prefix
#set -g __fish_git_prompt_color_suffix
#set -g __fish_git_prompt_color_bare
set -g __fish_git_prompt_color_merging red
set -g __fish_git_prompt_color_branch brblue
#set -g __fish_git_prompt_color_flags
#set -g __fish_git_prompt_color_upstream
#
#__fish_git_prompt_describe_style default|contains|describe|branch
set -g __fish_git_prompt_showcolorhints yes
set -g __fish_git_prompt_show_informative_status yes
set -g __fish_git_prompt_char_stateseparator ' '

# Unofficial fish_git_prompt settings
set -g __fish_git_prompt_char_branch_begin ''
set -g __fish_git_prompt_char_branch_end ''
set -g __fish_git_prompt_color_branch_begin bryellow
set -g __fish_git_prompt_color_branch_end bryellow


function fish_prompt
set -l sep (set_color $theme_prompt_segment_separator_color)$theme_prompt_segment_separator_char(__theme_reset_color)
set -l line1 (string join "$sep" \
(__theme_print_time) \
(__theme_print_userhost) \
(__theme_print_pwd) \
(__theme_print_git_status) \
(__theme_print_jobs) \
(__theme_print_pwd_rw) \
)
set -l line2 (string join " " \
(__theme_print_virtualenv) \
(__theme_print_prompt_char)\
)

echo "$line1"
echo "$line2 "
end
7 changes: 7 additions & 0 deletions fish_right_prompt.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function fish_right_prompt
set -l st $status

if [ $status != 0 ]
echo (set_color $theme_color_error) ↵ $st(set_color $theme_color_normal)
end
end
3 changes: 3 additions & 0 deletions fish_title.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function fish_title
# Customize terminal window title
end
10 changes: 10 additions & 0 deletions functions/__theme_print_git_status.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function __theme_print_git_status
[ "$theme_display_git" = 'no' ]; and return
set -l git_prompt (__fish_git_prompt | command sed -e 's/^ (//' -e 's/)$//')

[ "$git_prompt" = "" ]; and return

print_colored $__fish_git_prompt_char_branch_begin $__fish_git_prompt_color_branch_begin
printf '%s' $git_prompt
print_colored $__fish_git_prompt_char_branch_end $__fish_git_prompt_color_branch_end
end
10 changes: 10 additions & 0 deletions functions/__theme_print_jobs.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function __theme_print_jobs
[ "$theme_display_jobs" = 'no' ]; and return
set -l num_jobs (jobs -l | command wc -l)

if [ $num_jobs -gt 0 -o "$theme_display_jobs_always" = "yes" ]
print_colored "$theme_prompt_status_jobs_char" $theme_color_status_prefix
print_colored "$theme_prompt_status_separator_char" $theme_color_separator
print_colored "$num_jobs" $theme_color_status_jobs
end
end
3 changes: 3 additions & 0 deletions functions/__theme_print_prompt_char.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function __theme_print_prompt_char
print_colored $theme_prompt_char $theme_color_prompt
end
3 changes: 3 additions & 0 deletions functions/__theme_print_pwd.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function __theme_print_pwd
print_colored (prompt_pwd) $theme_color_path
end
11 changes: 11 additions & 0 deletions functions/__theme_print_pwd_rw.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function __theme_print_pwd_rw
[ "$theme_display_rw" = 'no' ]; and return;
set -l rw_chars

if [ -r . ]; set rw_chars r; end
if [ -w . ]; set rw_chars $rw_chars"w"; end

print_colored $theme_prompt_status_rw_char $theme_color_status_prefix
print_colored $theme_prompt_status_separator_char $theme_color_separator
print_colored $rw_chars $theme_color_status_rw
end
8 changes: 8 additions & 0 deletions functions/__theme_print_superuser.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function __theme_print_superuser
if [ (command id -u) = "0" ]
set theme_prompt_char "$theme_prompt_char_superuser"
print_colored $theme_prompt_superuser_glyph $theme_color_superuser
else
set theme_prompt_char "$theme_prompt_char_normal"
end
end
4 changes: 4 additions & 0 deletions functions/__theme_print_time.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function __theme_print_time
[ "$theme_display_time" = 'yes' ]; or return;
print_colored (command date $theme_display_time_format) $theme_color_time
end
13 changes: 13 additions & 0 deletions functions/__theme_print_userhost.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function __theme_print_userhost
echo -ns (__theme_print_superuser) $USER (__theme_reset_color)

if [ "$theme_display_group" != 'no' ]
print_colored $theme_prompt_userhost_separator $theme_color_separator
print_colored (id -gn) $theme_color_group
end

set -l hostname (command hostname | cut -d '.' -f 1)

print_colored "@" $theme_color_separator
print_colored "$hostname" $theme_color_host
end
14 changes: 14 additions & 0 deletions functions/__theme_print_virtualenv.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function __theme_print_virtualenv
[ "$theme_display_virtualenv" = 'no' -o -z "$VIRTUAL_ENV" ]; and return

set -l basename (basename "$VIRTUAL_ENV")

# special case for Aspen magic directories (http://www.zetadev.com/software/aspen/)
if test "$basename" = "__"
set basename (basename (dirname "$VIRTUAL_ENV"))
end

print_colored $theme_prompt_virtualenv_char_begin $theme_prompt_virtualenv_color_char_begin
print_colored $basename $theme_color_virtualenv
print_colored $theme_prompt_virtualenv_char_end $theme_prompt_virtualenv_color_char_end
end
3 changes: 3 additions & 0 deletions functions/__theme_reset_color.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function __theme_reset_color
set_color $theme_color_normal
end
16 changes: 16 additions & 0 deletions functions/print_colored.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function print_colored
set -l bgcolor normal
set -l fgcolor normal
set -l text

if contains -- -b in $argv[1]
set bgcolor $argv[2]
set fgcolor $argv[-1]
set text $argv[3..-2]
else
set fgcolor $argv[-1]
set text $argv[1..-2]
end

printf '%s%s%s' (set_color -b $bgcolor $fgcolor) (string join " " $text) (__theme_reset_color)
end

0 comments on commit 28c7181

Please sign in to comment.