Skip to content

Instantly share code, notes, and snippets.

@willbeaufoy
willbeaufoy / git commit formatter
Last active August 29, 2015 14:09
Format a file so that no line can exceed 72 characters (for git commit messages)
# Outputs to shell. Could be updated to change file in place. Explanation here:
# https://stackoverflow.com/questions/26991777/regex-sed-how-to-match-the-last-space-character-in-a-line-before-a-72-charac?answertab=active#tab-top
sed 'y/ /³/
s/.*/\
&³/
:space
s/\(.*\n\)\([^³]\{0,72\}\)³/\1\2 /
t space
s/\(.*\) \([^³]*³\)/\1\
@willbeaufoy
willbeaufoy / sman
Last active November 17, 2021 10:49
Open man pages in Sublime Text 3
# Paste this function into the shell, and/or add it to .bashrc.
# Then typing sman ssh will open the ssh man page in sublime text.
# Requires sublime text command line options (open with subl)
function sman()
{
man $1 > /tmp/man && subl /tmp/man
}