yaas
yaas

Reputation: 144

Substitute parts of CWD in bash prompt (Git Bash)

This is in Git Bash

I am trying to make my prompt go from

/c/folder $

to

c->folder $

What would I put in my .bashrc to make this work? Is it even possible?

Upvotes: 0

Views: 46

Answers (1)

that other guy
that other guy

Reputation: 123460

You can do arbitrary things to your prompt by setting PROMPT_COMMAND to a function that assigns PS1:

PROMPT_COMMAND="setmyprompt"
setmyprompt() {
  dir="${PWD#/}"
  dir="${dir//\//->}"
  PS1="$dir \\\$ "
}

Upvotes: 1

Related Questions