Skip to content

Instantly share code, notes, and snippets.

@sirmike
Last active July 13, 2022 12:57
Show Gist options
  • Save sirmike/45b8b79a7e7db93975ad4b6cb557ffc6 to your computer and use it in GitHub Desktop.
Save sirmike/45b8b79a7e7db93975ad4b6cb557ffc6 to your computer and use it in GitHub Desktop.
My toolbox

Terminal

Shell

Terminal multiplexer

My Tmux helpers

  • CTRL+A -> N - formats a json from a clipboard
  • CTRL+A -> X - formats an xml from a clipboard

Tmux conf fragment:

bind X new-window -n vim 'vim -c ":call FormatXmlFromClipboard()"'
bind N new-window -n vim 'vim -c ":call FormatJsonFromClipboard()"'

and Vim functions which are performing these formatting:

function! FormatXmlFast()
  :silent! %s/&lt;/</g
  :silent! %s/&gt;/>/g
  :silent! %s/&quot;/"/g
  :silent! %s/&amp;amp;/\&/g
  :silent! %s/&amp;/\&/g
  :silent! %s/>[ ]*</></g
  :silent! %s/></>\r</g
  set filetype=xml
  :normal gg=G
endfunction

function! FormatXmlFromClipboard()
  :normal "*p
  :call FormatXmlFast()
endfunction

function! FormatJsonFromClipboard()
  :normal "*p
  :silent! %!python -m json.tool
  set filetype=json
endfunction

Searching

Navigating disk

Working with textfiles

  • to_json
to_json() {
  underscore print --color -
}
  • to_xml
to_xml() {
  xmllint --format - | highlight --out-format=xterm256 --syntax=xml
}

Other tools

Colors

MacOS specific apps

Working with code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment