mauro-idsia / blip

Bayesian network Learning Improved Project
GNU Lesser General Public License v3.0
30 stars 11 forks source link

Helper script to make blip use easier #6

Open fcole90 opened 6 years ago

fcole90 commented 6 years ago

An helper script to make blip use easier

Currently to run blip the path to the jar file is needed. I created a small script to have just to run blip instead of java -jar path/to/blip.jar.

The script, blip.sh, is very simple.

#!/usr/bin/env bash

# Helper script to run blip in a single command.

# Obtain the absolute path of this script.
# Solution from: https://stackoverflow.com/a/246128
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
  DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
  SOURCE="$(readlink "$SOURCE")"
  [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"

java -jar "$DIR"/blip.jar "$@"

You can right-click and save in your home from here.

How to use it

Then you just need to put it in a folder and add it to your PATH. I decided to create a bin folder in my home.

mkdir -p ~/bin/blip_dir

Then put the script into the folder, together with the jar package, and give it execution permission.

mv blip.sh ~/bin/blip_dir/
mv blip.jar ~/bin/blip_dir/
chmod +x ~/bin/blip_dir/blip.sh

Finally make a symbolic link to your ~/bin folder.

ln -s ~/bin/blip_dir/blip.sh blip

Now you just need to add the folder to your path. If you wan to do it in a single terminal session, you can just type:

export PATH=$PATH:~/bin

or if you want something which lasts in every session you can add the previous command in the end of your .profile or .bashrc and then do:

source ~/.profile 

or

source ~/.bashrc

(See more on how to add a directory to your path.)