coursier / coursier

Pure Scala Artifact Fetching
https://get-coursier.io
Apache License 2.0
2.04k stars 310 forks source link

support fish shell for `cs setup` #3084

Open scarf005 opened 2 months ago

scarf005 commented 2 months ago

currently cs updates ~/.bash_profile but not ~/.config/fish/config.fish:

cs setup
Checking if a JVM is installed
Found a JVM installed under /home/scarf/.cache/coursier/arc/https/github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.24%252B8/OpenJDK11U-jdk_x64_linux_hotspot_11.0.24_8.tar.gz/jdk-11.0.24+8.
  Should we update ~/.profile, ~/.bash_profile? [Y/n] y
Some shell configuration files were updated. It is recommended to close this terminal once the setup command is done, and open a new one for the changes to be taken into account.

Checking if ~/.local/share/coursier/bin is in PATH

Checking if the standard Scala applications are installed
  Installed ammonite
  Found cs
  Found coursier
  Found scala
  Found scalac
  Found scala-cli
  Found sbt
  Found sbtn
  Found scalafmt

fish shell users manually has to copy following line

# >>> coursier install directory >>>
export PATH="$PATH:/home/scarf/.local/share/coursier/bin"
# <<< coursier install directory <<<

# >>> JVM installed by coursier >>>
export JAVA_HOME="/home/scarf/.cache/coursier/arc/https/github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.24%252B8/OpenJDK11U-jdk_x64_linux_hotspot_11.0.24_8.tar.gz/jdk-11.0.24+8"
export PATH="$PATH:/home/scarf/.cache/coursier/arc/https/github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.24%252B8/OpenJDK11U-jdk_x64_linux_hotspot_11.0.24_8.tar.gz/jdk-11.0.24+8/bin"
# <<< JVM installed by coursier <<<

into

# >>> coursier install directory >>>
fish_add_path /home/scarf/.local/share/coursier/bin
# <<< coursier install directory <<<

# >>> JVM installed by coursier >>>
set -gx JAVA_HOME "/home/scarf/.cache/coursier/arc/https/github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.24%252B8/OpenJDK11U-jdk_x64_linux_hotspot_11.0.24_8.tar.gz/jdk-11.0.24+8"
fish_add_path "/home/scarf/.cache/coursier/arc/https/github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.24%252B8/OpenJDK11U-jdk_x64_linux_hotspot_11.0.24_8.tar.gz/jdk-11.0.24+8/bin"
# <<< JVM installed by coursier <<<

in order for cs setup to work properly in fish shell.

i'm interested in opening a PR, but pointers on where to look would be appreciated.

sbushmanov commented 2 weeks ago

eval "$(cs java --jvm temurin:1.17 --env)"

(if you wish to)