Skip to content

Instantly share code, notes, and snippets.

View b0o's full-sized avatar
👻

Maddison Hellstrom b0o

👻
View GitHub Profile
#!/usr/bin/env bash
# Use (neo)vim as your MANPAGER
# Set MANPAGER=/path/to/viman in your shellrc
#
# Copyright 2020-2022 Maddison Hellstrom <https://github.com/b0o>
# MIT License
set -Eeuo pipefail
shopt -s inherit_errexit
#!/usr/bin/env bash
set -Eeuo pipefail
shopt -s inherit_errexit
declare vim="nvim"
command -v nvim &>/dev/null || vim="vim"
if [[ ! -t /dev/stdin ]]; then
MANPAGER='less' man "$@" -l -
elif [[ $# -gt 0 ]]; then
@b0o
b0o / Commands.ml
Last active January 16, 2022 23:05
let stringOfChannel ch =
let ok = ref false in
let result = ref "" in
let _ =
try
while true do
result := !result ^ "\n" ^ input_line ch
done
with End_of_file -> (
match Unix.close_process_in ch with
local shebang_regex = vim.regex([[^#!]])
local blank_or_comment_line_regex = vim.regex([[^\s*\(#.*\)\?$]])
local shellcheck_disable_regex = vim.regex([[^\s*#\s*shellcheck\s\+disable=\(\(SC\)\?\d\+\)\(,\(SC\)\?\d\+\)*\s*$]])
local shellcheck_disable_pattern = "^%s*#%s*shellcheck%s+disable=([^%s]*)%s*$"
-- Searches a region of the buffer `bufnr` for a ShellCheck disable directive.
-- The search proceeds from `row_start` to `row_end`.
-- If `row_start` is greater than `row_end`, the region is effectively searched in reverse.
-- A table representing first directive that's found is returned, otherwise nil.
local find_disable_directive = function(bufnr, row_start, row_end)
@b0o
b0o / audioctl
Last active October 22, 2021 16:24
audioctl
#!/usr/bin/env bash
# Copyright (c) 2018-2021 Maddison Hellstrom (github.com/b0o)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
[Default Applications]
text/plain=kitty-nvim.desktop;
[Desktop Entry]
Version=1.0
Name=Kitty (Neovim)
GenericName=Text Editor
Comment=Neovim in Kitty
Keywords=kitty;nvim;neovim
Icon=kitty
Terminal=false
X-MultipleArgs=false
Type=Application
function! MoveWindow(dir)
let l:orig_win = winnr()
let l:orig_buf = bufnr()
exe 'wincmd ' . a:dir
let l:dest_win = winnr()
let l:dest_buf = bufnr()
exe l:orig_win . 'windo hide buf' l:dest_buf
exe l:dest_win . 'windo hide buf' l:orig_buf
endfunction
nnoremap <M-S-h> :call MoveWindow('h')<Cr>
#compdef git-tag-version
# zsh completion for git-tag-version
_git-tag-version () {
_arguments -S -s "-h[usage]" "1:version-name" "2:from:__git_commits" "3:to:__git_commits"
}