-
Notifications
You must be signed in to change notification settings - Fork 1
/
til.fish
44 lines (30 loc) · 872 Bytes
/
til.fish
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/fish
set til_path ~/Code/til/
# fzf-tags.fish contains the fzf-tags function.
# If you have moved both of them into your functions/ folder this should work as is.
function read_title
set prompt 'set_color green; echo -n "Title"; set_color normal; echo "> "'
read -p $prompt -g title
end
function to_kebab_case
echo $argv | tr '[:upper:]' '[:lower:]' | tr -cs '[:alnum:]' - | sed 's/^-//' | sed 's/-$//'
end
function til
pushd $til_path
read_title
set file_name (to_kebab_case $title).md
set file_path $til_path/$file_name
set tags (fzf-tags)
set -l frontmatter "---
title: $title
date: $(date --iso-8601)
tags:
$tags---
"
echo $frontmatter >$file_path
kitty --title til -e -- nvim $file_path + -c startinsert 2>/dev/null
git add $file_name
git commit -m "new til: $title"
git push
popd
end