diff options
author | Adrian Kummerlaender | 2016-03-03 22:08:50 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2016-03-03 22:08:50 +0100 |
commit | 5faa18fd97f4706e6eb47177dc1877a47febdfb1 (patch) | |
tree | 6612f708ac893a716eb11b335effcbc4c831fa7f | |
parent | 32f634e02a6ead1b69b608f95643e46bbdb37029 (diff) | |
download | change-5faa18fd97f4706e6eb47177dc1877a47febdfb1.tar change-5faa18fd97f4706e6eb47177dc1877a47febdfb1.tar.gz change-5faa18fd97f4706e6eb47177dc1877a47febdfb1.tar.bz2 change-5faa18fd97f4706e6eb47177dc1877a47febdfb1.tar.lz change-5faa18fd97f4706e6eb47177dc1877a47febdfb1.tar.xz change-5faa18fd97f4706e6eb47177dc1877a47febdfb1.tar.zst change-5faa18fd97f4706e6eb47177dc1877a47febdfb1.zip |
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.
-rwxr-xr-x | change | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -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 |