1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-17 05:58:01 +00:00

Compare commits

..

1 Commits

Author SHA1 Message Date
nick-w-nick
929f7d13ac Merge 295fe153ad into 34ba60d313 2025-03-28 14:11:01 -04:00
3 changed files with 1 additions and 77 deletions

View File

@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
_1632 TILs and counting..._
_1630 TILs and counting..._
See some of the other learning resources I work on:
- [Ruby Operator Lookup](https://www.visualmode.dev/ruby-operators)
@@ -135,7 +135,6 @@ If you've learned something here, support my efforts writing daily TILs by
- [Duplicate The Current Tab](chrome/duplicate-the-current-tab.md)
- [Easier Access To Network Throttling Controls](chrome/easier-access-to-network-throttling-controls.md)
- [Keybinding To Focus The Address Bar](chrome/keybinding-to-focus-the-address-bar.md)
- [Open Current Tab In New Window With Vimium](chrome/open-current-tab-in-new-window-with-vimium.md)
- [Pause JavaScript From The Source DevTools Panel](chrome/pause-javascript-from-the-source-devtools-panel.md)
- [Navigate The Browser History With Vimium](chrome/navigate-the-browser-history-with-vimium.md)
- [Pretty Print Tabular Data](chrome/pretty-print-tabular-data.md)
@@ -1589,7 +1588,6 @@ If you've learned something here, support my efforts writing daily TILs by
- [Grep For Files Without A Match](unix/grep-for-files-without-a-match.md)
- [Grep For Files With Multiple Matches](unix/grep-for-files-with-multiple-matches.md)
- [Grep For Multiple Patterns](unix/grep-for-multiple-patterns.md)
- [Have Script ShellCheck Itself When Executing](unix/have-script-shellcheck-itself-when-executing.md)
- [Hexdump A Compiled File](unix/hexdump-a-compiled-file.md)
- [Ignore A Directory During ripgrep Search](unix/ignore-a-directory-during-ripgrep-search.md)
- [Ignore The Alias When Running A Command](unix/ignore-the-alias-when-running-a-command.md)

View File

@@ -1,14 +0,0 @@
# Open Current Tab In New Window With Vimium
Sometime I have a busy Chrome window going with a bunch of tabs open for
various lines of work as well as a number of tabs that I've neglected to close.
I then open a new tab, find something useful, and realize I'm at a "branching
point". I'm about to start in on a specific chunk of work that will probably
involve opening several more tabs and switch back and forth between some
dashboards. I want to start all of this from a fresh slate -- or at least from
a fresh Chrome window.
With [Vimium](https://github.com/philc/vimium), I can hit `W` (`Shift-w`) to
have the current tab move from the current window to a new window. The original
window, minus that one tab, will be left as is so that I can go back to it as
needed.

View File

@@ -1,60 +0,0 @@
# Have Script ShellCheck Itself When Executing
The [ShellCheck](https://www.shellcheck.net/) utility can be run against bash
scripts to check if there are any warnings or errors we should fix. It works
great as long as we remember to run it.
I wondered if I could make it easier on myself by not having to remember to run
it. What if my bash script were to `shellcheck` itself?
Here is an example script where at the beginning it looks for and runs the
`shellcheck` utility against `$0` (the path of the script). This is kind of
meta. As the script is executing, it has an external program run against the
entire contents of itself. If there are any `shellcheck` issues, they get
displayed and the program exits early.
```bash
#!/bin/bash
# Exit immediately if any command fails
set -e
# Self-validation using ShellCheck
if command -v shellcheck &> /dev/null; then
echo "Validating script with ShellCheck..."
# $0 refers to the script itself
if ! shellcheck "$0"; then
echo "ShellCheck found issues in the script. Exiting."
exit 1
fi
echo "Script validation passed."
else
echo "Warning: ShellCheck not found. Skipping validation."
fi
echo "Script execution continuing..."
# shellcheck warning here
read -p "Continue with current operation? (yes/no): " CONTINUE_WITH_EXISTING
if [[ ! "$CONTINUE_WITH_EXISTING" =~ ^[Yy][Ee][Ss]$ ]]; then
echo "Operation cancelled."
exit 1
fi
```
This last bit of the script with the `read` command will trigger a warning from
`shellcheck`.
```bash
$ ./check.sh
Validating script with ShellCheck...
In ./check.sh line 23:
read -p "Continue with current operation? (yes/no): " CONTINUE_WITH_EXISTING
^--^ SC2162 (info): read without -r will mangle backslashes.
For more information:
https://www.shellcheck.net/wiki/SC2162 -- read without -r will mangle backs...
ShellCheck found issues in the script. Exiting.
```