Skip to content

Instantly share code, notes, and snippets.

@Stephen-Harold
Created August 11, 2023 11:14
Show Gist options
  • Save Stephen-Harold/a26f7bc24632f740953d5bdb591363be to your computer and use it in GitHub Desktop.
Save Stephen-Harold/a26f7bc24632f740953d5bdb591363be to your computer and use it in GitHub Desktop.
Edit your prompt (PS1) instantly without sourcing.
#!/bin/bash
# on MacOS
function precmd() {
PS1=$( ~/.promptFile $? );
}
# on Linux
function customPrompt() {
PS1=$( ~/.promptFile $? );
}
PROMPT_COMMAND=customPrompt;
@Stephen-Harold
Copy link
Author

In the prompt file echo a string which will instantly become your PS1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment