summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorMichael J. Ryan <tracker1@gmail.com>2021-10-07 11:08:31 -0700
committerGitHub <noreply@github.com>2021-10-07 20:08:31 +0200
commit94d7de7f4eeeaa220c077250b325b02d33ee42b3 (patch)
tree6a253ef6fcb893a4859244e5bf567959d362c431 /docs
parent9f2f5293e335f85e26479c5e1a59cee088736657 (diff)
feat: Add starship_precmd_user_func support for PowerShell. (#3115)
Diffstat (limited to 'docs')
-rw-r--r--docs/advanced-config/README.md26
1 files changed, 26 insertions, 0 deletions
diff --git a/docs/advanced-config/README.md b/docs/advanced-config/README.md
index 412b74de2..2b768a68d 100644
--- a/docs/advanced-config/README.md
+++ b/docs/advanced-config/README.md
@@ -42,6 +42,21 @@ trap blastoff DEBUG # Trap DEBUG *before* running starship
eval $(starship init bash)
```
+## Custom pre-prompt and pre-execution Commands in PowerShell
+
+PowerShell does not have a formal preexec/precmd framework like most other shells.
+Because of this, it is difficult to provide fully customizable hooks in `powershell`.
+However, Starship does give you limited ability to insert your own functions
+into the prompt-rendering procedure:
+
+Create a function named `Invoke-Starship-PreCommand`
+
+```powershell
+function Invoke-Starship-PreCommand {
+ $host.ui.Write("🚀")
+}
+```
+
## Change Window Title
Some shell prompts will automatically change the window title for you (e.g. to
@@ -85,6 +100,17 @@ function set_win_title(){
starship_precmd_user_func="set_win_title"
```
+You can also set a similar output with PowerShell by creating a function named `Invoke-Starship-PreCommand`.
+
+```powershell
+# edit $PROFILE
+function Invoke-Starship-PreCommand {
+ $host.ui.Write("`e]0; PS> $env:USERNAME@$env:COMPUTERNAME`: $pwd `a")
+}
+
+Invoke-Expression (&starship init powershell)
+```
+
## Enable Right Prompt
Some shells support a right prompt which renders on the same line as the input. Starship can