summaryrefslogtreecommitdiff
path: root/.local/bin/edit_document
diff options
context:
space:
mode:
author0scar <qgt268@alumni.ku.dk>2021-06-10 08:05:06 +0000
committer0scar <qgt268@alumni.ku.dk>2021-06-10 08:05:06 +0000
commit7ad685aa6bd77d76115132280ce323d7fc5aeeb0 (patch)
treec605992dfb5582a050b8847eb624fa84f1f97d91 /.local/bin/edit_document
parent6e4a15d79352ca2707a3b0d81d158228a7d14704 (diff)
Add scripts
Diffstat (limited to '.local/bin/edit_document')
-rwxr-xr-x.local/bin/edit_document13
1 files changed, 13 insertions, 0 deletions
diff --git a/.local/bin/edit_document b/.local/bin/edit_document
new file mode 100755
index 0000000..1a5fb78
--- /dev/null
+++ b/.local/bin/edit_document
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+
+DOCUMENT=$(find -L ~/${1:-documents} -name '*.tex' \
+ | fzf --header 'Choose a tex file to edit' \
+ --history=${XDG_CACHE_HOME:-$HOME/.cache}/edit_document.hist)
+
+[ -n "${DOCUMENT}" ] || exit 1
+
+LOCAL_PATH=$(echo $DOCUMENT | sed -E 's/[^\/]+.tex$//g')
+LOCAL_FILE=$(echo $DOCUMENT | sed -E 's/.*\///g')
+
+cd $LOCAL_PATH
+${EDITOR:-vim} $LOCAL_FILE