niivue / niivue-vscode

NiiVue extension for vscode + standalone web app
https://niivue.github.io/niivue-vscode/
MIT License
21 stars 7 forks source link

call from command line #65

Open korbinian90 opened 1 month ago

korbinian90 commented 1 month ago

When the pwa is installed via chrome as local app, the following alias makes it work via command line: alias niivue='/usr/bin/google-chrome --app-id=pgienjkbgeffjnbagkbcacejihclfdeg' Opening images via niivue test.nii or niivue test1.nii test2.nii

TODO: create explanation somewhere useful

korbinian90 commented 1 month ago

This currently only works with absolute paths

korbinian90 commented 1 month ago

!/bin/bash

filePath=$(realpath "$1")

niivue='/usr/bin/google-chrome --app-id=pgienjkbgeffjnbagkbcacejihclfdeg' "$filePath"

korbinian90 commented 1 month ago

New version for multiple input images:

Store this file as niivue under /usr/bin (requires sudo) and run sudo chmod +x+r /usr/bin/niivue to make it executable. Afterwards, the command niivue Image1.nii Image2.nii should work

#!/bin/bash

filePaths=""

for filePath in "$@"; do
  absolutePath=$(realpath "$filePath")
  filePaths="$filePaths \"$absolutePath\""
done

eval /usr/bin/google-chrome --app-id=pgienjkbgeffjnbagkbcacejihclfdeg $filePaths