mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 20:09:39 -08:00
feat: add fish init script
This commit is contained in:
parent
eb42e0c93a
commit
1676d839af
|
@ -47,13 +47,6 @@ type AnsiRenderer struct {
|
|||
shell string
|
||||
}
|
||||
|
||||
const (
|
||||
zsh = "zsh"
|
||||
bash = "bash"
|
||||
pwsh = "pwsh"
|
||||
powershell5 = "powershell"
|
||||
)
|
||||
|
||||
func (r *AnsiRenderer) init(shell string) {
|
||||
r.shell = shell
|
||||
r.formats = &formats{}
|
||||
|
|
|
@ -273,15 +273,13 @@ Or, when using `~/.profile`.
|
|||
|
||||
Redefine `fish_prompt` in `~/.config/fish/config.fish`:
|
||||
|
||||
```bash
|
||||
function fish_prompt
|
||||
eval oh-my-posh --config ~/.poshthemes/jandedobbeleer.omp.json --error $status --eval
|
||||
end
|
||||
```fish
|
||||
oh-my-posh --init --shell fish --config ~/.poshthemes/jandedobbeleer.omp.json | source
|
||||
```
|
||||
|
||||
Once added, reload your config for the changes to take effect.
|
||||
|
||||
```bash
|
||||
```fish
|
||||
. ~/.config/fish/config.fish
|
||||
```
|
||||
|
||||
|
|
4
init/omp.fish
Normal file
4
init/omp.fish
Normal file
|
@ -0,0 +1,4 @@
|
|||
function fish_prompt
|
||||
set -l omp_duration "$CMD_DURATION$cmd_duration"
|
||||
::OMP:: --config ::CONFIG:: --error $status --execution-time $omp_duration
|
||||
end
|
11
main.go
11
main.go
|
@ -14,7 +14,12 @@ import (
|
|||
var Version = "development"
|
||||
|
||||
const (
|
||||
noExe = "echo \"Unable to find Oh my Posh executable\""
|
||||
noExe = "echo \"Unable to find Oh my Posh executable\""
|
||||
zsh = "zsh"
|
||||
bash = "bash"
|
||||
pwsh = "pwsh"
|
||||
fish = "fish"
|
||||
powershell5 = "powershell"
|
||||
)
|
||||
|
||||
type args struct {
|
||||
|
@ -149,7 +154,7 @@ func initShell(shell, config string) string {
|
|||
switch shell {
|
||||
case pwsh:
|
||||
return fmt.Sprintf("Invoke-Expression (@(&\"%s\" --print-init --shell pwsh --config %s) -join \"`n\")", executable, config)
|
||||
case zsh, bash:
|
||||
case zsh, bash, fish:
|
||||
return printShellInit(shell, config)
|
||||
default:
|
||||
return fmt.Sprintf("echo \"No initialization script available for %s\"", shell)
|
||||
|
@ -168,6 +173,8 @@ func printShellInit(shell, config string) string {
|
|||
return getShellInitScript(executable, config, "init/omp.zsh")
|
||||
case bash:
|
||||
return getShellInitScript(executable, config, "init/omp.bash")
|
||||
case fish:
|
||||
return getShellInitScript(executable, config, "init/omp.fish")
|
||||
default:
|
||||
return fmt.Sprintf("echo \"No initialization script available for %s\"", shell)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue