Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I've made several aliases for my convenience.But now I need to be helpful by sending a useful command and it is full of aliases.I've tried doing type u but all it returns is

up && ap upgrade -y --show-progress && r && ap check && ap autoclean

These are all aliases in u:

alias a='alias'
a ap='apt-get'
a r='ap autoremove -y'
a up='ap update'
share|improve this question
    
I apologize, I am having trouble understanding your question. When you say type u and "These are all aliases in u", what is u? And is up && ap upgrade -y etc...... the command you are trying to execute? If yes, then can you tell us in what way it doesn't work? –  Celada Jul 26 at 10:36
    
Take a look at help unalias. –  Cyrus Jul 26 at 10:38
    
@Celada No need to apologize, I could have explained it more.type command says something about something so type u says something about alias named u The problem is it returns what the command u does but it contains more aliases. –  user251046 Jul 26 at 10:40
    
@Cyrus is this pernament? –  user251046 Jul 26 at 10:41
    
@user251046: no. –  Cyrus Jul 26 at 11:32

1 Answer 1

up vote 5 down vote accepted

Press Ctrl-Alt-e with a command using your aliases written (ready to run) and Bash will expand it. Ctrl-Alt-e is the default binding for the shell-expand-line readline command.

Each time you push Ctrl-Alt-e Bash will expand one layer of alias, so push it repeatedly until your command is expanded as far as you need.

If your Meta key is not Alt, substitute it instead, or press Escape Ctrl-e.

There is also an alias-expand-line function which is not bound by default, which only expands aliases.

share|improve this answer
    
You'll need to keep pressing this key combination until the line is fully expanded if you have aliases within aliases as is the case with the OP. –  Joseph R. Jul 26 at 10:47
    
@JosephR. Oh thanks, I've found it out myself anyway though. –  user251046 Jul 26 at 11:25
    
@user251046 I figured you would. This is just a caveat for any future readers. –  Joseph R. Jul 26 at 11:49
1  
@JosephR. to be taken with a grain of salt for recursive aliases (like alias ls='ls --colour') –  Stéphane Chazelas Jul 26 at 11:51
1  
Ctrl-Alt-e doesn't expand only aliases. It also expands variables, arithmetic and command substitutions (and process substitutions!), though not tilde or globs, all of them on the command line, so use with care! alias-expand-line would be a better widget but is not bound by default. See also Ctrl-X a in zsh to expand the alias under the cursor. –  Stéphane Chazelas Jul 26 at 11:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.