06/08/2021 23:17 | Category: utility

Tags: vimbash

zet screenshot utility

A big portion of the Zet-CLI that is missing is the ability to quickly create screenshots and input them into the markdown file.

I've seen a few things that are similar, with one being a utility script/Vim addon that would push the screenshots to an /img/<some img>.png that can be referenced locally.

I believe doing the following would be better (needs to be tested):

  • Create a Vim function that calls a Bash script
    • Passes the script the current working directory of the .md
      • Via the clipboard? Or is this saved in a buffer somewhere when started?
    • Opens gnome-screenshot using the "filename" and "selection" flags
    • After exiting it prints ![](./some/path/datetime-img-#.png)

Script idea:

#!/usr/bin/env bash
img_count=$(ls *.png | wc -l)
some_path_to_directory=<some clipboard thing?>
filename="$HOME/$some_path_to_directory/$(date '%Y%m%d%H%M%S-img-$img_count')"
gnome-screenshot -a -border-effect=shadow -f $filename

# uses xclip to pipe the full filename back
filename | xclip

Vim idea:


function! s:screenshot()
    " full path
    let @+ = expand("%:p")

    " copy the registry to the clipboard
    :w !pbcopy

    " execute shell script
    :! /path/to/some/bash.sh

endfunction