#!/bin/bash # make generic for an app function vscode_install { local src local target local dir="$(dirname $(realpath "${BASH_SOURCE:-$0}"))" local script=$dir/vscode.func [[ ! $(command -v code) ]] && echo "vscode binary (code) at must be installed first" && return 1 [[ ! -f $script ]] && echo can not find vscode function script at $script && return 2 target=${1:-/opt/bin}/vscode chmod +rx $script ln -sf $script $target echo link to $script created at $target ls -la /opt/bin | grep vscode echo with permissions ls -la $script } # if script was executed then call the function (return 0 2>/dev/null) || vscode_install $@