Monday, April 29, 2024
 Popular · Latest · Hot · Upcoming
53
rated 0 times [  53] [ 0]  / answers: 1 / hits: 54732  / 1 Year ago, sat, november 19, 2022, 4:18:57

Okay a college of mine just showed me that you could do



sudo apt-get install <type first letters of package> <TAB>


That it auto-completes the name of the package. Just for an example...



sudo apt-get install ged<TAB> results in sudo apt-get install gedit



Now I tried to do this but this does not work for me.



How can I solve this? Do I have to install a package? My college told me that he didn't install anything extra for it.


More From » bash

 Answers
3

Bash does support some more kinds of autocompletion, not only filename completion.



In the file /etc/bash.bashrc, you will find a paragraph, like this or similiar to this:




# enable bash completion in interactive shells
#if ! shopt -oq posix; then
# if [ -f /usr/share/bash-completion/bash_completion ]; then
# . /usr/share/bash-completion/bash_completion
# elif [ -f /etc/bash_completion ]; then
# . /etc/bash_completion
# fi
#fi


(this example is from debian, but is probably identical to the Ubuntu version)



By removing the # character in the beginning of each line you put a lot of additional completion rules into effect. (Don't remove the # on the first line... thats really a comment ;-)



I believe apt-get completions are among those enabled with this. If not you could think about switching to zsh. I know they support it ;-)


[#34584] Saturday, November 19, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ofunn

Total Points: 164
Total Questions: 116
Total Answers: 116

Location: Liberia
Member since Fri, Oct 22, 2021
3 Years ago
;