recentpopularlog in

kme : tabcompletion   24

macos - How to add bash command completion for Docker on Mac OS X? - Stack Overflow
Reference: https://docs.docker.com/docker-for-mac/#bash
<code class="language-bash">
sudo -s
port install bash-completion
cd /opt/local/etc/bash_completion.d
ln -s /Applications/Docker.app/Contents/Resources/etc/docker.bash-completion
ln -s /Applications/Docker.app/Contents/Resources/etc/docker-machine.bash-completion
ln -s /Applications/Docker.app/Contents/Resources/etc/docker-compose.bash-completion
</code>
docker  cli  commandline  tabcompletion  bash-completion  solution 
november 2019 by kme
linux - Bash completion for path in argument (with equals sign present) - Stack Overflow
Check out the definition of COMP_WORDBREAKS in your environment to see why '--arg=<TAB>' (maybe) isn't working.
bash  programmablecompletion  tabcompletion  completion  maybesolution  workaround 
august 2019 by kme
Programmable Completion (Bash Reference Manual)
Finally, any prefix and suffix specified with the -P and -S options are added to each member of the completion list, and the result is returned to the Readline completion code as the list of possible completions.


See
bash  completion  tabcompletion  programmablecompletion  shellscripting  solution 
august 2019 by kme
An introduction to bash completion: part 2
I created a script and I use bash_completion, but I cannot figure out how to allow the completion of "--name=value1 --name=value2" (the "=" sign in the middle stop any other completion, and I tried to play with suffixes/prefixes without any success :s


This works:

<code class="language-bash">case "$cur" in
-t*)
cur=${cur/-t}
COMPREPLY=( $(compgen -W "${_tables[*]}" -P "-t" \
-- "$cur" ) )
return 0
;;
--table=*)
cur=${cur/--table=}
COMPREPLY=( $(compgen -W "${_tables[*]}" -P "--table=" \
-- "$cur" ) )
return
;;
*)
COMPREPLY=( $(compgen -W "${_opts[*]}" -- "$cur") )
return
;;
esac</code>
bash  programmablecompletion  tabcompletion  shellscripting  fuckina  solution 
august 2019 by kme
compgen: An Awesome Command To List All Linux Commands - nixCraft
<code class="language-bash">########################################
# Task: show all the bash built-ins
########################################
compgen -b
########################################
# Task: show all the bash keywords
########################################
compgen -k
########################################
# Task: show all the bash functions
########################################
compgen -A function</code>
bash  programmablecompletion  completion  tabcompletion  compgen  reference  newbie 
august 2019 by kme
readline - python tab completion Mac OSX 10.7 (Lion) - Stack Overflow | https://stackoverflow.com/
Putting this in a ~/.pythonrc works for Python >= 3. Python 2.7.x seems to require that you set PYTHONSTARTUP=~/.pythonrc in your login scripts.

<code class="language-python">import readline
import rlcompleter
if 'libedit' in readline.__doc__:
readline.parse_and_bind("bind ^I rl_complete")
else:
readline.parse_and_bind("tab: complete")</code>
python  macos  osx  repl  tabcompletion  autocompletion  annoyance  configfile  essential  movein 
march 2019 by kme
Autocompletion for your python shell|console|interpreter | http://blog.e-shell.org/
You really do need to set PYTHONSTARTUP in your login scripts.
So, all you have to do is, first, add this two lines to a file, for example, called .pythonrc in your home:
<code class="language-bash">cat ~/.pythonrc
# import rlcompleter, readline
# readline.parse_and_bind('tab:complete')
</code>

Second, add the PYTHONSTARTUP variable to your shell profile file. If you are using csh, tcsh or similar shells, this will do it:
<code class="language-bash">echo "setenv PYTHONSTARTUP ~/.pythonrc" >> ~/.cshrc</code>

If your shell is sh, bash, ksh or similars, this will do it:
<code class="language-bash">echo "export PYTHONSTARTUP=~/.pythonrc" >> ~/.profile</code>


On macOS, where the system Python is probably compiled against libedit instead of readline, you need to do this instead:

<code class="language-python">import readline
import rlcompleter
if 'libedit' in readline.__doc__:
readline.parse_and_bind("bind ^I rl_complete")
else:
readline.parse_and_bind("tab: complete")</code>
python  repl  autocompletion  tabcompletion  configfile  dotfile  solution 
march 2019 by kme
bash - How can I prevent unsupported 'shopt' options from causing errors in my .bashrc? - Unix & Linux Stack Exchange | https://unix.stackexchange.com/
But if you really dislike redirecting the error away, you can use the completion mechanism to perform introspection. This assumes that you don't have antiquated machines with bash ≤ 2.03 that didn't have programmable completion.
<code class="language-bash">
shopt_exists () {
compgen -A shopt -X \!"$1" "$1" >/dev/null
}
if shopt_exists direxpand; then
shopt -s direxpand
fi
</code>

This method avoids forking, which is slow on some environments such as Cygwin. So does the straightforward 2>/dev/null, I don't think you can beat that on performance.
bash  configfile  shellscripting  shopt  programmablecompletion  tabcompletion  schooling  solution 
february 2019 by kme
bash - How to expand filenames with Tab, even when a shell variable is used in the path? - Unix & Linux Stack Exchange | https://unix.stackexchange.com/
The solution is 'shopt -s direxpand' in Bash 4.2 or later. This is (supposedly) the default on 4.1 and earlier. I learned that "Ctrl+Alt+E" does something cool when you 'set -o emacs', though:
For example, typing less $lh/acc then hitting Tab will expand to: less \$lh/access_log.

Of course, what I would like instead is less $lh/access_log or even less /var/log/httpd/access_log. (weirdly, with the cd command the autocomplete doesn't work at all in that case, this question already talks about it)

I know that there is an alternative by using shell-expand-line (default key: Ctrl+Alt+E), but it's far from perfect because it expands aliases as well, and it doesn't quote paths with special chars (spaces, ...).
bash  tabcompletion  movein  configfile  interesting 
february 2019 by kme
linux - bash: variable name not being expanded with Tab completion - Super User | https://superuser.com/
shopt -s direxpand will make echo $HOME/<tab> expand to echo /home/matt/ in bash 4.2. In bash 4.1 it should be the default.
bash  tabcompletion  bashcompletion  commandline  shell  configfile  essential  movein  annoyance  solution  fuckina 
february 2019 by kme
autocomplete - Disable bash tab completion - Unix & Linux Stack Exchange | https://unix.stackexchange.com/
Dennis' solution
<code class="language-bash">
bind 'set disable-completion on'
</code>

can be done on the fly in Bash as well. You do not need to put it in .bashrc.

Musta's solution (bash --noediting) works but also disables command line editing.

Another way is
<code class="language-bash">
bind -u complete
</code>

(unset key binding associated with 'complete')

http://www.gnu.org/software/bash/manual/bashref.html, 4.2 Bash Builtin Commands.
bash  configsetting  configfile  completion  tabcompletion  itsslow  fuckina  solution 
november 2018 by kme
Enable Tab Completion for SSH Aliases
Blog formatting gremlins ate a bunch of extra backlashes, so you can't just copy-and-paste. The correct version with the missing backslashes is:

<code class="language-bash">
complete -o default -o nospace -W \
"$(/usr/bin/env ruby -ne 'puts $_.split(/[,\s]+/)[1..-1].reject{|host| host.match(/\*|\?/)} if $_.match(/^\s*Host\s+/);' < $HOME/.ssh/config)" \
scp sftp ssh
</code>
bash  essential  movein  ssh  configfile  tabcompletion  bashcompletion  solution 
december 2017 by kme

Copy this bookmark:





to read