Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: command line completion with environment variables.

  1. #1
    Join Date
    May 2013
    Beans
    4

    command line completion with environment variables.

    Command line completion did not work when opening a terminal so I googled and figured that out (uncommenting lines in /etc/bash.bashrc.

    it works when I start with a full path like / or relative path,

    but when I type something like:

    $cd $HOME/D<tab>

    I do not get command line completion when using environment variables. How to fix this?

  2. #2
    Join Date
    Feb 2009
    Location
    Dallas, TX
    Beans
    7,790
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: command line completion with environment variables.

    Hi jvsrvcs.

    Unfortunately, bash completion does not work that way. Bash would have to evaluate variables as you type them instead of waiting for an enter.

    If you are trying to get something else to work (writing an script for example), may be there's another way to accomplish what you want.

    Let us know how it goes.
    Regards.

  3. #3
    Join Date
    Jul 2007
    Location
    Mississauga, ON
    Beans
    123
    Distro
    Lubuntu 12.10 Quantal Quetzal

    Re: command line completion with environment variables.

    Quote Originally Posted by jvsrvcs View Post
    but when I type something like:

    $cd $HOME/D<tab>

    I do not get command line completion when using environment variables. How to fix this?
    For this particular scenario try:
    Code:
    $ cd ~/D<tab>
    Windows by necessity, Linux by choice
    Lubuntu and loving it!

  4. #4
    Join Date
    May 2013
    Beans
    4

    command line completion

    I am at a Terminal command prompt. I type: $cd $HOME/

    and then hit the tab key and instead of the directory contents being displayed, I get:
    $cd \$HOME/ <= it just inserted a \ in front of the $

    now I have to backspace and erase that \ in front of the $, my command line completion is broken. I have worked with Unix/Linux since the early 1920's and I have never seen this happen in all my years. Who programmed that into the command line completion? How do I find the person responsible? How do I fix this?
    Last edited by Elfy; July 9th, 2013 at 08:07 PM.

  5. #5
    Join Date
    May 2006
    Location
    Milwaukee,WI
    Beans
    6,280
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: command line completion

    why do you have the dollar signs? auto-completion works for names close to what you typed, so if you want to change directory to your /home/ folder you would type in
    Code:
    cd /home/
    and then you would hit tab and it would show you all the contents of whats in your home.

  6. #6
    Join Date
    Jul 2005
    Location
    I think I'm here! Maybe?
    Beans
    Hidden!
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: command line completion

    In fact just cd will take you back to your home folder from anywhere in the filesystem, unless you have run sudo -i or sudo su to get to a root prompt, when it will just take you back to root@hostname instead of user@hostname.

  7. #7
    Join Date
    Feb 2008
    Location
    Land of fire and drought
    Beans
    Hidden!
    Distro
    Xubuntu

    Re: command line completion

    Quote Originally Posted by ajgreeny View Post
    ... unless you have run sudo -i or sudo su to get to a root prompt, when it will just take you back to root@hostname instead of user@hostname.
    ... in which case you will need to type 'exit' to become a normal user again.

    Code:
    cd /home
    Will put you to the /home directory, if you aren't already in it.

    Code:
    dir /home
    Will show its contents (or the tab, apparently, although that's a newie on me, thanks). I'm presuming you are following a guide to do something in a terminal, possibly to learn more?

  8. #8
    Join Date
    May 2006
    Location
    Milwaukee,WI
    Beans
    6,280
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: command line completion

    oh, and it's impossible you were working on Unix or Linux in the 1920's since Unix wasn't around till 1969 and Linux in 1983 but anyway, hope we all answered your question

  9. #9
    Join Date
    Nov 2005
    Location
    Lincolnshire, UK
    Beans
    1,461
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: command line completion

    Quote Originally Posted by jvsrvcs View Post
    ...I have worked with Unix/Linux since the early 1920's and I have never seen this happen in all my years...

  10. #10
    Join Date
    Feb 2008
    Location
    Land of fire and drought
    Beans
    Hidden!
    Distro
    Xubuntu

    Re: command line completion

    Quote Originally Posted by jvsrvcs View Post
    I have worked with Unix/Linux since the early 1920's ...
    Time traveller?

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •