macos: add my fshard script; remove set_iterm2_tab_title.py
- ID
78bf9c8- date
2026-09-27 14:34:21+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
be6ecc1- message
macos: add my fshard script; remove set_iterm2_tab_title.py- changed files
2 files, 25 additions, 10 deletions
Changed files
macos/README.md (7570 → 7750)
diff --git a/macos/README.md b/macos/README.md
index 4541e1f..8603394 100644
--- a/macos/README.md
+++ b/macos/README.md
@@ -37,6 +37,10 @@ scripts = [
"description": "print the path to the frontmost selected item in Finder"
},
{
+ "name": "fshard",
+ "description": "print the lowercased first character of the filename of the frontmost selected item in Finder"
+ },
+ {
"name": "furl",
"description": "get the URL of the frontmost Safari window"
},
@@ -141,6 +145,15 @@ cog_helpers.create_description_table(folder_name=folder_name, scripts=scripts)
</dd>
<dt>
+ <a href="https://github.com/alexwlchan/scripts/blob/main/macos/fshard">
+ <code>fshard</code>
+ </a>
+ </dt>
+ <dd>
+ print the lowercased first character of the filename of the frontmost selected item in Finder
+ </dd>
+
+ <dt>
<a href="https://github.com/alexwlchan/scripts/blob/main/macos/furl">
<code>furl</code>
</a>
@@ -222,15 +235,6 @@ cog_helpers.create_description_table(folder_name=folder_name, scripts=scripts)
</dd>
<dt>
- <a href="https://github.com/alexwlchan/scripts/blob/main/macos/set_iterm_tab_title.py">
- <code>set_iterm_tab_title.py TITLE</code>
- </a>
- </dt>
- <dd>
- Set the title of a tab in iTerm 2
- </dd>
-
- <dt>
<a href="https://github.com/alexwlchan/scripts/blob/main/macos/sterilise">
<code>sterilise [PATH]</code>
</a>
@@ -260,4 +264,4 @@ cog_helpers.create_description_table(folder_name=folder_name, scripts=scripts)
</p>
</dd>
</dl>
-<!-- [[[end]]] (sum: uJMF1iuiOs) -->
+<!-- [[[end]]] (sum: HJjXQ1mrjm) -->
macos/fshard (0 → 318)
diff --git a/macos/fshard b/macos/fshard
new file mode 100755
index 0000000..a5f71c6
--- /dev/null
+++ b/macos/fshard
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+# fshard prints the lowercased first character of the filename of the
+# frontmost selected item in Finder.
+#
+# I use this when sharding files into directories based on filenames.
+
+set -o errexit
+set -o nounset
+
+filename=$(basename "$(ffile)")
+echo -n "${filename:0:1}" | tr '[:upper:]' '[:lower:]'