mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -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
|
shell string
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
|
||||||
zsh = "zsh"
|
|
||||||
bash = "bash"
|
|
||||||
pwsh = "pwsh"
|
|
||||||
powershell5 = "powershell"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (r *AnsiRenderer) init(shell string) {
|
func (r *AnsiRenderer) init(shell string) {
|
||||||
r.shell = shell
|
r.shell = shell
|
||||||
r.formats = &formats{}
|
r.formats = &formats{}
|
||||||
|
|
|
@ -273,15 +273,13 @@ Or, when using `~/.profile`.
|
||||||
|
|
||||||
Redefine `fish_prompt` in `~/.config/fish/config.fish`:
|
Redefine `fish_prompt` in `~/.config/fish/config.fish`:
|
||||||
|
|
||||||
```bash
|
```fish
|
||||||
function fish_prompt
|
oh-my-posh --init --shell fish --config ~/.poshthemes/jandedobbeleer.omp.json | source
|
||||||
eval oh-my-posh --config ~/.poshthemes/jandedobbeleer.omp.json --error $status --eval
|
|
||||||
end
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Once added, reload your config for the changes to take effect.
|
Once added, reload your config for the changes to take effect.
|
||||||
|
|
||||||
```bash
|
```fish
|
||||||
. ~/.config/fish/config.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"
|
var Version = "development"
|
||||||
|
|
||||||
const (
|
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 {
|
type args struct {
|
||||||
|
@ -149,7 +154,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, bash:
|
case zsh, bash, fish:
|
||||||
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)
|
||||||
|
@ -168,6 +173,8 @@ func printShellInit(shell, config string) string {
|
||||||
return getShellInitScript(executable, config, "init/omp.zsh")
|
return getShellInitScript(executable, config, "init/omp.zsh")
|
||||||
case bash:
|
case bash:
|
||||||
return getShellInitScript(executable, config, "init/omp.bash")
|
return getShellInitScript(executable, config, "init/omp.bash")
|
||||||
|
case fish:
|
||||||
|
return getShellInitScript(executable, config, "init/omp.fish")
|
||||||
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