Compare commits

...

9 Commits

8 changed files with 79 additions and 36 deletions

View File

@ -17,6 +17,8 @@ else
set -x EDITOR "vim -u ~/.config/vim/vimrc"
end
alias datenow="date '+%Y-%m-%d'"
function please
@ -61,7 +63,9 @@ if status --is-interactive
alias g="git"
mkdir -p ~/.local
if [ (expr (date '+%s') - (cat "$HOME/.local/last_shell" 2>/dev/null || echo 0)) -gt "28800" ]
set time_diff (expr (date '+%s') - (cat "$HOME/.local/last_shell" 2>/dev/null || echo 0))
if [ "$time_diff" -gt "28800" ]
[ -d "$HOME/tmp" ] && rm -rf "$HOME/tmp/*"
timeout 5 git sit && date '+%s' > "$HOME/.local/last_shell"
echo ""
end

View File

@ -1,7 +1,7 @@
[init]
defaultBranch = main
[user]
name = Sam Greytalon
name = Sam Talonborn
email = sam@oaktal.com
[pull]
rebase = false

View File

@ -1,6 +1,5 @@
nnoremap gf :let @a='../'.expand('%')<CR>vi>y<Esc>:tabnew <C-R>"<CR>:let @"=@a
vnoremap gf y<Esc>:let @a='../'.expand('%')<CR>:tabnew <C-R>"<CR>:let @"=@a
nnoremap mf viwc[]<Esc>hpla(<>)<Left><Left><C-R>=expand('%')<CR><Esc>F/l"_dt>hpa.md<Esc>
vnoremap mf c[]<Esc>hpla(<>)<Left><Left><C-R>=expand('%')<CR><Esc>F/l"_dt>hpa.md<Esc>
nnoremap ml :r!grep -Rl '' .<Left><Left><Left>
vnoremap ml y<Esc>:execute 'r!grep -Rl '.shellescape(@", 1).' .'<CR>
nnoremap gl vi)y<Esc>:tabnew <C-R>"<CR>
vnoremap gl y<Esc>:tabnew <C-R>"<CR>
nnoremap ml viwc[]<Esc>hpla()<Esc>hpa.md<Esc>
vnoremap ml c[]<Esc>hpla()<Esc>hpa.md<Esc>

View File

@ -6,6 +6,10 @@ autocmd FileType markdown set columns=80
autocmd FileType markdown set linebreak
autocmd FileType markdown setlocal comments+=">"
autocmd FileType gemtext setlocal wrap
autocmd FileType gemtext setlocal linebreak
autocmd FileType gemtext setlocal columns=80
autocmd FileType text setlocal textwidth=120
autocmd FileType text setlocal formatoptions=tcroqawn
autocmd FileType text,markdown,gemtext set spell

View File

@ -4,4 +4,4 @@ Host *
IgnoreUnknown UseKeychain
UseKeychain yes
AddKeysToAgent yes
IdentityFile ~/.ssh/id_rsa
IdentityFile ~/.ssh/id_ed25519

View File

@ -7,7 +7,7 @@ dest="$3"
root="$(pwd)"
rm -r "$dest"
cp -r "$src" "$dest"
rsync -a --exclude '.*' "$src" "$dest"
files="$(find "$dest" -type f)"

View File

@ -51,14 +51,14 @@ print OUT <<"END_HTML";
END_HTML
my $line = convert_gmi_line($old_title);
print OUT " $line\n";
print OUT " $line";
foreach $line (<IN>) {
chomp $line;
my $out = convert_gmi_line($line);
if (defined $out) {
print OUT " $out\n";
print OUT " $out";
}
}
@ -68,30 +68,50 @@ print OUT <<'END_HTML';
END_HTML
sub convert_gmi_line {
state $mode = 'normal';
state $pre = 0;
state $list = 0;
my ($line) = @_;
if ($mode eq 'pre') {
if ($pre == 1) {
if ($line eq '```') {
$mode = 'normal';
return undef;
$pre = 0;
return "</pre>\n";
}
return $line;
return " $line\n";
}
if ($line =~ /^\* /) {
if ($list == 0) {
return '<ul>';
if ($line eq '```') {
$pre = 1;
if ($list == 1) {
$list = 0;
return "</ul>\n <pre>\n";
}
return "<pre>\n";
}
if ($list == 0) {
if ($line =~ /^\* /) {
$list = 1;
my $listitem = convert_gmi_line($line);
return "<ul>\n $listitem";
}
}
else {
if ($list == 1) {
return '</ul>';
if (not $line =~ /^\* /) {
$list = 0;
my $nextline = convert_gmi_line($line);
if (defined $nextline) {
return "</ul>\n $nextline";
}
else {
return "</ul>\n";
}
}
}
@ -102,43 +122,39 @@ sub convert_gmi_line {
my $text = $2;
$link =~ s/\.gmi/\.html/;
return "<p><a href=\"$link\">$text</a></p>";
return "<p><a href=\"$link\">$text</a></p>\n";
}
when(/^#[^#]/) {
$line =~ s/^#\s*//;
return "<h1>$line</h1>";
return "<h1>$line</h1>\n";
}
when(/^##[^#]/) {
$line =~ s/^##\s*//;
return "<h2>$line</h2>";
return "<h2>$line</h2>\n";
}
when(/^###/) {
$line =~ s/^###\s*//;
return "<h3>$line</h3>";
return "<h3>$line</h3>\n";
}
when(/^\*\s*/) {
$line =~ s/^\*\s*//;
return "<li>$line</li>";
return " <li>$line</li>\n";
}
when(/^>/) {
$line =~ s/^>//;
$line =~ s/^>\s*//;
return "<blockquote>$line</blockquote>";
}
when('```') {
$mode = 'pre';
return undef;
return "<blockquote>$line</blockquote>\n";
}
default {
if ($line eq '') {
return undef;
}
return "<p>$line</p>";
return "<p>$line</p>\n";
}
}
}

View File

@ -36,6 +36,20 @@ while [ $# -ne 0 ]; do
echo "$time $file"
done | sort -k 1,1 | awk '{ $1="" }1')"
;;
TITLE)
files="$(echo "$files" | while read -r file; do
path="$(echo "$file" | awk '{ print $1 }')"
title="$(cat "$file" | sed '1!d')"
echo "$path $title"
done | sort -k 2 | awk '{ print $1 }')"
;;
SUBTITLE)
files="$(echo "$files" | while read -r file; do
path="$(echo "$file" | awk '{ print $1 }')"
subtitle="$(cat "$file" | sed '2!d')"
echo "$path $subtitle"
done | sort -k 2 | awk '{ print $1 }')"
;;
esac
shift
@ -75,6 +89,12 @@ while [ $# -ne 0 ]; do
echo "$file $(head -n1 "$path" 2> /dev/null | sed 's/^#//g' | sed 's/^ //g')"
done)"
;;
SUBTITLE)
files="$(echo "$files" | while read -r file; do
[ "$file" = "" ] && continue
path="$(echo "$file" | awk '{ print $1 }')"
echo "$file $(cat "$path" 2> /dev/null | sed '2!d' | sed 's/^##//g' | sed 's/^ //g')"
done)"
esac
shift