Skip to content

Instantly share code, notes, and snippets.

View mattboehm's full-sized avatar

Matthew Boehm mattboehm

View GitHub Profile
@Deraen
Deraen / vim-lightning-talk.md
Last active May 5, 2016 08:31
VIM Lightning talk
 __      _______ __  __            _____ _       _
 \ \    / /_   _|  \/  |    _     / ____| |     (_)
  \ \  / /  | | | \  / |  _| |_  | |    | | ___  _ _   _ _ __ ___
   \ \/ /   | | | |\/| | |_   _| | |    | |/ _ \| | | | | '__/ _ \
    \  /   _| |_| |  | |   |_|   | |____| | (_) | | |_| | | |  __/
     \/   |_____|_|  |_|          \_____|_|\___/| |\__,_|_|  \___|
                                               _/ |
                                              |__/
@sindresorhus
sindresorhus / post-merge
Last active May 2, 2024 03:18
git hook to run a command after `git pull` if a specified file was changed.In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed.Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
@qstrahl
qstrahl / minimal-autocomplete.vim
Last active February 24, 2024 06:43
Super lightweight autocomplete using vim's built-in <C-n> completion
set cot=menu,menuone
ino <BS> <BS><C-r>=getline('.')[col('.')-3:col('.')-2]=~#'\k\k'?!pumvisible()?"\<lt>C-n>\<lt>C-p>":'':pumvisible()?"\<lt>C-y>":''<CR>
ino <CR> <C-r>=pumvisible()?"\<lt>C-y>":""<CR><CR>
ino <Tab> <C-r>=pumvisible()?"\<lt>C-n>":"\<lt>Tab>"<CR>
ino <S-Tab> <C-r>=pumvisible()?"\<lt>C-p>":"\<lt>S-Tab>"<CR>
augroup MyAutoComplete
au!
au InsertCharPre * if
@mattboehm
mattboehm / gist:7109927
Last active January 6, 2024 07:25
Highlighting lines in vim
"with your cursor on a line or a block selected, type `:HL`
"to remove, on each line call :sign unplace
highlight HL ctermbg=darkgray
sign define hl linehl=HL
let s:highlightLineSignId = 74000
function! g:HighlightLine()
execute 'sign place' s:highlightLineSignId 'line='.line(".") 'name=hl' 'file='.expand("%")
let s:highlightLineSignId += 1
endfunction
command! HL call g:HighlightLine()
@caruccio
caruccio / bash-path-vars
Last active December 28, 2023 22:47
Path manipulation with bash vars
$ FILE=/some/path/to/file.txt
###################################
### Remove matching suffix pattern
###################################
$ echo ${FILE%.*} # remove ext
/some/path/to/file
$ FILE=/some/path/to/file.txt.jpg.gpg # note various file exts