Skip to content

Conversation

eatkins
Copy link
Contributor

@eatkins eatkins commented Oct 25, 2020

This commit adds a wizard for installing sbtn along with tab completions
for bash, fish, powershell and zsh. It introduces the installSbtn
command which installs sbtn into ~/.sbt/1.0/bin/sbtn(.exe) depending on
the platform. It also can optionally install completions. The
completions are installed into ~/.sbt/1.0/completions. The sbtn native
executable is installed by downloading the sbt universal zip for the
version (which can be provided as an input argument with a fallback to
the running sbt version) and extracting the platform specific binary
into ~/.sbt/1.0/bin. After installing the executable, it offers to setup
the path and completions for the four shells. With the user's consent,
it adds a line to the shell config that updates the path to include
~/.sbt/1.0/bin and another line to source the appropriate completion
file for the shell from ~/.sbt/1.0/completions.

@eatkins
Copy link
Contributor Author

eatkins commented Oct 25, 2020

Here's what it looks like in action:

sbt:scala-compile> installSbtn
downloading https://github.com/sbt/sbt/releases/download/v1.4.1/sbt-1.4.1.zip to /var/folders/zv/2wskcxc14cn6kyj4yb53whc40000gn/T/sbt-1.4.19861458291520778649zip
extracting /var/folders/zv/2wskcxc14cn6kyj4yb53whc40000gn/T/sbt-1.4.19861458291520778649zip!sbt/bin/sbtn-x86_64-apple-darwin to /Users/ethanatkins/.sbt/1.0/bin/sbtn
Setup sbtn for shell:
 [1] bash
 [2] fish
 [3] powershell
 [4] zsh
 [5] none
Enter option: 4
Add /Users/ethanatkins/.sbt/1.0/bin to PATH in /Users/ethanatkins/.zshrc? y/n (y default): y
Add tab completions to /Users/ethanatkins/.zshrc? y/n (y default): y

Successfully installed sbtn for zsh. You may need to restart zsh for the changes to take effect.
[success] Total time: 15 s, completed Oct 25, 2020, 3:53:29 PM

@eatkins
Copy link
Contributor Author

eatkins commented Oct 25, 2020

I manually tested that it works on mac, linux and windows. I only tested powershell on windows and I only tested bash, zsh and fish on linux and mac.

@eatkins
Copy link
Contributor Author

eatkins commented Oct 25, 2020

With an empty .zshrc, it generates:

# The following two lines were added by the sbt installSbtn task:
fpath=($fpath /Users/ethanatkins/.sbt/1.0/completions)
autoload -Uz compinit; compinit

path=($path /Users/ethanatkins/.sbt/1.0/bin)

For bash, it's:

export PATH=$PATH:/Users/ethanatkins/.sbt/1.0/bin
source /Users/ethanatkins/.sbt/1.0/completions/sbtn.bash

For fish, it's

set PATH $PATH /Users/ethanatkins/.sbt/1.0/bin
source /Users/ethanatkins/.sbt/1.0/completions/sbtn.fish

For powershell, it's

$env:Path += ";C:\Users\ethanatkins\.sbt\1.0\bin"                                                                                                                                                                                                                                     
. "C:\Users\ethanatkins\.sbt\1.0\completions\sbtn.ps1" 

This commit adds a wizard for installing sbtn along with tab completions
for bash, fish, powershell and zsh. It introduces the `installSbtn`
command which installs sbtn into ~/.sbt/1.0/bin/sbtn(.exe) depending on
the platform. It also can optionally install completions. The
completions are installed into ~/.sbt/1.0/completions. The sbtn native
executable is installed by downloading the sbt universal zip for the
version (which can be provided as an input argument with a fallback to
the running sbt version) and extracting the platform specific binary
into ~/.sbt/1.0/bin. After installing the executable, it offers to setup
the path and completions for the four shells. With the user's consent,
it adds a line to the shell config that updates the path to include
~/.sbt/1.0/bin and another line to source the appropriate completion
file for the shell from ~/.sbt/1.0/completions.
This test works fine locally on all platforms but there are issues in
CI. I think that it might work ok with 1.4.2 without a lot of extra
effort so I'm going to disable it for now.
@eed3si9n eed3si9n merged commit 1436960 into sbt:develop Oct 26, 2020
@eatkins eatkins deleted the sbtn-wizard branch October 29, 2020 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants