summaryrefslogtreecommitdiff
path: root/.local/bin/edit_document
diff options
context:
space:
mode:
author0scar <qgt268@alumni.ku.dk>2022-01-16 20:04:55 +0000
committer0scar <qgt268@alumni.ku.dk>2022-01-16 20:05:28 +0000
commit6a6490fa010d0d0b3670e464852ec8d5222c5c83 (patch)
tree92fbb9a54a3ab6f1606ee76113fb5aa1189928b0 /.local/bin/edit_document
parent714c658df99435e7ebd9aaefc22000ece9c356a0 (diff)
Auto-position preview window in edit_document
The preview is placed on top, if the terminal window is less than 120 columns wide.
Diffstat (limited to '.local/bin/edit_document')
-rwxr-xr-x.local/bin/edit_document5
1 files changed, 5 insertions, 0 deletions
diff --git a/.local/bin/edit_document b/.local/bin/edit_document
index 3afa96e..7609770 100755
--- a/.local/bin/edit_document
+++ b/.local/bin/edit_document
@@ -3,9 +3,14 @@
DIR=${1:-~/documents}
EXTENSION=${2:-tex}
+PREVIEWPOS=right
+
+[ $(( $(tput cols) )) -lt 120 ] && PREVIEWPOS=up
+
DOCUMENT=$(find -L $DIR -name "*.${EXTENSION}" \
| fzf -m --header 'Open file(s) in $EDITOR' \
--history=${XDG_CACHE_HOME:-$HOME/.cache}/edit_document.hist \
+ --preview-window=$PREVIEWPOS \
--border=rounded --preview='bat {}')
[ -n "${DOCUMENT}" ] || exit 1