Gedit Snippets and External Tools.
Tab trigger: hugo
---
title:
summary:
date: $(TZ=UTC date +"%Y-%m-%dT%H:%M:%S%z")
---
Tab trigger: linkx
<a href="xxx" target="_blank" rel="noopener">xxx</a>
Shortcut key: Alt+J
Save: Nothing
Input: Current document
Output: Replace current document
#!/bin/sh
fold -w 80 -s
Shortcut key: Alt+F9
Save: Nothing
Input: Nothing
Output: Nothing
#!/usr/bin/env bash
exec >/dev/null 2>&1
file="$GEDIT_CURRENT_DOCUMENT_PATH"
if [[ -z "$file" || ! -f "$file" ]]; then
exit 0
fi
title=$(grep -m1 '^title:' "$file" | sed 's/^title:[[:space:]]*//')
if [[ -z "$title" ]]; then
exit 0
fi
slug=$(echo "$title" \
| tr '[:upper:]' '[:lower:]' \
| sed -E 's/[^a-z0-9]+/-/g; s/^-|-$//g')
dir=$(dirname "$file")
new="$dir/$slug.md"
# already correct name
if [[ "$file" == "$new" ]]; then
exit 0
fi
# write temp file then replace
tmp="${new}.tmp"
cat "$file" > "$tmp" && mv "$tmp" "$new" && rm "$file"
# Open the new file in new tab
gedit "$new" 2>/dev/null &
exit 0