mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-10 04:54:03 -08:00
feat: add bash init script
This commit is contained in:
parent
1b5263e48e
commit
8e226ac332
|
@ -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
9
init/omp.bash
Normal 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
|
4
main.go
4
main.go
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue