feat: add bash init script

This commit is contained in:
Jan De Dobbeleer 2020-12-23 13:12:10 +01:00 committed by Jan De Dobbeleer
parent 1b5263e48e
commit 8e226ac332
3 changed files with 14 additions and 9 deletions

View file

@ -252,14 +252,8 @@ source ~/.zshrc
Add the following to `~/.bashrc` (or `~/.profile` on MacOS): Add the following to `~/.bashrc` (or `~/.profile` on MacOS):
```bash ```bashrc
function _update_ps1() { eval "$(oh-my-posh --init --shell bash --config ~/.poshthemes/jandedobbeleer.omp.json)"
eval "$(oh-my-posh --config ~/.poshthemes/jandedobbeleer.omp.json --error $? --eval)"
}
if [ "$TERM" != "linux" ] && [ -x "$(command -v oh-my-posh)" ]; then
PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi
``` ```
Once added, reload your profile for the changes to take effect. Once added, reload your profile for the changes to take effect.

9
init/omp.bash Normal file
View file

@ -0,0 +1,9 @@
export POSH_THEME=::CONFIG::
function _update_ps1() {
PS1="$(::OMP:: --config $POSH_THEME --error $?)"
}
if [ "$TERM" != "linux" ] && [ -x "$(command -v ::OMP::)" ]; then
PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi

View file

@ -149,7 +149,7 @@ func initShell(shell, config string) string {
switch shell { switch shell {
case pwsh: case pwsh:
return fmt.Sprintf("Invoke-Expression (@(&\"%s\" --print-init --shell pwsh --config %s) -join \"`n\")", executable, config) return fmt.Sprintf("Invoke-Expression (@(&\"%s\" --print-init --shell pwsh --config %s) -join \"`n\")", executable, config)
case zsh: case zsh, bash:
return printShellInit(shell, config) return printShellInit(shell, config)
default: default:
return fmt.Sprintf("echo \"No initialization script available for %s\"", shell) return fmt.Sprintf("echo \"No initialization script available for %s\"", shell)
@ -166,6 +166,8 @@ func printShellInit(shell, config string) string {
return getShellInitScript(executable, config, "init/omp.ps1") return getShellInitScript(executable, config, "init/omp.ps1")
case zsh: case zsh:
return getShellInitScript(executable, config, "init/omp.zsh") return getShellInitScript(executable, config, "init/omp.zsh")
case bash:
return getShellInitScript(executable, config, "init/omp.bash")
default: default:
return fmt.Sprintf("echo \"No initialization script available for %s\"", shell) return fmt.Sprintf("echo \"No initialization script available for %s\"", shell)
} }