diff options
author | Peter | 2022-02-01 12:34:11 +0000 |
---|---|---|
committer | Peter | 2022-02-01 12:34:11 +0000 |
commit | e50c7d7db628cbbbca7c3754a4e1faf17352aa3d (patch) | |
tree | bc00c6ebbc752448f928a9e9d7241be6553ba488 /content/posts | |
parent | a243b9f65ace5a5bb92cbb2dae24f8cacc0fdad6 (diff) | |
download | blog.minskio.co.uk-e50c7d7db628cbbbca7c3754a4e1faf17352aa3d.tar.gz blog.minskio.co.uk-e50c7d7db628cbbbca7c3754a4e1faf17352aa3d.tar.bz2 blog.minskio.co.uk-e50c7d7db628cbbbca7c3754a4e1faf17352aa3d.zip |
Couple new posts
Diffstat (limited to 'content/posts')
-rw-r--r-- | content/posts/2022-new-years-resolutions.md | 16 | ||||
-rw-r--r-- | content/posts/formatting-and-checking-bash-scripts.md | 30 |
2 files changed, 46 insertions, 0 deletions
diff --git a/content/posts/2022-new-years-resolutions.md b/content/posts/2022-new-years-resolutions.md new file mode 100644 index 0000000..0e62f3b --- /dev/null +++ b/content/posts/2022-new-years-resolutions.md @@ -0,0 +1,16 @@ +--- +title: "2022 New Year's Resolutions" +date: 2022-01-14T12:02:00 +lastmod: 2022-01-14T12:02:00 +tags: ["Health", "Lifestyle", "Lists"] +--- + +Another year, another belated list: + +* ~[65kg weight](/weight/) +* Continue Japanese Duolingo course +* Increase crypto holdings and savings +* Install FOSS Wi-Fi AP +* Provision computers using ansible +* Server 2.0 Project (email, xmpp, seedbox) +* Start running again diff --git a/content/posts/formatting-and-checking-bash-scripts.md b/content/posts/formatting-and-checking-bash-scripts.md new file mode 100644 index 0000000..a3d2411 --- /dev/null +++ b/content/posts/formatting-and-checking-bash-scripts.md @@ -0,0 +1,30 @@ +--- +title: "Formatting and checking bash scripts" +date: 2022-02-01T11:52:00 +lastmod: 2022-02-01T11:52:00 +tags: ["Linux", "Software", "Snippets"] +--- + +Everyone's head of [shellcheck](https://github.com/koalaman/shellcheck) for checking over scripts to ensure obvious (and not-so-obvious) mistakes aren't being made. Afterwards I usually quite like to beautify/prettify/format up code to get all the usual readability improvements gained from this. In the past, I've used [beautysh](https://github.com/lovesegfault/beautysh) and while it's worked, I generally don't like using python programs when alternatives are available, and especially don't like manually installing programs when it can be done via the package manager. In steps [shfmt](https://github.com/mvdan/sh), a handy go program (no dependencies, portable, etc) that works exactly how you'd expect it to be run. + +It can either be installed via [your package manager](https://github.com/mvdan/sh#readme), or you can install it from source using go: +``` +go install mvdan.cc/sh/v3/cmd/shfmt@latest +``` + +Once installed, test it's runnable +``` +shfmt --version +``` + +With that confirmed, you can run it against a bash script as such: +``` +shfmt -l -d path/to/your/script.sh +``` + +In the above example, the `-l` flag formats the text and the `-d` flag shows a diff of what's been changed. +If you're happy with the changes shown, you can replace the `-d` flag with `-w` to overwrite the original file: + +``` +shfmt -l -w path/to/your/script.sh +```
\ No newline at end of file |