Skip to content

Instantly share code, notes, and snippets.

@composite
Last active October 1, 2019 02:25
Show Gist options
  • Select an option

  • Save composite/e26aaa0b59715fda4515fbaa976432f1 to your computer and use it in GitHub Desktop.

Select an option

Save composite/e26aaa0b59715fda4515fbaa976432f1 to your computer and use it in GitHub Desktop.
A shell file for custom command of generated path.
declare TARGET_PATH=/path/to/some.thing
if [ ! -z "$*" ]; then
if [[ "$*" == '-'* ]]; then
echo $TARGET_PATH
exit
fi
declare CMD="$1"
shift
declare ARG="$*"
if [[ $* == *'{}'* ]]; then
"$CMD" ${ARG/\{\}/$TARGET_PATH}
else
"$CMD" $ARG "${TARGET_PATH}"
fi
exit
fi
echo 'USAGE:'
echo "$0 [COMMAND]: custom command for TARGET_PATH"
echo "example: $0 vi -R > vi -R [TARGET_PATH]"
echo " $0 fgrep 'example' {} | wc > fgrep 'example' [TARGET_PATH] | wc"
echo "$0 [-]: prints TARGET_PATH"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment