Ubuntu – How to quickly check the value of bash variables, aliases and history commands from terminal

bashcommand lineenvironment-variableshistory

How do you expand in place:

  • bash aliases
  • environment variables
  • history commands

to edit them and check they are correct?

For example, I have some aliases I use for flashing different devices and I just wanted to change the revision number to install, I don't really want to copy/paste from my .bashrc to do this.

Best Answer

bash offers the Ctrl+Alt+e shortcut (from the bash man page):

   shell-expand-line (M-C-e)
          Expand the line as the shell does. This performs alias and
          history expansion as well as all of the shell word expansions.

Examples:

  • ls Ctrl+Alt+e

    ls -aF --color
    
  • !268 Ctrl+Alt+e

    ps -aef
    
  • $PATH Ctrl+Alt+e

    /opt/vagrant/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games