How can I print a path in Terminal with the home folder path replaced by a ~?
pwd
/Users/denz/projects/coolApp
But I want to something like this
~/projects/coolApp
bashmacosterminal
How can I print a path in Terminal with the home folder path replaced by a ~?
pwd
/Users/denz/projects/coolApp
But I want to something like this
~/projects/coolApp
Best Answer
Here's a function:
Add this function to a profile file and use
pwdr
.In
bash
you can also use parameter expansion and avoid the call tosed
by using the rather magically lookingThe
${...}
expression can be used anywhere a shell variable can be used as well, theecho
is just for demonstration purposes.