Slackware This Forum is for the discussion of Slackware Linux.
|
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
08-22-2006, 02:51 PM
|
#1
|
Member
Registered: Feb 2004
Location: Northamptonshire, UK
Distribution: Windows XP, Arch Linux
Posts: 131
Rep:
|
Tab completion with sudo
How do I enable tab completion when using sudo like on Ubuntu? I have no .bashrc file or /etc/bash.bashrc
Cheers.
|
|
|
08-22-2006, 02:57 PM
|
#2
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
can you explain more clearly what you mean? tab completion is a standard default bash faeture so if that's your shell, you will have it enabled.
|
|
|
08-22-2006, 03:16 PM
|
#3
|
Member
Registered: Feb 2004
Location: Northamptonshire, UK
Distribution: Windows XP, Arch Linux
Posts: 131
Original Poster
Rep:
|
Sorry I meant for commands and applications. If I use sudo I have to type the full command and cannot use tab completion.
|
|
|
08-22-2006, 03:26 PM
|
#4
|
Member
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 377
Rep:
|
When you hit tab in your shell, you get command completion and filename completion. For a contrived example, typing "lso<TAB>" at the beginning of the line will complete the command to "lsof", but "sudo lso<TAB>" tries to complete this argument as a file name, and often there is none starting with "lso".
My workaround is to complete first, then jump to the beginning (C-A) and add "sudo ". It helps to have the 3 directories {,/usr{,/local}}/sbin in your path as a normal user.
I know tcsh can be configured to very sophisticated context-sensitive completions; not sure about bash. That would be the fancy approach.
|
|
|
08-22-2006, 03:28 PM
|
#5
|
Member
Registered: Sep 2004
Location: Ontario, Canada
Distribution: Slackware 14.2, current
Posts: 416
Rep:
|
Do you mean that for example instead of typing
sudo /sbin/ifconfig
you would like to be able to type
sudo ifc[tab]
and have it expand to ifconfig?
I don't know the answer, just trying to help clarify the question.
|
|
|
08-22-2006, 03:37 PM
|
#6
|
Slackware Contributor
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559
|
You need to install the bash-completion package which is not part of stock Slackware but it is available in the /extra directory. A link to the package for Slackware 10.2 is here: http://slackware.osuosl.org/slackwar...sh-completion/
Eric
|
|
|
08-22-2006, 03:44 PM
|
#7
|
HCL Maintainer
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450
Rep:
|
For so-called "smart" tab-completion, most distros already supply some good rules (usually something like /etc/bash_completion). To put the rules in your startup, you generally source the file in ~/.bashrc or ~/.bash_profile or ~/.profile.
If you don't have a file /etc/bash_completion, you can create your own rules with the compgen and complete commands.
For example, for sudo to complete with executables, you could do:
Or you could think of more elaborate methods.
|
|
|
08-22-2006, 03:46 PM
|
#8
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
Quote:
Originally Posted by osor
For so-called "smart" tab-completion, most distros already supply some good rules (usually something like /etc/bash_completion). To put the rules in your startup, you generally source the file in ~/.bashrc or ~/.bash_profile or ~/.profile.
If you don't have a file /etc/bash_completion, you can create your own rules with the compgen and complete commands.
For example, for sudo to complete with executables, you could do:
Or you could think of more elaborate methods.
|
/me continues to learn new commands.....
|
|
|
08-22-2006, 03:46 PM
|
#9
|
Member
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 377
Rep:
|
I should have read "man bash" before (so should everyone).
Extrasolar:
Use complete-command (M-!), i.e.,
sudo /usr/sbin/lso[M-!]
to complete it to "/usr/sbin/lsof". (And if /usr/sbin is in your path, you don't have to type it.)
And yes, bash has Programmable Completion (see man), which sounds nifty.
|
|
|
All times are GMT -5. The time now is 02:59 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|