Bash – How to Expand Aliases Inline

aliasbashexpansion

Is there a way to expand aliases inline in bash?

$bash>alias ll='ls -l '
$bash>ll<tab>
$bash>ls -l 

Best Answer

You can press Ctrl-Alt-e to perform the readline function shell-expand-line which will do alias, history and word expansions. Note that on some keyboards Meta is not Alt. You might need to press Esc then Ctrl-e

The functions alias-expand-line and history-and-alias-expand-line are not bound by default, but you can bind them by adding lines similar to the following to your ~/.inputrc file.

"\e\C-l": alias-expand-line

which would make Ctrl-Alt-l (lower case "ell") perform only alias expansion.

Related Question