├── README.md ├── bin └── mm ├── database └── db ├── install.sh ├── modules ├── basics.sh └── last_status.sh ├── moon.sh └── pics ├── IMG_20210612_193634.jpg └── moon.png /README.md: -------------------------------------------------------------------------------- 1 | # Moon 2 | A modular prompt for BASH made for speed! 3 | 4 | Moon is a modular prompt that has been crafted with speed in mind. 5 | Moon supports usermade modules and is fully customisable. 6 | Moon is written completely in BASH which makes it faster than prompts written in Python, Go or Rust (atleast on my PC :p) 7 | 8 | ## In action 9 | ![Settings Window](https://raw.githubusercontent.com/ayush7788/moon/main/pics/moon.png) 10 | ![Settings Window](https://raw.githubusercontent.com/ayush7788/moon/main/pics/IMG_20210612_193634.jpg) 11 | 12 | 13 | ## Dependencies 14 | - wget or curl (wget recommended, as `mm` uses wget to fetch modules) 15 | - git (install only and for "git\_module" module) 16 | - Any Nerd Font (eg. Iosevka Nerd Font) 17 | 18 | ## Installation 19 | With `curl` 20 | ``` 21 | bash -c "$(curl -fsSL https://raw.githubusercontent.com/ayush7788/moon/main/install.sh)" 22 | ``` 23 | or with `wget` 24 | ``` 25 | bash -c "$(wget -qO- https://raw.githubusercontent.com/ayush7788/moon/main/install.sh)" 26 | ``` 27 | 28 | ## Modules for Moon 29 | [This repository](https://github.com/ayush7788/moon_modules) contains modules for Moon Prompt. 30 | 31 | ### Available Modules 32 | - `username` in `basics.sh` 33 | - `hostname` in `basics.sh` 34 | - `working_dir` in `basics.sh` 35 | - `check_last_status` in `last_status.sh` 36 | - `battery` in `battery.sh` 37 | - `git_module` in `git.sh` 38 | - `date_module` in `date.sh` 39 | - `time_module` in `date.sh` 40 | 41 | ### Installing a module 42 | All modules are contained within a set. 43 | A set can contain many modules in it. To get a module you have to install the whole set. 44 | Modules can be installed with the Moon Manager, `mm` utility. 45 | 46 | To install the module `battery`, you have to install `battery.sh` set. 47 | 48 | First update the database with - 49 | ```shell 50 | mm -u 51 | ``` 52 | 53 | Then to install a set do - 54 | ```shell 55 | mm -i battery.sh 56 | ``` 57 | 58 | ### Using a module 59 | To use a module, include it in the `MODULES` variable in `~/.config/moon/moon.sh` 60 | ```shell 61 | # Other stuff 62 | MODULES="\n\ 63 | $(working_dir) $(battery)\ 64 | \n >>" 65 | 66 | prompt=$MODULES 67 | export PS1=$prompt 68 | ``` 69 | -------------------------------------------------------------------------------- /bin/mm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # __ __ ___ ___ _ _ 4 | #| \/ |/ _ \ / _ \| \ | | 5 | #| |\/| | | | | | | | \| | 6 | #| | | | |_| | |_| | |\ | 7 | #|_| |_|\___/ \___/|_| \_| 8 | # Moon Manager by CLAW (https://github.com/clawbhaiya) 9 | 10 | 11 | repo="https://raw.githubusercontent.com/acidicneko/moon_modules/main/modules" 12 | data_repo="https://raw.githubusercontent.com/acidicneko/moon/main/database" 13 | prefix="$HOME/.config/moon" 14 | VERSION=1.0.5 15 | 16 | help_mm () { 17 | printf "Moon Manager Utility by Acidicneko (https://github.com/acidicneko)\n\ 18 | \noption: usage\n\n\ 19 | -s: search in database\n\ 20 | -i: install a set from database\n\ 21 | -r: uninstall a set\n\ 22 | -l: list all installed sets\n\ 23 | -la: list the whole database\n\ 24 | -u: update database\n\ 25 | -su: update mm itself\n\ 26 | -v: prints version information\n\ 27 | -h: bring up help\n\n" 28 | } 29 | 30 | search () { 31 | test -f "$prefix"/database/db 32 | if [ $? = 1 ] ; then 33 | printf "\e[31mmm: database file not found! run \"mm -u\" to download database\n\e[0m" 34 | return 1 35 | fi 36 | result="$(cat "$prefix"/database/db | grep $1)" 37 | if [ "$result" = "" ] ; then 38 | printf "\e[31mmm: no such module or set in database: %s\n" "$1" 39 | return 1 40 | fi 41 | IFS=' ' 42 | read -a tokens <<< "$result" 43 | echo "Module: ${tokens[0]}" 44 | echo "Set: ${tokens[1]}" 45 | echo "Version: ${tokens[2]}" 46 | return 0 47 | } 48 | 49 | search_set () { 50 | test -f "$prefix"/database/db 51 | if [ $? = 1 ] ; then 52 | printf "\e[31mmm: database file not found! run \"mm -u\" to dowload database\n\e[0m" 53 | return 1 54 | fi 55 | result="$(cat "$prefix"/database/db | grep $1)" 56 | if [ "$result" = "" ] ; then 57 | printf "\e[31mmm: no such module or set in database: %s\n" "$1" 58 | return 1 59 | fi 60 | IFS=' ' 61 | read -a tokens <<< "$result" 62 | if [ "${tokens[1]}" != "$1" ] ; then 63 | printf "\e[31mmm: no such set found in database: %s\n\e[0m" "$1" 64 | return 1 65 | fi 66 | return 0 67 | } 68 | 69 | install () { 70 | printf "\e[32mmm: installing set \"%s\"...\n\e[0m" "$1" 71 | search_set "$1" 72 | if [ $? = 1 ] ; then 73 | printf "\e[31mmm: error\e[0m\n" 74 | return 1 75 | fi 76 | test -f "$prefix"/modules/"$1" 77 | if [ $? = 0 ] ; then 78 | printf "\e[32mmm: set already installed!\n\e[0m" "$1" 79 | return 2 80 | fi 81 | printf "\e[32mmm: downloading set: %s...\n\e[0m" "$1" 82 | 83 | curl "$repo"/"$1" --output "$prefix"/modules/"$1" 84 | 85 | if [ $? != 0 ] ; then 86 | printf "\e[31mmm: something went wrong during installing set: %s\n\e[0m" "$1" 87 | return 1 88 | fi 89 | printf "\e[32mmm: set \"%s\" installed!\n\e[0m" "$1" 90 | } 91 | 92 | list_installed () { 93 | printf "\e[32mmm: installed sets -> \n\e[0m" 94 | for i in "$prefix"/modules/* ; do 95 | echo "$i" 96 | done 97 | } 98 | 99 | uninstall () { 100 | test -f "$prefix"/modules/"$1" 101 | if [ $? = 1 ] ; then 102 | printf "\e[31mmm: no such module installed: %s\e[0m\n" "$1" 103 | return 1 104 | fi 105 | rm "$prefix"/modules/"$1" 106 | if [ $? != 0 ] ; then 107 | printf "\e[31mmm: something went wrong while removing set: %s\e[0m\n" "$1" 108 | return 1 109 | fi 110 | printf "\e[32mmm: set uninstalled: %s\n\e[0m" "$1" 111 | } 112 | 113 | update_database () { 114 | printf "\e[32mmm: updating database...\n\e[0m" 115 | test -f "$prefix"/database/db 116 | if [ $? = 0 ] ; then 117 | rm "$prefix"/database/db 118 | fi 119 | wget "$data_repo"/db -P "$prefix"/database/ 120 | if [ $? != 0 ] ; then 121 | printf "\e[31mmm: something went wrong during updating database\n\e[0m" 122 | return 1 123 | fi 124 | printf "\e[32mmm: database updated!\n\e[0m" 125 | } 126 | 127 | update_self () { 128 | printf "\e[32mmm: updating mm itself...\n\e[0m" 129 | rm "$prefix"/bin/mm 130 | wget "https://raw.githubusercontent.com/clawbhaiya/moon/main/bin/mm" -P "$prefix"/bin/ 131 | chmod +x "$prefix"/bin/mm 132 | printf "updated!!\n\n" 133 | } 134 | 135 | if [ "$1" = "-s" ] ; then 136 | search "$2" 137 | elif [ "$1" = "-i" ] ; then 138 | install "$2" 139 | elif [ "$1" = "-v" ] ; then 140 | printf "Moon Manager v%s\nBy CLAW (https://github.com/clawbhaiya)\n" "$VERSION" 141 | elif [ "$1" = "-l" ] ; then 142 | list_installed 143 | elif [ "$1" = "-la" ] ; then 144 | cat "$prefix"/database/db 145 | elif [ "$1" = "-r" ] ; then 146 | uninstall "$2" 147 | elif [ "$1" = "-u" ] ; then 148 | update_database 149 | elif [ "$1" = "-su" ] ; then 150 | update_self 151 | elif [ "$1" = "-h" ] ; then 152 | help_mm 153 | else 154 | printf "\e[31mmm: unknow option: %s\e[0m\n" "$1" 155 | fi 156 | 157 | -------------------------------------------------------------------------------- /database/db: -------------------------------------------------------------------------------- 1 | git git.sh 1 2 | battery battery.sh 1 3 | time date.sh 1 4 | date date.sh 1 5 | username basics.sh 1 6 | hostname basics.sh 1 7 | working_dir basics.sh 1 8 | check_last_status last_status.sh 2 9 | cmd_duration cmd_duration.sh 1 10 | modern_prompt modern_prompt.sh 1 11 | modern_dir modern_prompt.sh 1 12 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | printf "\e[1;34m __ __ ___ ___ _ _\n" 2 | printf "| \/ |/ _ \ / _ \| \ | |\n" 3 | printf "| |\/| | | | | | | | \| |\n" 4 | printf "| | | | |_| | |_| | |\ |\n" 5 | printf "|_| |_|\___/ \___/|_| \_|\n\n" 6 | 7 | printf "\e[1;37mMoon Prompt Installer by CLAW (https://github.com/clawbhaiya)\e[0m\n" 8 | 9 | dir=$HOME/.config/moon 10 | read -p "Install Moon to $dir ? [y/n]: " choice 11 | 12 | if [[ "$choice" = "n" ]] ; then 13 | printf "\e[31mInstall cancelled!\e[0m\n" 14 | exit 1 15 | fi 16 | 17 | printf "\e[1;33mInstalling Moon to $dir...\e[0m\n" 18 | 19 | if [ -d "$dir" ]; then 20 | printf "\e[31mMoon is already installed!\e[0m\n" 21 | exit 1 22 | else 23 | git clone https://github.com/clawbhaiya/moon.git $dir 24 | chmod +x "$dir"/bin/mm 25 | fi 26 | echo "PATH=\"\$PATH:$dir/bin/\"" >> "$HOME"/.bashrc 27 | echo . "$dir/moon.sh" >> "$HOME"/.bashrc 28 | 29 | printf "\e[1;32mMoon Prompt installed! Please restart BASH...\e[0m\n" 30 | 31 | -------------------------------------------------------------------------------- /modules/basics.sh: -------------------------------------------------------------------------------- 1 | username () { 2 | echo "\e[${USERNAME_COL}m\u\e[0m" 3 | } 4 | 5 | hostname () { 6 | echo "\e[${HOSTNAME_COL}m\h\e[0m" 7 | } 8 | 9 | working_dir () { 10 | echo "\e[${WORKING_DIR_COL}m\w\e[0m" 11 | } 12 | 13 | -------------------------------------------------------------------------------- /modules/last_status.sh: -------------------------------------------------------------------------------- 1 | check_last_status_main () { 2 | exit_code=$? 3 | if [[ $exit_code != 0 ]] ; then 4 | status="" 5 | [[ "$SHOW_EXIT_CODE" == 1 ]] && 6 | status="${status} $exit_code" 7 | echo "$status" 8 | return 1 9 | fi 10 | echo " " 11 | return 0 12 | } 13 | 14 | check_last_status () { 15 | echo "\$(check_last_status_main)" 16 | } 17 | -------------------------------------------------------------------------------- /moon.sh: -------------------------------------------------------------------------------- 1 | # __ __ ___ ___ _ _ 2 | # | \/ |/ _ \ / _ \| \ | | 3 | # | |\/| | | | | | | | \| | 4 | # | | | | |_| | |_| | |\ | 5 | # |_| |_|\___/ \___/|_| \_| 6 | # Moon Prompt for BASH by CLAW (https://github.com/clawbhaiya) 7 | # 8 | ## A set of basic modules have been provided. 9 | ## To make your own modules check the documentation 10 | 11 | 12 | ## DO NOT PLAY WITH THIS TwT 13 | # include all module files 14 | for i in $HOME/.config/moon/modules/* ; do 15 | . "$i" 16 | done 17 | 18 | ## Options provided by modules can be configures here 19 | # configuration for modules 20 | USERNAME_COL="1;37" # controls username module color 21 | HOSTNAME_COL="1;32" # controls hostname module color 22 | WORKING_DIR_COL="1;34" # controls workind_dir module color 23 | GIT_COL="1;36" # controls git_module module color 24 | DATE_COL="1;35" # controls date_module & time_module colors 25 | SHOW_EXIT_CODE=1 # defines if exit code should be shown (1 = true, 0 = false) 26 | CMD_DURATION_COL="1;33" # controls cmd_duration module col 27 | #LOW_BATTERY=20 # controls low battery warning level 28 | 29 | # include your modules here 30 | ## Non modular text can be also written here, eg, newlines, special characters, etc 31 | MODULES="\n\ 32 | $(username)@$(hostname) | $(working_dir) $(check_last_status)\ 33 | \n  " 34 | 35 | prompt="$MODULES" 36 | 37 | export PS1="$prompt" 38 | -------------------------------------------------------------------------------- /pics/IMG_20210612_193634.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acidicneko/moon/f742b780fc3b805663f7ef064c4e7ceb9956bac3/pics/IMG_20210612_193634.jpg -------------------------------------------------------------------------------- /pics/moon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acidicneko/moon/f742b780fc3b805663f7ef064c4e7ceb9956bac3/pics/moon.png --------------------------------------------------------------------------------