Skip to content

Instantly share code, notes, and snippets.

@fungusakafungus
Created July 22, 2013 18:20
Show Gist options
  • Save fungusakafungus/6056205 to your computer and use it in GitHub Desktop.
Save fungusakafungus/6056205 to your computer and use it in GitHub Desktop.
Use `type` builtin to format bash code. Give it a bash file as an argument, it will overwrite it with formatted bash. Kinda useful for one-liners, but adds useless semicolons and strips comments. At least.
#!/bin/bash
eval "function $1() { $(cat $1); }";
type $1 2>&1 | sed -n 's#^ ##p' > "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment