Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Current Working Directory output in an alias

Tags:

bash

I want to create an alias that will print out the current working directory sub name.

I have this:

BASENAME=${PWD##*/}
alias wai="echo $BASENAME"

This outputs the directory subname of the directory .bashrc is stored in. I want it to be the current working directory.

Sorry if this is simple, I'm new to bash.

like image 480
Nick Barone Avatar asked Oct 26 '25 10:10

Nick Barone


1 Answers

The trick is really just in the single quotes. I believe you can achieve this by doing the following:

'echo ${PWD##*/}'

More details: Difference between single and double quotes in Bash

like image 68
kgong Avatar answered Oct 29 '25 00:10

kgong



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!