Skip to main content
The 2024 Developer Survey results are live! See the results
Simplify command used
Source Link
JS.
  • 111
  • 4

This is a duplicate of:

how to expand aliases inline in bash?

and

Expand subshell before executing it?

Turns out, BASH uses readline to handle this. Readline has the command shell-expand-line, which is by default assigned the keyboard shortcut Just press Esc followed by Ctrl-Xe (see man readline)

To test, I have the following alias defined in my .bash_profile:

alias cdh='cd ${HOME}'

Starting a new shell/terminal allows me to type:

cdh

Then press: Esc  Ctrl-Xe

and readline updates the command-line to:

cd /home/user_name 

MacOS 13.2.1
iterm2 3.4.15
bash 5.1.8(1)-release (x86_64-apple-darwin21.2.0)

Ubuntu 20.04.5 LTS
5.0.17(1)-release (x86_64-pc-linux-gnu)

This is a duplicate of:

how to expand aliases inline in bash?

and

Expand subshell before executing it?

Turns out, BASH uses readline to handle this. Readline has the command shell-expand-line, which is by default assigned the keyboard shortcut EscCtrl-X (see man readline)

To test, I have the following alias defined in my .bash_profile:

alias cdh='cd ${HOME}'

Starting a new shell/terminal allows me to type:

cdh

Then press: EscCtrl-X

and readline updates the command-line to:

cd /home/user_name 

MacOS 13.2.1
iterm2 3.4.15
bash 5.1.8(1)-release (x86_64-apple-darwin21.2.0)

Ubuntu 20.04.5 LTS
5.0.17(1)-release (x86_64-pc-linux-gnu)

This is a duplicate of:

how to expand aliases inline in bash?

and

Expand subshell before executing it?

Turns out, BASH uses readline to handle this. Just press Esc followed by Ctrl-e

To test, I have the following alias defined in my .bash_profile:

alias cdh='cd ${HOME}'

Starting a new shell/terminal allows me to type:

cdh

Then press: Esc  Ctrl-e

and readline updates the command-line to:

cd /home/user_name 

MacOS 13.2.1
iterm2 3.4.15
bash 5.1.8(1)-release (x86_64-apple-darwin21.2.0)

Ubuntu 20.04.5 LTS
5.0.17(1)-release (x86_64-pc-linux-gnu)

Removed editing of ~/.inputrc, which turns out to be unnecessary and distracting
Source Link
JS.
  • 111
  • 4

Turns out thisThis is a duplicate of:

how to expand aliases inline in bash?

and

Expand subshell before executing it?

The answer that worked for me was to create/edit theTurns out, BASH uses readline config file `~/to handle this.inputrc following Brad Park's suggestion Readline has the command here

In summaryshell-expand-line, create/editwhich is by default assigned the ~/.inputrc file to contain:keyboard shortcut EscCtrl-X (see man readline)

Control-x:shell-expand-line

To test, I have the following alias defined in my .bash_profile:

alias cdh='cd ${HOME}'

Starting a new shell/terminal allows me to type:

cdh

Then press: CtlEscCtrl-xX

and readline updates the command-line to:`

cd /home/user_name 

MacOS 13.2.1
iterm2 3.4.15
bash 5.1.8(1)-release (x86_64-apple-darwin21.2.0)

Ubuntu 20.04.5 LTS
5.0.17(1)-release (x86_64-pc-linux-gnu)

Turns out this is a duplicate of:

how to expand aliases inline in bash?

and

Expand subshell before executing it?

The answer that worked for me was to create/edit the readline config file `~/.inputrc following Brad Park's suggestion here

In summary, create/edit the ~/.inputrc file to contain:

Control-x:shell-expand-line

I have the following alias defined in my .bash_profile:

alias cdh='cd ${HOME}'

Starting a new shell/terminal allows me to type:

cdh

Then press: Ctl-x

and readline updates the command-line to:`

cd /home/user_name 

MacOS 13.2.1
iterm2 3.4.15
bash 5.1.8(1)-release (x86_64-apple-darwin21.2.0)

Ubuntu 20.04.5 LTS
5.0.17(1)-release (x86_64-pc-linux-gnu)

This is a duplicate of:

how to expand aliases inline in bash?

and

Expand subshell before executing it?

Turns out, BASH uses readline to handle this. Readline has the command shell-expand-line, which is by default assigned the keyboard shortcut EscCtrl-X (see man readline)

To test, I have the following alias defined in my .bash_profile:

alias cdh='cd ${HOME}'

Starting a new shell/terminal allows me to type:

cdh

Then press: EscCtrl-X

and readline updates the command-line to:

cd /home/user_name 

MacOS 13.2.1
iterm2 3.4.15
bash 5.1.8(1)-release (x86_64-apple-darwin21.2.0)

Ubuntu 20.04.5 LTS
5.0.17(1)-release (x86_64-pc-linux-gnu)

added 186 characters in body
Source Link
JS.
  • 111
  • 4

Turns out this is a duplicate of:

how to expand aliases inline in bash?

and

Expand subshell before executing it?

The answer that worked for me was to create/edit the readline config file `~/.inputrc following Brad Park's suggestion here

In summary, create/edit the ~/.inputrc file to contain:

Control-x:shell-expand-line

I have the following alias defined in my .bash_profile:

alias cdh='cd ${HOME}'

Starting a new shell/terminal allows me to type:

cdh

Then press: Ctl-x

and readline updates the command-line to:`

cd /home/user_name 

MacOS 13.2.1
iterm2 3.4.15
bash 5.1.8(1)-release (x86_64-apple-darwin21.2.0)

Ubuntu 20.04.5 LTS
5.0.17(1)-release (x86_64-pc-linux-gnu)

Turns out this is a duplicate of:

how to expand aliases inline in bash?

and

Expand subshell before executing it?

The answer that worked for me was to create/edit the readline config file `~/.inputrc following Brad Park's suggestion here

In summary, create/edit the ~/.inputrc file to contain:

Control-x:shell-expand-line

I have the following alias defined in my .bash_profile:

alias cdh='cd ${HOME}'

Starting a new shell/terminal allows me to type:

cdh

Then press: Ctl-x

and readline updates the command-line to:`

cd /home/user_name 

Turns out this is a duplicate of:

how to expand aliases inline in bash?

and

Expand subshell before executing it?

The answer that worked for me was to create/edit the readline config file `~/.inputrc following Brad Park's suggestion here

In summary, create/edit the ~/.inputrc file to contain:

Control-x:shell-expand-line

I have the following alias defined in my .bash_profile:

alias cdh='cd ${HOME}'

Starting a new shell/terminal allows me to type:

cdh

Then press: Ctl-x

and readline updates the command-line to:`

cd /home/user_name 

MacOS 13.2.1
iterm2 3.4.15
bash 5.1.8(1)-release (x86_64-apple-darwin21.2.0)

Ubuntu 20.04.5 LTS
5.0.17(1)-release (x86_64-pc-linux-gnu)

Source Link
JS.
  • 111
  • 4
Loading