niivue / niivue-vscode

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

call from command line #65

Open korbinian90 opened 4 months ago

korbinian90 commented 4 months 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 3 months ago

This currently only works with absolute paths

korbinian90 commented 3 months ago

!/bin/bash

filePath=$(realpath "$1")

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

korbinian90 commented 3 months 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