basher icon indicating copy to clipboard operation
basher copied to clipboard

Allows custom folder name

Open soraxas opened this issue 5 years ago • 6 comments

This PR adds the ability to clone into a named folder (same as the normal git clone command where you can clone to any folder), with the exception that it's to rename the result folder.

Use case: I uses lots of gist to host the script that I used (and easy to share). My basher list looks something like:

dylanaraps/neofetch
pepa65/tldr-bash-client
simonthum/git-sync
so-fancy/diff-so-fancy
soraxas/0ef22338ad01e470cd62595d2e5623dd
soraxas/4c54c944714412baeb1b773ff10d7261
soraxas/507cbff5fab0a10f71cdc4b9179e3e36
soraxas/711591894b79be8916ef85307f1a3552
soraxas/72ed82761fc7435e8d2bf4d2043d641f
soraxas/735c512a785b8278b9faffdbb303b37b
soraxas/ab594b0cf5c49b4e36c04249f0b7c2f7
soraxas/dot-reminder
soraxas/works

which is impossible to know what those packages are for (because github gist cannot be renamed).

With this PR, I can install package with

basher install gist.github.com/soraxas/735c512a785b8278b9faffdbb303b37b git-utils

i.e.

Usage: basher install [--ssh] [site]/<package>[@ref] [folder]

and it will clone into cellar/soraxas/git-utils. The result is:

dylanaraps/neofetch
pepa65/tldr-bash-client
simonthum/git-sync
so-fancy/diff-so-fancy
soraxas/close-gnome-terminal
soraxas/dot-reminder
soraxas/easy-extraction
soraxas/gist-add-x-bit
soraxas/git-utils
soraxas/open-rev-ports
soraxas/parse-assh
soraxas/pdfcrop
soraxas/works

In addition, to enhance the basher list functinoality, it now has a verbose flag -v where if you run

basher list -v

it will displays the upstream URL (also useful to shows hostname other than github.com), like so:

dylanaraps/neofetch            (https://github.com/dylanaraps/neofetch.git)
pepa65/tldr-bash-client        (https://github.com/pepa65/tldr-bash-client.git)
simonthum/git-sync             (https://github.com/simonthum/git-sync.git)
so-fancy/diff-so-fancy         (https://github.com/so-fancy/diff-so-fancy.git)
soraxas/close-gnome-terminal   (https://gist.github.com/soraxas/711591894b79be8916ef85307f1a3552.git)
soraxas/dot-reminder           (https://github.com/soraxas/dot-reminder.git)
soraxas/easy-extraction        (https://gist.github.com/soraxas/ab594b0cf5c49b4e36c04249f0b7c2f7.git)
soraxas/gist-add-x-bit         (https://gist.github.com/soraxas/507cbff5fab0a10f71cdc4b9179e3e36.git)
soraxas/git-utils              (https://gist.github.com/soraxas/735c512a785b8278b9faffdbb303b37b.git)
soraxas/open-rev-ports         (https://gist.github.com/soraxas/0ef22338ad01e470cd62595d2e5623dd.git)
soraxas/parse-assh             (https://gist.github.com/soraxas/72ed82761fc7435e8d2bf4d2043d641f.git)
soraxas/pdfcrop                (https://gist.github.com/soraxas/4c54c944714412baeb1b773ff10d7261.git)
soraxas/works                  (https://gist.github.com/soraxas/4c54c944714412baeb1b773ff10d7261.git)

soraxas avatar May 29 '20 08:05 soraxas

Nice! I'd love to be able to specify both the namespace and package name though, something like basher install gh:shellm-org/loop shellm/loop. It would effectively allow to install from any mirror with different namespaces.

pawamoy avatar May 30 '20 15:05 pawamoy

@pawamoy see #70 for that

soraxas avatar May 31 '20 03:05 soraxas

Sorry, I used the cookiecutter syntax for the URL :sweat_smile:

What I really meant was basher install github.com/shellm-org/loop shellm/loop. This way users could install my packages from my GitHub org shellm-org or the GitLab one shellm under the same namespace: shellm.

pawamoy avatar Jun 01 '20 08:06 pawamoy

True, I would agree that it would be a more flexible approach.

With the updated PR, one must specify the optional folder in the <...>/<...> format, i.e.

basher install gist.github.com/me/89271498214 foo/bar

Though that begs the question of whether a package must be in the format of <username>/<repo>. But until we want to relax that constrain (and closes #67), this is at least consistent to the current behaviour.

soraxas avatar Jun 01 '20 08:06 soraxas

Great, thanks for the update :slightly_smiling_face:

pawamoy avatar Jun 01 '20 08:06 pawamoy

This is great, thanks for the contributions. It's missing tests though, if you're still interested.

juanibiapina avatar Jan 04 '21 09:01 juanibiapina