{"id":17984429,"url":"https://github.com/adoyle-h/a-bash-prompt","last_synced_at":"2025-03-25T20:32:09.117Z","repository":{"id":64008827,"uuid":"191178769","full_name":"adoyle-h/a-bash-prompt","owner":"adoyle-h","description":"A Bash prompt written by pure Bash script. Make Bash great again!","archived":false,"fork":false,"pushed_at":"2023-06-09T16:07:26.000Z","size":59,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-14T13:06:42.150Z","etag":null,"topics":["bash","prompt","ps1","shell","shell-prompt","terminal"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adoyle-h.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-10T14:00:08.000Z","updated_at":"2023-11-28T10:02:31.000Z","dependencies_parsed_at":"2022-11-30T14:30:23.861Z","dependency_job_id":null,"html_url":"https://github.com/adoyle-h/a-bash-prompt","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adoyle-h%2Fa-bash-prompt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adoyle-h%2Fa-bash-prompt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adoyle-h%2Fa-bash-prompt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adoyle-h%2Fa-bash-prompt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adoyle-h","download_url":"https://codeload.github.com/adoyle-h/a-bash-prompt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222090821,"owners_count":16929472,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","prompt","ps1","shell","shell-prompt","terminal"],"created_at":"2024-10-29T18:21:20.453Z","updated_at":"2024-10-29T18:21:21.042Z","avatar_url":"https://github.com/adoyle-h.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A Bash Prompt\n\nA Bash prompt written by pure Bash script. Make Bash great again!\n\nAll prompt sections are configurable, extendable and easy to use.\n\n## Preview\n\n### Responsive prompt (Auto fit to window width).\n\n![responsive-prompt.png](https://media.githubusercontent.com/media/adoyle-h/_imgs/master/github/a-bash-prompt/responsive-prompt.png)\n\n### Show last command exit status\n\n![exit-status.png](https://media.githubusercontent.com/media/adoyle-h/_imgs/master/github/a-bash-prompt/exit-status.png)\n\n### Highlight Backgound jobs:\n\n![jobs-labels.png](https://media.githubusercontent.com/media/adoyle-h/_imgs/master/github/a-bash-prompt/jobs-labels.png)\n\n### Bubble Style and Block Style\n\n![bubble-and-block-styles.png](https://media.githubusercontent.com/media/adoyle-h/_imgs/master/github/a-bash-prompt/bubble-and-block-styles.png)\n\n### Quick preview in container\n\nYou can easily preview it in container.\n\n```sh\n# build docker image (default bash 4.4)\n./build\n# run and enter container (default bash 4.4)\n./run\n\n# or build with specific bash version\n./build 5.0\n./run 5.0\n```\n\n## Prerequisites\n\n### Supported Platform\n\n| Supported | Platform | Version | Main Reasons                       |\n|:---------:|:---------|:--------|:-----------------------------------|\n|     ✅    | MacOS    | *       | -                                  |\n|     ✅    | Linux    | *       | -                                  |\n|     ✅    | BSD      | *       | -                                  |\n|     🚫    | Windows  | -       | Never and ever supported.          |\n\n### Supported Shells\n\n| Supported | Shell | Version          | Main Reasons                                |\n|:---------:|:------|:-----------------|:--------------------------------------------|\n|     ❔    | Zsh   | v5 and higher    | Not tested yet.                             |\n|     ✅    | Bash  | v5 and higher    | -                                           |\n|     ✅    | Bash  | v4.2 and higher  | -                                           |\n|     🚫    | Bash  | v3.x, v4.0, v4.1 | Associative array not supported  until v4.0 |\n\n## Versions\n\nSee [releases][].\nThe versions follows the rules of [SemVer 2.0.0](http://semver.org/).\n\n## Install\n\n```sh\ngit clone https://github.com/adoyle-h/a-bash-prompt.git\necho \"source $PWD/a-bash-prompt/a.prompt.bash\" \u003e ~/.bahsrc\n```\n\n## Default Options\n\nYou can set these variables before and after `source a.prompt.bash` to override defaults options.\n\nYou can modify `PROMPT_NO_COLOR`, `PROMPT_COLOR_*` and `PROMPT_STYLE_*` variables to change the display in runtime.\n\nAvailable colors: RED GREEN YELLOW BLUE PURPLE CYAN WHITE BLACK GREY\nAvailable styles: bubble block square none\n(Case-sensitive)\n\nBelows are default options.\n\n### Others\n\n```sh\nPROMPT_NO_COLOR=0               # If set 1, no color printed\nPROMPT_NO_MODIFY_LSCOLORS=0\nPROMPT_PS1=''                   # If `PROMPT_PS1` is not empty, the PS1 in framework will be override.\n```\n\n### Layout\n\nYou can rearrange the layout.\n\n```sh\nPROMPT_LAYOUT_RIGHT=( exit_status jobs python_virtualenv time )\nPROMPT_LAYOUT_LEFT=( left_icon user hostname cwd )\nPROMPT_LAYOUT_MAIN=( indicator git reset_text )\n```\n\n### Time Clock\n\n```sh\nPROMPT_ENABLE_TIME=1\nPROMPT_STYLE_TIME=block\nPROMPT_COLOR_TIME=YELLOW\nPROMPT_FORMAT_TIME='T%s'        # You can set ' %s'\nPROMPT_PS1_TIME_DATE_FORMAT='+%H:%M:%S' # date +%H:%M:%S\n```\n\n### Front and Backgound Jobs\n\n```sh\nPROMPT_ENABLE_JOB=1\nPROMPT_STYLE_JOB=block\nPROMPT_COLOR_JOB=CYAN\nPROMPT_FORMAT_JOB='Jobs %s'\n```\n\n### Process Exit Status Code\n\n```sh\nPROMPT_ENABLE_EXIT_STATUS=1\nPROMPT_STYLE_EXIT_STATUS=block\nPROMPT_COLOR_EXIT_STATUS=RED\nPROMPT_FORMAT_EXIT_STATUS='😱 %s'\n```\n\n### Current Work Directory\n\n```sh\nPROMPT_ENABLE_CWD=1\nPROMPT_STYLE_CWD=block\nPROMPT_COLOR_CWD=GREEN\nPROMPT_FORMAT_CWD=' %s '\n```\n\n### Current User\n\n```sh\nPROMPT_ENABLE_USER=0\nPROMPT_STYLE_USER=square\nPROMPT_COLOR_USER=CYAN\nPROMPT_FORMAT_USER='%s'\n```\n\n### Hostname\n\n```sh\nPROMPT_ENABLE_HOSTNAME=0\nPROMPT_STYLE_HOSTNAME=square\nPROMPT_COLOR_HOSTNAME=PURPLE\nPROMPT_FORMAT_HOSTNAME='%s'\n```\n\n### Git branch and status\n\n```sh\nPROMPT_ENABLE_GIT=1\nPROMPT_COLOR_GIT=BLUE\nPROMPT_STYLE_GIT=none\nPROMPT_FORMAT_GIT='%b'\n# See https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh\nGIT_PS1_SHOWDIRTYSTATE=1\nGIT_PS1_SHOWSTASHSTATE=1\nGIT_PS1_SHOWUNTRACKEDFILES=1\nGIT_PS1_SHOWCOLORHINTS=true\nGIT_PS1_SHOWUPSTREAM=git\nGIT_PS1_DESCRIBE_STYLE=branch\nGIT_PS1_STATESEPARATOR=' '\n```\n\n### Python Virtual Environment\n\n```sh\nPROMPT_ENABLE_PYTHON_VENV=1\nPROMPT_STYLE_PYTHON_VENV=block\nPROMPT_COLOR_PYTHON_VENV=PURPLE\nPROMPT_FORMAT_PYTHON_VENV='%s'\nPROMPT_PYTHON_VIRTUALENV_LEFT='venv:'\n```\n\n### Left Icon\n\n```sh\nPROMPT_ENABLE_LEFT_ICON=1\nPROMPT_STYLE_LEFT_ICON=none\nPROMPT_COLOR_LEFT_ICON=GREEN\nPROMPT_FORMAT_LEFT_ICON='%s '\nPROMPT_PS1_LEFT_ICON='⧉ '\n```\n\n### Indicator\n\n```sh\nPROMPT_ENABLE_INDICATOR=1\nPROMPT_STYLE_INDICATOR=none\nPROMPT_COLOR_INDICATOR=GREEN\nPROMPT_FORMAT_INDICATOR='%s '\nPROMPT_PS1_INDICATOR='𝕬'\n```\n\n### History Append\n\ncall `history -a` each time.\n\n```sh\nPROMPT_ENABLE_HISTORY_APPEND=0\n```\n\n## Advanced Usage\n\n### Write section to extend prompt\n\n```sh\n__ps1_section_hello() {\n  [[ ${PROMPT_ENABLE_HELLO:-1} == 0 ]] \u0026\u0026 return\n  local PROMPT_STYLE_HELLO=${PROMPT_STYLE_HELLO:-block}\n  local PROMPT_COLOR_HELLO=${PROMPT_COLOR_HELLO:-GREEN}\n  local PROMPT_FORMAT_HELLO=${PROMPT_FORMAT_HELLO:-'%s'}\n  __ps1_print_section HELLO \"hello world\"\n}\n\nPROMPT_LAYOUT_RIGHT+=( hello )\n```\n\nThen you will get these.\n\n![write-your-section.png](https://media.githubusercontent.com/media/adoyle-h/_imgs/master/github/a-bash-prompt/write-your-section.png)\n\n### Git-prompt is slow\n\nIf you feel slow in git directory. Disable these options will make it faster.\n\n```sh\nGIT_PS1_SHOWDIRTYSTATE=\nGIT_PS1_SHOWSTASHSTATE=\nGIT_PS1_SHOWUNTRACKEDFILES=\n```\n\nSee https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh\n\nYou can also disable git-prompt completely by `unset __git_ps1`.\n\n### Override PS1\n\nIf `PROMPT_PS1` set, the PS1 in framework will be override.\n\n```sh\nPROMPT_PS1='\\u@\\h:\\w\\$ '\n```\n\n### Disable prompt color\n\nSet `PROMPT_NO_COLOR=1`.\n\n![no-color.png](https://media.githubusercontent.com/media/adoyle-h/_imgs/master/github/a-bash-prompt/no-color.png)\n\n### Do not modify LS_COLORS variable\n\na-bash-prompt will modify `LSCOLORS` and `LS_COLORS` by default.\n\nSet `PROMPT_NO_MODIFY_LSCOLORS=1` to disable it.\n\n### Refresh bash_history\n\nbash_history file will not be refreshed before exit shell by default.\n\nIf you use tmux, it may cause some troubles.\nSet `PROMPT_ENABLE_HISTORY_APPEND=1` to refresh bash_history each command.\n\n## Suggestion, Bug Reporting, Contributing\n\n**Before opening new Issue/Discussion/PR and posting any comments**, please read [Contributing Guidelines](https://gcg.adoyle.me/CONTRIBUTING).\n\n## Copyright and License\n\nCopyright 2019-2023 ADoyle (adoyle.h@gmail.com). Some Rights Reserved.\nThe project is licensed under the **BSD 3-clause License**.\n\nSee the [LICENSE][] file for the specific language governing permissions and limitations under the License.\n\nSee the [NOTICE][] file distributed with this work for additional information regarding copyright ownership.\n\n## Other Projects\n\n- [shell-general-colors](https://github.com/adoyle-h/shell-general-colors): To generate [colors.bash](./colors.bash).\n- [one.share](https://github.com/one-bash/one.share)\n- [Other shell projects](https://github.com/adoyle-h?tab=repositories\u0026q=\u0026type=source\u0026language=shell\u0026sort=stargazers) created by me.\n\n\n\u003c!-- links --\u003e\n\n[LICENSE]: ./LICENSE\n[NOTICE]: ./NOTICE\n[releases]: https://github.com/adoyle-h/a-bash-prompt/releases\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadoyle-h%2Fa-bash-prompt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadoyle-h%2Fa-bash-prompt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadoyle-h%2Fa-bash-prompt/lists"}