aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2016-03-03 22:08:50 +0100
committerAdrian Kummerlaender2016-03-03 22:08:50 +0100
commit5faa18fd97f4706e6eb47177dc1877a47febdfb1 (patch)
tree6612f708ac893a716eb11b335effcbc4c831fa7f
parent32f634e02a6ead1b69b608f95643e46bbdb37029 (diff)
downloadchange-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-xchange17
1 files 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