Thursday, December 28, 2023

how to use vim-surround reminder 2 self

vim surround

you type capitol v capitol s as if you were typing VIM SURROUND, then you type out your tag like p for example.

Wednesday, December 27, 2023

chmod a file from within vim


:!chmod +x %

its a pretty cool trick. so great that you don't need to leave vim!

Tuesday, December 26, 2023

xfce4 is pretty sweet what about mac?

xfce4 timer is perfect. it can run a shell command periodically. I've got it set up like a pomodoro.Got me wondering how i could do this on my mac? Maybe cron jobs?

I heard cronnix the gui front end for cron jobs was discontinued. maybe Il just use chatgpt to write my cron commands

Saturday, December 23, 2023

how to join org files and delete duplicates

delete

ls *.org | grep -v -E "(merge.org|init\.org|groovy\ black\.org)" | xargs rm

merges

awk '!seen[$0]++' *.org | grep -vE 'init\.org|groovy black\.org' > merge.org

how to join org files

you type this in the terminal in the current working directory and it joins all your org files you have in there and outputs them to a file called merged.org


cat *.org > merged.org

very handy indeed.

cool pomodoro timer website

pomodor
pomofocus

syncthing daemon

I decided to set up a daemon to automatically start synthing heres how


sudo vim /etc/systemd/system/syncthing.service

use the whoami command if you don't know your username. and add it to this syncthing.service file



[Unit]
Description=Syncthing - Open Source Continuous File Synchronization
After=network.target

[Service]
User=
ExecStart=/usr/bin/syncthing -no-browser -gui-address="http://127.0.0.1:8384"
Restart=on-failure
RestartSec=10
ExecStartPre=/bin/sleep 5

[Install]
WantedBy=multi-user.target

reload systemd to read new service file



sudo systemctl daemon-reload

start syncthing service and enable it to start on boot:



sudo systemctl start syncthing
sudo systemctl enable syncthing

now syncthing should be running as a daemon on your linux system. you can use commands like 'sudo systemctl start/stop/restart/status syncthing'

how to set path on vimwiki

add this to your vimrc

let g:vimwiki_path = '~/Documents/vimwiki/'

It's annoying how when you first try to run vimwiki on an iphone it prompts to create the vimwiki folder but it can't properly in a-shell mini because of sandboxing. The github page said just look it up in the manual. :h vimwiki_list. for some reason the help docs weren't opening for me so anyway I just asked chatgpt for some lines to add to the vimrc.

Thursday, December 21, 2023

how to sudo save a file already open in vim

how to sudo save a file already open in vim

    
  :w ! sudo tee %
    

its super annoying when you type out that long path only to find you forgot to sudo and now it wont let you save. It's good to know there's a way to fix this.

xfce4-timer: it was there all along

i should've used xfce4-timer instead

pomodoro shmomadoro. who needs it anyway? well i thought i did.

turns out there was something hidden away in linux mint in plain sight.

all i had to do was click in the top right corner

panel: add new items: xfce4-timer

what I like about it is it lets you trigger a command after the timed interval

tomatoshell was cool but I like this one because I dont need to just have it be for half hour increments. also its kind of a waste to have a terminal window taken up by a graphical thing. this is less obtrusive exactly what i was looking for all along. Im still glad I didn't download that gigabyte sized pomodoro. (although its tempting im still kind of curious to see what 2 gigabytes of pomodoro could be. I imagine the tomato being 2 gigabytes juicier even though the juicyness has nothing to do with the file size. but im curious still...)

cli pomodoro for linux

tomatoshell

almost went with gnome pomodoro it was the only thing that showed up in the package manager but damn its almost a gigabyte. WHY!!! theres no reason a simple pomodoro timer app needs to be almost a gig jeeeezus.

"I tried a few others, none of them worked. Probably downloaded a million viruses on my computer instead."

how to use

  • p = pause
  • s = skip (reset)
  • q = quit

you can make a custom alarm by putting your own alarm.wav file in

    
  $HOME/.local/share/tomatoshell/alarm.wav
    

how to install fzf in vim

how to install fzf in vim

add this to your .vimrc


Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'

and this further down



"fzf
nnoremap fr :Files

# I've got it triggered with Space F -R like doom emacs


I tried to use fzf before and was unsuccessful


apt installing it wasn't enough


installing junegun/fzf wasn't enough either


you need all 3 for it to work


the next hurdle you have to jump over is set a keybind


vim spellcheck

:set spell

  • s[ search next mispelled word
  • z= that brings up a list of corrections
  • :set nospell turns it off

ctrl o: temporary normal mode

ive been using this one a whole lot lately.

with emmet i have comma in normal mode to expand html.

it gets really confusing switching back and forth between modes all the time. being able to slip in and out without ever leaving insert has real potential for some slick typing

p ctrl o comma coma

its gonna take some getting used to to work that into muscle memory but it will be worth it.

ctrl o o = jump line staying in insert mode

dealing with splits in vim

ctrl w r = swap panes

ctrl w c = close panes


Sunday, December 17, 2023

Control + Alt + D = hide desktop (linux mint)

this is the default. i was thinking about remapping ctrl h to hide but that toggles hide/show hidden files. was maybe thinking command h, was going to see if there was already something conflicting but then i saw control alt d. most of the time I just want to hide everything anyway and use rofi to launch stuff.

what sucked was I wanted to be like linuxmint-computer@local to ssh into it but it wouldnt let me.

on raspberry pi i could do that and it was nice because I wouldnt need to know my ip all the time. DNS would switch the ips

Avahi is what you need

sudo apt install avahi-daemon

type hostname it will tell you your hostname

so easy to break a hugo site

I forgot to put my tags in doublequotes.

gh pages actions freaks out at you saying the TOML is wrong.

multiple git commits later realized last few blogposts werent posted :(

even though it was in one file. all the other posts that were correctly formatted wouldnt be added because hugo builds the entire site at once from the markdown files.

How I like to setup Copyq

settings

theres a lot of things you need to change to make this clipboard manager decent. a majorly annoying thing is when an item is selected in the list IT DOESNT ADD IT TO YOUR CLIPBOARD. the terminal you have to say copyq next, copyq previous (prev doesnt work!) grossly verbose.

enable vi motions (obviously)


enable autostart


disable closed when unfocused (default on is annoying)


preferences: appearances: enable darktheme


in history: set editor to gvim -f %1


max number of items in history i set to 10


layout: disable hide toolbar labels (default is off)


just use rofi

its kind of annoying in 3 ways.

  • you need to type out and remember long terminal commands
  • gui keeps dissapearing
  • even though you select it it doesnt copy

setting up rofi to deal with it instead is wayyyy better.


I have it set to pop up with ctrl period


            
#!/usr/bin/env python3

# https://github.com/albertlauncher/python/blob/master/CopyQ.py

import json
import subprocess as sp

copyq_script_getAll = r"""
var result=[];
for ( var i = 0; i < size(); ++i ) {
    var obj = {};
    obj.row = i;
    obj.mimetypes = str(read("?", i)).split("\n");
    obj.mimetypes.pop();
    obj.text = str(read(i));
    result.push(obj);
}
JSON.stringify(result);
"""


if __name__ == '__main__':
    p = sp.run('copyq -'.split(), input=copyq_script_getAll,
               encoding='utf-8', stdout=sp.PIPE, stderr=sp.PIPE)
    json_arr = json.loads(p.stdout)

    items = []
    for json_obj in json_arr:
        text = json_obj['text']
        text = " ".join(filter(None, text.replace("\n", " ").split(" ")))
        items.append(text)

    title = 'rofi-copyq'
    rofi = f'rofi -dmenu -i -p {title} -format i'.split()
    rofi_input = '\n'.join(x for x in items)

    p = sp.run(rofi, input=rofi_input, encoding='utf-8', stdout=sp.PIPE, stderr=sp.PIPE)
    if p.returncode == 0:
        num = p.stdout.strip()
        sp.run(f'copyq select({num});'.split(),
               encoding='utf-8', stdout=sp.PIPE, stderr=sp.PIPE)
            
        

I put that text in a text file called roficlipq.py


startmenu: settings: keyboard: application shortcuts: python3 pathto roficopyq.py


qr code generation

this is a pretty cool feature


you enable by going to


preferences: shortcuts: application: create qr code from url (requires qrencode)

sudo apt install qrencode

i find this very handy

Friday, December 15, 2023

Vscode Extensions

vscode extensions

some extensions im using lately.

Thursday, December 14, 2023

Hugo Date Format In Vim

cliptools is perfect on mac for creating front matter.
too bad its only on mac.
I tried looking for a solution using a clipboard manager on linux.
but it only got me part way there. hardest part is adding the date.
looked at some snippet tools and some automation tools.
cb, copyq, clipman, diodon
the vim plugin hugo helper sucks. its too complicated.
almost easier to do manually. (defeats the whole purpose)
I found out you don't need a plugin vims got you covered.

add this to your .vimrc:
" Map <leader>d to insert the current date and time in "YYYY-MM-DD HH:MM:SS" format
nnoremap <leader>d i<C-R>=strftime('%Y-%m-%d %H:%M:%S')<CR><Esc>

potatoes

potatoes reaching for the light//

they have no eye but they grow them.

the roots reach out for the light

they grow tentacles and they find a  way.

pushing through the bag. in search of soil

in search of light

Wednesday, December 13, 2023