dvm
dvm copied to clipboard
Added bash completion and fzf support
This adds:
- Bash completion
- Renames internal functions to be prefixed
_so they don't show up indv<tab><tab> dvm use <tab><tab>will show list of installed versions and--defaultdvm use --default <tab><tab>will show list of installed versionsdvm install <tab><tab>will show list of stable versions (this seems like the thing most used will need).
- Renames internal functions to be prefixed
- Fuzzy matching with
fzfdvm installwill openfzfwith stable versionsdvm usewill optionfzfwith installed versionsdvm use --defaultwill optionfzfwith installed versions
To make bash completion and fuzzy matching fast, the list of versions for stable, beta and dev will be saved to:
$DVM_ROOT/cache/versions-stable$DVM_ROOT/cache/versions-beta$DVM_ROOT/cache/versions-dev
If older than 5 minutes the list of versions will be refreshed. According to man date this should work on Mac OS too, but I only tested it on Linux.
warning: it's entirely possible that I made a typo in some of this code, I renamed quite a few things -- and I have yet to figure out what dvm alias is good for :see_no_evil:
I think we should consider a dvm default command for setting the default version... possibly even a dvm install [--use] [--default] command, so that updating to the latest version is easy. But that's something we can do later.
For now bash completion and fzf will make most interactions with dvm much smoother.
I think we should consider a dvm default command for setting the default version.
Something like this? :wink:
$ dvm --help |grep use
use Select a Dart version to use (--default to set as default)
I'd actually forgotten this feature existed until a couple weeks ago. https://github.com/cbracken/dvm/issues/12. Perhaps the bug was to actually create an alias symlink, rather than writing the file to be sourced which IIRC is what it does now. That's probably actually still a good idea.
Oh I see, I misread what you'd written; you actually included the above in your completions list. Sounds like you're saying we should add a dvm default command that would allow the user to swing the default version, rather than dvm use --default VERSION?
Sounds like you're saying we should add a
dvm defaultcommand that would allow the user to swing the default version, rather thandvm use --default VERSION?
Yeah, or something like that.. I frequently find that what I want to do is:
- Install a Dart SDK version, and,
- Set it to be used by default.
There is many ways we could do this. Maybe dvm without any arguments should do:
V=$(dvm listall | fzf); dvm install $V; dvm use $V --default;
Just because, listall + install + use + --default is the most common thing to do. But we can consider that later.
@cbracken I assume we both forgot all about this :rofl:
Should we merge... all the stuff about adding additional commands and shortcuts seems like follow up PRs, if we want to do it. With fzf and bash completion using dvm is already a lot easier :D
Just adding a note to apologise for the delay! I haven't forgotten about this, but was out for three weeks starting almost exactly when you last replied and finally got caught up on all the other stuff! Will take a look!
@cbracken friendly ping :D