diff --git a/.gitignore b/.gitignore index b3299bc..6d711fe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .png .jpg .DS_Store +.vscode diff --git a/README.md b/README.md index c8ff37f..b559f3c 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,31 @@ # RED SNAPPER -![Red Snapper](https://raw.githubusercontent.com/ZuraGuerra/theme-red-snapper/master/redsnapper.jpg) +![Red Snapper, fish shell theme](./images/red-snapper.jpg) -## ><}}*> F E A T U R E S +## Features + Directory path + Git branch name + Git status -+ YOUR OWN PET FISH! ++ A LOYAL FISH PET! -## ><}}*> GIT STATUS -### Untracked changes -Your pet will detect if you added files, but didn't track them. He will open his mouth, hungry of yummy commits! -![fish shell untracked changes](https://raw.githubusercontent.com/ZuraGuerra/theme-red-snapper/master/hungry2.png) +## Installation +### Oh My Fish +```fish +omf theme red-snapper +``` -After you commit, he will close his mouth, satiated. -![fish shell commited](https://raw.githubusercontent.com/ZuraGuerra/theme-red-snapper/master/fed.png) +### Fisher +```fish +fisher install oh-my-fish/theme-red-snapper +``` -### Can't find .git -Something is fishy here! If you are not inside a Git working directory, your pet will go to sleep. -![fish shell not using git](https://raw.githubusercontent.com/ZuraGuerra/theme-red-snapper/master/fishy.png) +## Git Status +### Track changes +Your fish will identify if you've added files without tracking them. It will open its mouth, eager for new commits! +![Red Snapper, preview dirty git repository](./images/preview-dirty-git.jpg) + +After you've committed, it will close its mouth, satisfied. +![Red Snapper, preview clean git repository](./images/preview-clean-git.jpg) +### Can't find .git +Something is fishy here! If you're not within a Git working directory, your pet will go to sleep. +![Red Snapper, preview no git repository](./images/preview-no-git.jpg) diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish index 8b2cf75..cf9c7b5 100644 --- a/functions/fish_prompt.fish +++ b/functions/fish_prompt.fish @@ -6,50 +6,78 @@ function _is_git_dirty echo (command git status -s --ignore-submodules=dirty 2> /dev/null) end +function _init_colors + set -g blue (set_color -o blue) + set -g green (set_color -o green) + set -g red (set_color -o red) + set -g yellow (set_color -o yellow) -function fish_prompt - set -l blue (set_color -o blue) - set -l green (set_color -o green) - set -l red (set_color -o red) - set -l yellow (set_color -o yellow) - - set -l orange_fish (set_color -o FFA500) - set -l yellow_fish (set_color -o FFB732) - set -l red_fish (set_color -o FF725A) - set -l black_fish (set_color -o 3F3F3F) + set -g orange_fish (set_color -o FFA500) + set -g yellow_fish (set_color -o FFB732) + set -g red_fish (set_color -o FF725A) + set -g black_fish (set_color -o 3F3F3F) set_color $fish_color_cwd +end - if [ -n "$SSH_CONNECTION" ] +function _maybe_draw_ssh_conn + if test -n "$SSH_CONNECTION" printf '%s | ' (hostname | head -c 10) end +end - if [ "$HOME" = (pwd) ] +function _draw_current_dir + if test "$HOME" = (pwd) printf "$red~" else - printf (pwd) + printf (prompt_pwd) end +end - printf "$blue ─> " +function _maybe_draw_git_branch + set -l branch_name (_git_branch_name) + if test -n "$branch_name" + switch "$branch_name" + case 'main' 'master' + printf "$red{[%s]}" (string upper $branch_name) + case '*' + printf "$red{[%s]}" "$branch_name" + end + end +end - if [ (_git_branch_name) ] +function _draw_fish - if test (_git_branch_name) = "master" - printf "$red(MASTER)" - else - printf "$red("(_git_branch_name)")" - end + set -l branch_name (_git_branch_name) - if [ (_is_git_dirty) ] - printf " $orange_fish><$yellow_fish}}$black_fish*$red_fish< " + # git dir = false + if not test -n "$branch_name" + printf "$blue><}}*> " + end + + # git dir = true + if test -n "$branch_name" + if test -n (_is_git_dirty) + printf "$orange_fish><$yellow_fish}}$black_fish*$red_fish< " else - printf " $orange_fish><$yellow_fish}}$black_fish*$orange_fish> " + printf "$orange_fish><$yellow_fish}}$black_fish*$orange_fish> " end + end +end - else - printf "$blue><}}*> " +function fish_prompt + _init_colors - end + _maybe_draw_ssh_conn + + _draw_current_dir + + printf "$blue ─> " + + _maybe_draw_git_branch + + printf "\n" + _draw_fish end diff --git a/images/preview-clean-git.jpg b/images/preview-clean-git.jpg new file mode 100644 index 0000000..d5caf04 Binary files /dev/null and b/images/preview-clean-git.jpg differ diff --git a/images/preview-dirty-git.jpg b/images/preview-dirty-git.jpg new file mode 100644 index 0000000..6b4f8f7 Binary files /dev/null and b/images/preview-dirty-git.jpg differ diff --git a/images/preview-no-git.jpg b/images/preview-no-git.jpg new file mode 100644 index 0000000..77f0e5f Binary files /dev/null and b/images/preview-no-git.jpg differ diff --git a/images/red-snapper.jpg b/images/red-snapper.jpg new file mode 100644 index 0000000..b82cc62 Binary files /dev/null and b/images/red-snapper.jpg differ