mirror of
https://github.com/jbranchaud/til
synced 2026-01-07 17:18:02 +00:00
Compare commits
6 Commits
73476a8d16
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4801e730f9 | ||
|
|
bd021f7eab | ||
|
|
8d8cfd56ce | ||
|
|
f4faa06258 | ||
|
|
8ccbd82320 | ||
|
|
5ea4165893 |
@@ -10,7 +10,7 @@ working across different projects via [VisualMode](https://www.visualmode.dev/).
|
|||||||
|
|
||||||
For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter).
|
For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter).
|
||||||
|
|
||||||
_1716 TILs and counting..._
|
_1721 TILs and counting..._
|
||||||
|
|
||||||
See some of the other learning resources I work on:
|
See some of the other learning resources I work on:
|
||||||
|
|
||||||
@@ -158,6 +158,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
|||||||
|
|
||||||
### Claude Code
|
### Claude Code
|
||||||
|
|
||||||
|
- [Allow Edits From The Start](claude-code/allow-edits-from-the-start.md)
|
||||||
- [Monitor Usage Limits From CLI](claude-code/monitor-usage-limits-from-cli.md)
|
- [Monitor Usage Limits From CLI](claude-code/monitor-usage-limits-from-cli.md)
|
||||||
- [Open Current Prompt In Default Editor](claude-code/open-current-prompt-in-default-editor.md)
|
- [Open Current Prompt In Default Editor](claude-code/open-current-prompt-in-default-editor.md)
|
||||||
|
|
||||||
@@ -349,6 +350,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
|||||||
- [Count Number Of Commits On A Branch](git/count-number-of-commits-on-a-branch.md)
|
- [Count Number Of Commits On A Branch](git/count-number-of-commits-on-a-branch.md)
|
||||||
- [Create A New Branch With Git Switch](git/create-a-new-branch-with-git-switch.md)
|
- [Create A New Branch With Git Switch](git/create-a-new-branch-with-git-switch.md)
|
||||||
- [Delete All Untracked Files](git/delete-all-untracked-files.md)
|
- [Delete All Untracked Files](git/delete-all-untracked-files.md)
|
||||||
|
- [Determine Absolute Path Of Top-Level Project Directory](git/determine-absolute-path-of-top-level-project-directory.md)
|
||||||
- [Determine The Hash Id For A Blob](git/determine-the-hash-id-for-a-blob.md)
|
- [Determine The Hash Id For A Blob](git/determine-the-hash-id-for-a-blob.md)
|
||||||
- [Diffing With Patience](git/diffing-with-patience.md)
|
- [Diffing With Patience](git/diffing-with-patience.md)
|
||||||
- [Dropping Commits With Git Rebase](git/dropping-commits-with-git-rebase.md)
|
- [Dropping Commits With Git Rebase](git/dropping-commits-with-git-rebase.md)
|
||||||
@@ -501,6 +503,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
|||||||
|
|
||||||
### Heroku
|
### Heroku
|
||||||
|
|
||||||
|
- [Check Ruby Version For Production App](heroku/check-ruby-version-for-production-app.md)
|
||||||
- [Connect To A Database By Color](heroku/connect-to-a-database-by-color.md)
|
- [Connect To A Database By Color](heroku/connect-to-a-database-by-color.md)
|
||||||
- [Deploy A Review App To A Different Stack](heroku/deploy-a-review-app-to-a-different-stack.md)
|
- [Deploy A Review App To A Different Stack](heroku/deploy-a-review-app-to-a-different-stack.md)
|
||||||
- [Diagnose Problems In A Heroku Postgres Database](heroku/diagnose-problems-in-a-heroku-postgres-database.md)
|
- [Diagnose Problems In A Heroku Postgres Database](heroku/diagnose-problems-in-a-heroku-postgres-database.md)
|
||||||
@@ -747,6 +750,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
|||||||
|
|
||||||
- [Create Umbrella Task For All Test Tasks](mise/create-umbrella-task-for-all-test-tasks.md)
|
- [Create Umbrella Task For All Test Tasks](mise/create-umbrella-task-for-all-test-tasks.md)
|
||||||
- [List The Files Being Loaded By Mise](mise/list-the-files-being-loaded-by-mise.md)
|
- [List The Files Being Loaded By Mise](mise/list-the-files-being-loaded-by-mise.md)
|
||||||
|
- [Look In Ruby Version Dotfile](mise/look-in-ruby-version-dotfile.md)
|
||||||
- [Preserve Color Output For Task Command](mise/preserve-color-output-for-task-command.md)
|
- [Preserve Color Output For Task Command](mise/preserve-color-output-for-task-command.md)
|
||||||
- [Read Existing Dot Env File Into Env Vars](mise/read-existing-dot-env-file-into-env-vars.md)
|
- [Read Existing Dot Env File Into Env Vars](mise/read-existing-dot-env-file-into-env-vars.md)
|
||||||
- [Run A Command With Specific Tool Version](mise/run-a-command-with-specific-tool-version.md)
|
- [Run A Command With Specific Tool Version](mise/run-a-command-with-specific-tool-version.md)
|
||||||
@@ -1638,6 +1642,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
|||||||
- [Different Ways To Generate A v4 UUID](unix/different-ways-to-generate-a-v4-uuid.md)
|
- [Different Ways To Generate A v4 UUID](unix/different-ways-to-generate-a-v4-uuid.md)
|
||||||
- [Display All The Terminal Colors](unix/display-all-the-terminal-colors.md)
|
- [Display All The Terminal Colors](unix/display-all-the-terminal-colors.md)
|
||||||
- [Display Free Disk Space](unix/display-free-disk-space.md)
|
- [Display Free Disk Space](unix/display-free-disk-space.md)
|
||||||
|
- [Display Line Numbers While Using Less](unix/display-line-numbers-while-using-less.md)
|
||||||
- [Display The Contents Of A Directory As A Tree](unix/display-the-contents-of-a-directory-as-a-tree.md)
|
- [Display The Contents Of A Directory As A Tree](unix/display-the-contents-of-a-directory-as-a-tree.md)
|
||||||
- [Do A Dry Run Of An rsync](unix/do-a-dry-run-of-an-rsync.md)
|
- [Do A Dry Run Of An rsync](unix/do-a-dry-run-of-an-rsync.md)
|
||||||
- [Do Not Overwrite Existing Files](unix/do-not-overwrite-existing-files.md)
|
- [Do Not Overwrite Existing Files](unix/do-not-overwrite-existing-files.md)
|
||||||
|
|||||||
35
claude-code/allow-edits-from-the-start.md
Normal file
35
claude-code/allow-edits-from-the-start.md
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# Allow Edits From The Start
|
||||||
|
|
||||||
|
A common pattern for me when using Claude Code is that I start it up in a
|
||||||
|
project, I prompt it with a question or feature spec, it either comes up with a
|
||||||
|
plan or just starts working, and as soon as it is ready to make its first edits
|
||||||
|
to a file, it prompts me something like:
|
||||||
|
|
||||||
|
```
|
||||||
|
Do you want to make this edit to Taskfile.yml?
|
||||||
|
❯ 1. Yes
|
||||||
|
2. Yes, allow all edits during this session (shift+tab)
|
||||||
|
3. Type here to tell Claude what to do differently
|
||||||
|
```
|
||||||
|
|
||||||
|
That's a nice default so that I don't get surprised by Claude Code editing a
|
||||||
|
bunch of files.
|
||||||
|
|
||||||
|
However, if I'm in a git-backed project and I'm going into a session intending
|
||||||
|
to make edits, then I can skip the formalities. I can tell Claude Code when
|
||||||
|
starting up the session that edits are allowed.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ claude --permission-mode acceptEdits
|
||||||
|
```
|
||||||
|
|
||||||
|
When I do this, I'll see the following indicator below the prompt input field:
|
||||||
|
|
||||||
|
```
|
||||||
|
⏵⏵ accept edits on (shift+tab to cycle)
|
||||||
|
```
|
||||||
|
|
||||||
|
If I've already started `claude` but I forgot to specify that permission mode, I
|
||||||
|
can also toggle right into _accept edits_ by hitting `Shift+Tab`.
|
||||||
|
|
||||||
|
[source](https://www.youtube.com/watch?v=_IK18goX4X8)
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
# Determine Absolute Path Of Top-Level Project Directory
|
||||||
|
|
||||||
|
The `git rev-parse` command is a git plumbing command for parsing different
|
||||||
|
kinds of things in git into a canonical form that can be used in a deterministic
|
||||||
|
way by scripts. I would typically think of using it to work with branch names,
|
||||||
|
tags, and other kinds of refs.
|
||||||
|
|
||||||
|
There is a handy, sorta off-label use for it in determining the absolute path of
|
||||||
|
the root directory for the current git repository. Use the `--show-toplevel`
|
||||||
|
flag with no other arguments.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
❯ git rev-parse --show-toplevel
|
||||||
|
/Users/lastword/dev/jbranchaud/til
|
||||||
|
```
|
||||||
|
|
||||||
|
Here, I am in the local copy of [my TIL repo](https://github.com/jbranchaud/til). This command gives me the absolute
|
||||||
|
path of the top-level directory where that `.git` directory resides.
|
||||||
|
|
||||||
|
This is useful for scripts that need to orient themselves to the current
|
||||||
|
project's top-level directory regardless of what directory they are being
|
||||||
|
executed from. This is useful for things like a git hook script or monorepos
|
||||||
|
with scripts located in a specific sub-project directory.
|
||||||
|
|
||||||
|
Also worth mentioning is the `--show-superproject-working-tree` flag. In my TIL
|
||||||
|
repo, I have a private repository included as a submodule. Within that directory
|
||||||
|
`--show-toplevel` will produce the absolute path to the submodule. If I instead
|
||||||
|
want the absolute path of the _super project_ (in this case TIL), then I can use
|
||||||
|
this other flag.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
❯ git rev-parse --show-toplevel
|
||||||
|
/Users/lastword/dev/jbranchaud/til/notes
|
||||||
|
|
||||||
|
❯ git rev-parse --show-superproject-working-tree
|
||||||
|
/Users/lastword/dev/jbranchaud/til
|
||||||
|
```
|
||||||
|
|
||||||
|
See `man git-rev-parse` for more details.
|
||||||
32
heroku/check-ruby-version-for-production-app.md
Normal file
32
heroku/check-ruby-version-for-production-app.md
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# Check Ruby Version For Production App
|
||||||
|
|
||||||
|
While deploying a fresh Rails app to Heroku recently, I ran into an issue. The
|
||||||
|
`it` block argument wasn't working despite being on Ruby 4.0. Or so I thought.
|
||||||
|
|
||||||
|
Running the following command reported the Ruby version of that Heroku server
|
||||||
|
instance:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
❯ heroku run -- ruby --version
|
||||||
|
Running ruby --version on ⬢ my-app... up, run.3090
|
||||||
|
ruby 3.3.9 (2025-07-24 revision f5c772fc7c) [x86_64-linux]
|
||||||
|
```
|
||||||
|
|
||||||
|
I was on `3.3.9` which must have been the fallback default at the time.
|
||||||
|
|
||||||
|
Though I had set the Ruby version in my `.ruby-version` file, I had neglected to
|
||||||
|
specify it in the `Gemfile` as well. Once I added it to the `Gemfile` and
|
||||||
|
redeployed, my Heroku server instance was running the expected version of Ruby.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
❯ heroku run -- ruby --version
|
||||||
|
Running ruby --version on ⬢ my-app... up, run.5353
|
||||||
|
ruby 4.0.0 (2025-12-25 revision 553f1675f3) +PRISM [x86_64-linux]
|
||||||
|
```
|
||||||
|
|
||||||
|
Note: because [I have set `HEROKU_ORGANIZATION` and
|
||||||
|
`HEROKU_APP`](set-default-team-and-app-for-project.md) in my environment
|
||||||
|
(`.envrc`) for the local copy of the app, I don't need to specify those when
|
||||||
|
running the `heroku run` command above.
|
||||||
|
|
||||||
|
See `heroku run --help` for more details.
|
||||||
27
mise/look-in-ruby-version-dotfile.md
Normal file
27
mise/look-in-ruby-version-dotfile.md
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# Look In Ruby Version Dotfile
|
||||||
|
|
||||||
|
Newer versions of [`mise`](https://mise.jdx.dev/dev-tools/) specifically only
|
||||||
|
look for tool versions in `mise.toml` as well as the asdf `.tool-versions` file.
|
||||||
|
A lot of Ruby projects use the `.ruby-version` file to indicate the Ruby version
|
||||||
|
of a project. To continue to use the `.ruby-version` file instead of migrating
|
||||||
|
to `mise.toml`, you need to tell `mise` that you prefer to use the idiomatic
|
||||||
|
version file.
|
||||||
|
|
||||||
|
I added the following line to my
|
||||||
|
[`~/.config/mise/config.toml`](https://github.com/jbranchaud/dotfiles/commit/8edeb7a9c53500e89e88b4079cbd1859ebebcbda)
|
||||||
|
file:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
idiomatic_version_file_enable_tools = ["ruby"]
|
||||||
|
```
|
||||||
|
|
||||||
|
Now, whenever `mise` is looking for the specified Ruby version of a project, it
|
||||||
|
will also look for `.ruby-version`.
|
||||||
|
|
||||||
|
Here is a [full list of idomatic version files supported by
|
||||||
|
`mise`](https://mise.jdx.dev/configuration.html#idiomatic-version-files).
|
||||||
|
|
||||||
|
See
|
||||||
|
[`idiomatic_version_file_enable_tools`](https://mise.jdx.dev/configuration/settings.html#idiomatic_version_file_enable_tools)
|
||||||
|
as well as the [Ruby-specific documentation](https://mise.jdx.dev/lang/ruby.html#ruby-version-and-gemfile-support)
|
||||||
|
for more details.
|
||||||
27
unix/display-line-numbers-while-using-less.md
Normal file
27
unix/display-line-numbers-while-using-less.md
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# Display Line Numbers While Using Less
|
||||||
|
|
||||||
|
Including line numbers while viewing files with `less` can provide useful
|
||||||
|
context for understanding where you are within the file. This is especially true
|
||||||
|
if you've used `&` to filter down to lines that match a pattern.
|
||||||
|
|
||||||
|
You can start `less` with line numbers with the `-N` flag (or `--LINE-NUMBERS`
|
||||||
|
if you really want to spell it out).
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ less -N log/development.log
|
||||||
|
```
|
||||||
|
|
||||||
|
If you've already started up `less` and wish you had included line numbers,
|
||||||
|
there is no reason to restart it with the flag. Instead, toggle the line numbers
|
||||||
|
option on within the `less` process. To do this, type `-N`. It will prompt you
|
||||||
|
with `Constantly display line numbers (press RETURN)`. Hit enter and line
|
||||||
|
numbers will appear to the left of each line in the file.
|
||||||
|
|
||||||
|
Similarly, to toggle line numbers back off within `less`, hit `-n` (lower-case
|
||||||
|
`n`), accept the prompt, and back off they go.
|
||||||
|
|
||||||
|
Both of these (`-N`/`-n`) are options being set (toggled) via the `-` command.
|
||||||
|
There are many other options like these that can be configured within a `less`
|
||||||
|
session in the same way.
|
||||||
|
|
||||||
|
See `man less` and find the `-` command and the available `OPTIONS`.
|
||||||
Reference in New Issue
Block a user