#!/usr/bin/env bash print_long_help() { cat <] FLAGS: -h, --help show this help message and exit OPTIONS: -p Port use for on host for the Pluto Server ARGS: Port on client to connect Pluto Server Either an ~/.ssh/config alias or the host address EOF } print_short_help() { cat <] For more information try --help EOF } print_start_msg() { cat </dev/null fi ssh -L "$1":localhost:"${3:-7000}" "$2"\ "julia -e\ \"import Pluto; Pluto.run( port=${3:-7000}, require_secret_for_open_links=false, require_secret_for_access=false )\"" } exit_msg(){ printf "\nNotebook has been shutdown\n" exit 0 } # Print help and exit ==== if [[ $1 == '--help' ]]; then print_long_help exit 0 elif [[ "$1" =~ '-h' ]]; then print_short_help exit 0 fi # Parse arguments ==== positional_args=() while [[ "$#" -gt 0 ]]; do arg="$1" case $arg in -p) host_port="$2" shift shift ;; *) positional_args+=("$1") shift ;; esac done set -- "${positional_args[@]}" # Set graceful exit if [[ "$#" -eq 2 ]]; then trap exit_msg SIGINT print_start_msg "$1" ssh_pluto_tunnel $1 $2 $host_port else print_short_help exit 2 fi