https://github.com/ittus/firebase-prompt
Show current firebase project on shell prompt
https://github.com/ittus/firebase-prompt
bash bash-script console firebase firebase-cli firebase-console zsh
Last synced: about 2 months ago
JSON representation
Show current firebase project on shell prompt
- Host: GitHub
- URL: https://github.com/ittus/firebase-prompt
- Owner: ittus
- Created: 2018-08-10T06:30:45.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-01-29T09:10:33.000Z (over 5 years ago)
- Last Synced: 2025-03-28T17:05:36.945Z (2 months ago)
- Topics: bash, bash-script, console, firebase, firebase-cli, firebase-console, zsh
- Size: 148 KB
- Stars: 8
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Firebase prompt
Show current firebase project on terminal prompt
When working on multiple stages (development, staging, production), developers usually use
`firebase use [project_id_or_alias]`
to switch between projects. It's very easy to run a command on production environment instead of development, which is very dangerous.
This script intends to show firebase project name on **shell prompt**. I hope this can help prevent unexpected situation.
## How to set up
### 1. Bash
Add following script to the end of `~/.bash_profile`
```bash
prompt_firebase() {
local fb_project=$(grep \"$(pwd)\" ~/.config/configstore/firebase-tools.json | cut -d" " -f2)
if [[ -n $fb_project ]]; then
echo [$fb_project]
fi
}
export PS1="\$(prompt_firebase)"$PS1
```Then run `source ~/.bash_profile` or open new terminal window
### 2. iTerm2 with oh-my-zsh
For example, if you're using `agnoster` theme:
Edit `~/.oh-my-zsh/themes/agnoster.zsh-theme````bash
prompt_firebase() {
local fb_project=$(grep \"$(pwd)\" ~/.config/configstore/firebase-tools.json | cut -d" " -f2)
if [[ -n $fb_project ]]; then
prompt_segment red black $fb_project
fi
}
```and add `prompt_firebase` to `build_prompt` functions
```bash
build_prompt() {
RETVAL=$?
prompt_status
prompt_virtualenv
prompt_context
prompt_dir
prompt_git
prompt_bzr
prompt_hg
prompt_firebase
prompt_end
}
```Then run `source ~/.zshrc` or open new terminal window

## More Info
- https://www.freecodecamp.org/news/how-to-show-your-current-firebase-project-name-on-the-command-line-prompt-to-prevent-dangerous-1bfee6293811/