Monday, 11 June 2018

bash - Command-T for shell


I'm looking for a shell extension that allows me to do filename completion similarly to Command-T.


Command-T a feature in TextMate and a plugin for Vim that allows you to select filenames by typing portions of them which need not be contiguous. It uses a ranking system to decide which filename to use, and provides a menu of available options. If you're not familiar with this feature the best way to understand it is to watch the first video from the Command-T github page.


What tool can I use so that I can have Command-T-style completion for filenames in my shell? (Bash currently, open to alternatives.)



Answer



Zsh to the rescue!


Toss the following into your ~/.zshrc file and enjoy!


Please note, it may not be nearly as good as TM's ability to find file names but it's leaps and bounds better than the default autocomplete found in bash.


##############################################################
# Stuff from http://zshwiki.org/home/examples/compquickstart #
##############################################################
zmodload zsh/complist
autoload -U compinit && compinit
zstyle ':completion:::::' completer _complete _approximate
zstyle -e ':completion:*:approximate:*' max-errors 'reply=( $(( ($#PREFIX + $#SUFFIX) / 3 )) )'
zstyle ':completion:*:descriptions' format "- %d -"
zstyle ':completion:*:corrections' format "- %d - (errors %e})"
zstyle ':completion:*:default' list-prompt '%S%M matches%s'
zstyle ':completion:*' group-name ''
zstyle ':completion:*:manuals' separate-sections true
zstyle ':completion:*' menu select
zstyle ':completion:*' verbose yes
## case-insensitive (uppercase from lowercase) completion
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
#zstyle ':completion:*' special-dirs ..

No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...