fix(install.sh,zsh-theme): fix export "gcloud" to $PATH, remove "node" as a dependency for showing Firebase project, show Google Cloud Project ID

This commit is contained in:
Anton Shubin 2022-01-31 20:54:09 +01:00
parent 6748b510b0
commit cb671f5947
5 changed files with 33 additions and 31 deletions

View File

@ -16,6 +16,6 @@ And it takes 15-30 min, so make sure to grab your favourite tea or coffee meanwh
# Install oh-my-zsh (it restarts shell, so it has to be separate)
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# Main installation script
# Main installation script (make sure you use `zsh` to run the script, otherwise you'll run into weird errors)
zsh ./install.sh
```

View File

@ -12,8 +12,8 @@ echo '✅ Brew installation complete \n'
echo '▶️ Installing Apps with Brew...'
brew bundle
# Configure Google Cloud CLI $PATH and autocomplete
source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc"
source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc"
echo 'source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc"' >> ~/.zshrc
echo 'source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc"' >> ~/.zshrc
echo '✅ Apps installation complete \n'
echo '▶️ Installing Node.js via NVM...'
@ -29,11 +29,9 @@ echo '✅ Node.js installation complete \n'
echo '▶️ Configuring custom Spy4x theme for Oh-my-zsh...'
cd "$script_dir"
cp -R oh-my-zsh-theme/* ~/.oh-my-zsh/custom/
echo 'ZSH_THEME="spy4x"' >> ~/.zshrc
cp my.zsh-theme ~/.oh-my-zsh/themes/
echo 'ZSH_THEME="my"' >> ~/.zshrc
echo 'source $ZSH/oh-my-zsh.sh' >> ~/.zshrc
mkdir ~/projects && cd ~/projects
echo 'cd ~/projects' >> ~/.zshrc # Set ~/projects as default dir to open in terminal
source ~/.zshrc
echo '✅ Configuration complete \n'

27
my.zsh-theme Normal file
View File

@ -0,0 +1,27 @@
# oh-my-zsh theme
# Example of the look:
#
# ~/projects/project-name master firebase-project-id gcp-project-id
# $ <your input will start here>
#
local return_code='%(?..%{$fg[red]%}%? ↵%{$reset_color%})'
local current_dir='$fg[green]%}%~%{$reset_color%}'
local git_branch='$(git_prompt_info)%{$reset_color%}'
# Get Firebase Project ID or Alias that is associated with current folder
local firebase_project=%{$fg[yellow]%}'$(grep \"$(pwd)\" ~/.config/configstore/firebase-tools.json | cut -d" " -f2 | tr -d "\"" | tr -d ",")'%{$reset_color%}
# Get Google Cloud Project ID that is currently selected
local gcp_project=%{$fg[cyan]%}'$(gcloud config get-value project 2> /dev/null)'%{$reset_color%}
PROMPT="${current_dir} ${git_branch} ${firebase_project} ${gcp_project}
$ "
RPS1="${return_code}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$terminfo[bold]"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
alias yu="yarn upgrade-interactive --latest"
alias gst="git status -sb"

View File

@ -1,9 +0,0 @@
const { readFileSync } = require(`fs`);
const folderPath = process.argv[2];
try {
const pathToFirebaseToolsJson = `${process.env.HOME}/.config/configstore/firebase-tools.json`;
const fileContent = readFileSync(pathToFirebaseToolsJson);
const firebaseToolsJson = JSON.parse(fileContent);
const firebaseProjectName = firebaseToolsJson.activeProjects[folderPath];
firebaseProjectName && console.log(`${firebaseProjectName} `);
} catch (error) {}

View File

@ -1,14 +0,0 @@
local return_code='%(?..%{$fg[red]%}%? ↵%{$reset_color%})'
local current_dir='%{$terminfo[bold]$fg[green]%}%~%{$reset_color%}'
local git_branch='$(git_prompt_info)%{$reset_color%}'
local firebase_project=%{$fg[cyan]%}'$(node ~/.oh-my-zsh/custom/getFirebaseProject.js $(pwd))'%{$reset_color%}
PROMPT="${current_dir} ${firebase_project}${git_branch}
$ "
RPS1="${return_code}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
alias yu="yarn upgrade-interactive --latest"
alias gst="git status -sb"