Bash – Match empty line in an alias .bashrc

aliasbashbashrc

I would like to bind my empty line in my bash to a specific command (for example pwd, ls, …), like so :

$<enter>
$/home/

I tried

// ~/.bashrc
alias ="pwd"

But obviously this was rejected :

-bash: alias: =pwd: not found

Any idea ?

Best Answer

An alternative:

PROMPT_COMMAND='_L="$(history 1)"; [ "$_L" != "$_X" ] || echo $PWD && _X="$_L"'
Related Question