From 5faa18fd97f4706e6eb47177dc1877a47febdfb1 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Thu, 3 Mar 2016 22:08:50 +0100 Subject: Implement support for automatic editor determination If the first argument is not an executable `change` tries to open the provided arguments as files in the default text editor. This adds `mimedb` as a new dependency. --- change | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/change b/change index bb21de3..b1929d8 100755 --- a/change +++ b/change @@ -1,13 +1,24 @@ #!/usr/bin/bash +source ~/.bashrc + readonly FILTER_PATH="/usr/local/share/libChangeLog/filter" +if [[ $(mimedb $1) == application* ]] +then + readonly EDITOR_NAME=$(basename $1) + readonly EDITOR_CMD="$@" +else + readonly EDITOR_NAME=$(basename $EDITOR) + readonly EDITOR_CMD="$EDITOR $@" +fi + export CHANGE_LOG_TARGET="/tmp/$(basename $0).$$.tmp" -export CHANGE_LOG_IGNORE_PATTERN_PATH="$FILTER_PATH/$(basename $1).filter" +export CHANGE_LOG_IGNORE_PATTERN_PATH="$FILTER_PATH/$EDITOR_NAME.filter" -LD_PRELOAD=libChangeLog.so eval "$@" +LD_PRELOAD=libChangeLog.so eval "$EDITOR_CMD" -if [ -e $CHANGE_LOG_TARGET ] +if [[ -e $CHANGE_LOG_TARGET ]] then cat $CHANGE_LOG_TARGET rm -f $CHANGE_LOG_TARGET -- cgit v1.2.3