Commands tagged completion (11)

  • Pressing ESC then * will insert in the command line the results of the autocompletion. It's hard to explain but if you look the sample output or do echo ESC * you will understand quickly. By the way, few reminders about ESC : - Hold ESC does the same thing as tab tab - 'ESC .' inserts the last argument of last command (can be done many times in order to get the last argument of all previous commands) Show Sample Output

    ESC *
    Josay · 2009-06-14 21:17:40 18
  • When browsing java source code (for example) it's really annoying having to type the first letter of the package when there is only one package in the subdir. man bash for more info about FIGNORE

    export FIGNORE=.svn
    peter0081 · 2010-04-09 15:26:00 0
  • In Bash, when defining an alias, one usually loses the completion related to the function used in that alias (that completion is usually defined in /etc/bash_completion using the complete builtin). It's easy to reuse the work done for that completion in order to have smart completion for our alias. That's what is done by this command line (that's only an example but it may be very easy to reuse). Note 1 : You can use given command line in a loop "for old in apt-get apt-cache" if you want to define aliases like that for many commands. Note 2 : You can put the output of the command directly in your .bashrc file (after the ". /etc/bash_completion") to always have the alias and its completion Show Sample Output

    old='apt-get'; new="su-${old}"; command="sudo ${old}"; alias "${new}=${command}"; $( complete | sed -n "s/${old}$/${new}/p" ); alias ${new}; complete -p ${new}
    Josay · 2009-08-10 00:15:05 0
  • enable each bash completion that you have installed at your system, that's very nice ;)

    for x in $(eselect bashcomp list | sed -e 's/ //g' | cut -d']' -f2 | sed -e 's/\*//');do eselect bashcomp enable $x --global;sleep 0.5s;done
    chronos · 2010-09-21 00:17:26 0

  • 1
    for i in `eselect bashcomp list | awk '{print $2}'`; do eselect bashcomp enable $i; done
    jsvk · 2012-12-10 06:07:54 0
  • Tested with bash v4.1.5 on ubuntu 10.10 Limitations: as written above, only works for programs with no file extention (i.e 'proggy', but not '') because \eb maps to readine function backward-word rather then shell-backward-word (which is unbinded by default on ubuntu), and correspondingly for \ef. if you're willing to have Ctrl-f and Ctrl-g taken up too , you can insert the following lines into ~/.inputrc, in which case invoking Ctrl-e will do the right thing both for "proggy" and "". -- cut here -- \C-f:shell-backward-word \C-g:shell-forward-word "\C-e":"\C-f`which \C-g`\e\C-e" -- cut here -- Show Sample Output

    bind '"\C-e":"\eb `which \ef`\e\C-e"'
    jennings6k · 2011-01-26 16:11:52 0
  • It gives a 'xcd' command for changing directory to one of CWDs of other ZSH processes (typically running in a terminal emulator). Useful for single-windowed terminal emulators like XTerm or Rxvt which don't have ability to pass CWD of one shell to another. Show Sample Output

    function _xterm_cwds() { for pid in $(pidof -- -zsh) $(pidof zsh); do reply+=$(readlink /proc/$pid/cwd) done }; function xcd() { cd $1 }; compctl -K _xterm_cwds xcd
    aartur · 2012-07-12 19:59:46 1

  • 0
    eselect bashcomp enable --global $(eselect bashcomp list | sed -e 's/ //g'| cut -d']' -f2 | sed -e 's/\*//'| xargs)
    proteusx · 2012-07-20 22:01:08 1
  • Pros: * it's much faster then for loop * removes first line of 'eselect bashcomp list' - which contains text "Available completions:"

    eselect bashcomp enable --global $(eselect bashcomp list | tail -n +2 | awk '{print $2}' |xargs)
    eNcacz · 2016-02-12 16:53:22 0
  • MacOS Solution due to lack of pidof command and procfs on MacOS Kernel. Show Sample Output

    function _xterm_cwds() { for pid in $(pgrep -x zsh); do reply+=$(lsof -p $pid | grep cwd | awk '{print $9}') done }; function xcd() { cd $1 }; compctl -K _xterm_cwds xcd
    cdiehl · 2019-06-15 02:26:11 0
  • When you have to manage lot of servers, it's boring to type ssh root@myhost for each connection. Now you can type juste "s someting" and you are connected. You can too add bash_completion script to complet with tab the name of your servers. This will be the next tips from me ;) Show Sample Output

    alias s='ssh -l root'
    GouNiNi · 2009-05-07 15:57:12 6

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Check These Out

Grep by paragraph instead of by line.
This is a command that I find myself using all the time. It works like regular grep, but returns the paragraph containing the search pattern instead of just the line. It operates on files or standard input. $ grepp or $ | grepp

search user defined function in c language

A video capture command which can be assigned to a keyboard shortcut.
A video capture command which can be assigned to a keyboard shortcut.

Find and list users who talk like "lolcats"
Greps IRC logs for phrases and lists users who said them.

List all users and groups

Create a tar file with the current date in the name.

Network Folder Copy with Monitoring ( tar + nc + pv )
Transfer tar stream thru nc with pv montoiring taken from:

Format date/time string for a different day
The "date' command has options to easily format the date, day, month, time, etc. But what if you want a relative date or time. Like, I wanted yesterday's date in a particular format. You may want the exact date of "2 months ago" or "-3 days" nicely formatted. For that, you can use this command. The --date option takes fuzzy parameters like the ones mentioned in the previous sentence.

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Show interface/ip using awk
Interfaces like lo can be omitted from the beginning, there are probably better ways of doing this, i'm a noob at awk.

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: