Code Monkey home page Code Monkey logo

Comments (2)

aryarm avatar aryarm commented on September 26, 2024

An understanding of bash tab completions continues to elude me. There are three different systems I've encountered that all seem to do things differently: knuth, my phone, and my laptop.
A little bit of a breakthrough came when I played around with cds tab completion a while back. I'll document a few things I learned for posterity. Hopefully they can shed some light on how normal alias gets its completions too.

  • Bash completions are not an inherent feature of bash necessarily. I think they need to get enabled by an external script.
  • Bash completions get enabled every time the terminal is started. The following code needs to appear in your .bashrc in order for this to happen. In order for tab completions from our repo to work appropriately, our code needs to be sourced after this code is run.
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
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
  • knuth does not have the above code. Neither does it have a bash_completion enabler script. Yet it seems to have some form of tab completion, albeit a really bad one. You can enable better bash completions on knuth by copying the script and adapting the code above to the appropriate places.
  • Most computers also have a folder /etc/bash_completion.d/ where it seems like bash completion scripts for some individual commands (like git, for example) are stored. I have yet to understand what this does and why it exists.
  • I still don't know where tab completions for normal cd are defined. @GiselleSerate, you might run into the same problem with normal alias since they are both bash built-in commands (I think?)

from myaliases.

GiselleSerate avatar GiselleSerate commented on September 26, 2024

Okay, tab completion was a little enthusiastic. Alias doesn't do any tab completing. (I don't know where it would . . .) So we're going to call this a case of Tab Completion Isn't Duct Tape and close this issue.

from myaliases.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.