Cybrkyd's Git Repositories

gedit-config

Branch: main Last commit: 2026-05-07 18:41:25 +0100 Clone: git clone https://git.cybrkyd.com/repository/gedit-config

Gedit Config

Gedit Snippets and External Tools.

Snippets: Markdown

Tab trigger: hugo

---
title: 
summary: 
date: $(TZ=UTC date +"%Y-%m-%dT%H:%M:%S%z")
---


Tab trigger: linkx

<a href="xxx" target="&#95;blank" rel="noopener">xxx</a>

External Tools

Fold text to 80 columns


Shortcut key: Alt+J
Save: Nothing
Input: Current document
Output: Replace current document

#!/bin/sh
fold -w 80 -s


Rename open Markdown doc with title from YAML, and open it in new tab


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