mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 07:08:01 +00:00
Compare commits
6 Commits
ff227a39ed
...
2d5abd9cbf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2d5abd9cbf | ||
|
|
2efaf27066 | ||
|
|
6b4b2c588c | ||
|
|
e473fa781d | ||
|
|
5ce5eccb0a | ||
|
|
db4961a8eb |
@@ -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).
|
||||
|
||||
_1666 TILs and counting..._
|
||||
_1668 TILs and counting..._
|
||||
|
||||
See some of the other learning resources I work on:
|
||||
|
||||
@@ -415,6 +415,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
||||
- [Stashing Untracked Files](git/stashing-untracked-files.md)
|
||||
- [Switch To A Recent Branch With FZF](git/switch-to-a-recent-branch-with-fzf.md)
|
||||
- [Transition A Branch From One Base To Another](git/transition-a-branch-from-one-base-to-another.md)
|
||||
- [Tell gh What The Default Repo Is](git/tell-gh-what-the-default-repo-is.md)
|
||||
- [Turn Off The Output Pager For One Command](git/turn-off-the-output-pager-for-one-command.md)
|
||||
- [Two Kinds Of Dotted Range Notation](git/two-kinds-of-dotted-range-notation.md)
|
||||
- [Unstage Changes Wih Git Restore](git/unstage-changes-with-git-restore.md)
|
||||
@@ -748,6 +749,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
||||
|
||||
- [Allow Neovim To Copy/Paste With System Clipboard](neovim/allow-neovim-to-copy-paste-with-system-clipboard.md)
|
||||
- [Create User Command To Open Init Config](neovim/create-user-command-to-open-init-config.md)
|
||||
- [Jump Between Changes In Current File](neovim/jump-between-changes-in-current-file.md)
|
||||
- [Run A Lua Statement From The Command Prompt](neovim/run-a-lua-statement-from-the-command-prompt.md)
|
||||
- [Run nvim With Factory Defaults](neovim/run-nvim-with-factory-defaults.md)
|
||||
- [Set Up Vim-Plug With Neovim](neovim/set-up-vim-plug-with-neovim.md)
|
||||
|
||||
40
Taskfile.yml
40
Taskfile.yml
@@ -11,6 +11,24 @@ tasks:
|
||||
cmds:
|
||||
- task --list
|
||||
|
||||
notes:
|
||||
desc: Interactive picker for notes tasks
|
||||
cmds:
|
||||
- |
|
||||
TASK=$(task --list | grep "^\* notes:" | sed 's/^\* notes://' | sed 's/\s\+/ - /' | fzf --prompt="Select notes task: " --height=40% --reverse) || true
|
||||
if [ -n "$TASK" ]; then
|
||||
TASK_NAME=$(echo "$TASK" | awk '{print $1}' | sed 's/:$//')
|
||||
task notes:$TASK_NAME
|
||||
fi
|
||||
interactive: true
|
||||
silent: true
|
||||
|
||||
notes:edit:
|
||||
desc: All-in-one edit, commit, and push notes
|
||||
cmds:
|
||||
- task notes:open
|
||||
- task notes:push
|
||||
|
||||
notes:sync:
|
||||
desc: Sync latest changes from the notes submodule
|
||||
cmds:
|
||||
@@ -18,8 +36,8 @@ tasks:
|
||||
- cd {{.NOTES_DIR}} && git checkout main
|
||||
silent: false
|
||||
|
||||
notes:edit:
|
||||
desc: Edit NOTES.md (syncs latest changes first)
|
||||
notes:open:
|
||||
desc: Opens NOTES.md (syncs latest changes first) in default editor
|
||||
deps: [notes:sync]
|
||||
cmds:
|
||||
- $EDITOR {{.NOTES_FILE}}
|
||||
@@ -40,12 +58,6 @@ tasks:
|
||||
cmds:
|
||||
- git status
|
||||
|
||||
notes:save:
|
||||
desc: Quick save - edit, commit, and push notes
|
||||
cmds:
|
||||
- task notes:edit
|
||||
- task notes:push
|
||||
|
||||
notes:pull:
|
||||
desc: Pull latest changes (alias for sync)
|
||||
cmds:
|
||||
@@ -62,15 +74,3 @@ tasks:
|
||||
dir: '{{.NOTES_DIR}}'
|
||||
cmds:
|
||||
- git log --oneline -10
|
||||
|
||||
notes:
|
||||
desc: Interactive picker for notes tasks
|
||||
cmds:
|
||||
- |
|
||||
TASK=$(task --list | grep "^\* notes:" | sed 's/^\* notes://' | sed 's/\s\+/ - /' | fzf --prompt="Select notes task: " --height=40% --reverse)
|
||||
if [ -n "$TASK" ]; then
|
||||
TASK_NAME=$(echo "$TASK" | awk '{print $1}' | sed 's/:$//')
|
||||
task notes:$TASK_NAME
|
||||
fi
|
||||
interactive: true
|
||||
silent: true
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"excludes": ["README.md"],
|
||||
"markdown": {
|
||||
"unorderedListMarker": "preserve"
|
||||
"textWrap": "never"
|
||||
},
|
||||
"plugins": ["https://plugins.dprint.dev/markdown-0.16.0.wasm"]
|
||||
}
|
||||
|
||||
38
git/tell-gh-what-the-default-repo-is.md
Normal file
38
git/tell-gh-what-the-default-repo-is.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# Tell gh What The Default Repo Is
|
||||
|
||||
I recently forked [dkarter/dotfiles](https://github.com/dkarter/dotfiles) as a
|
||||
way of bootstrapping a robust dotfile config for a new machine that I could
|
||||
start making customizations to. I'm maintaining a `my-dotfiles` branch and keep
|
||||
things in sync with the original upstream repo.
|
||||
|
||||
When trying to go to *my* fork of the repo
|
||||
([jbranchaud/dotfiles](https://github.com/jbranchaud/dotfiles)) in the web with
|
||||
the `gh` CLI tool, I ran into a weird issue. It was instead opening up to
|
||||
`dkarter/dotfiles`.
|
||||
|
||||
`gh` was under the wrong impression which repo should be considered the default.
|
||||
To clarify things for `gh`, there is a command to set the default repo.
|
||||
|
||||
```bash
|
||||
$ gh repo set-default jbranchaud/dotfiles
|
||||
✓ Set jbranchaud/dotfiles as the default repository for the current directory
|
||||
```
|
||||
|
||||
Now when I run `gh repo view --web`, it opens the browser to my fork of the
|
||||
dotfiles.
|
||||
|
||||
But where does this setting live?
|
||||
|
||||
Opening this repo's `.git/config` file I can see a section for the `origin`
|
||||
remote that includes a new line for `gh-resolved`. This being set to `base`
|
||||
tells `gh` that this remote is the one to treat as the default repo.
|
||||
|
||||
```
|
||||
[remote "origin"]
|
||||
url = git@github.com:jbranchaud/dotfiles.git
|
||||
fetch = +refs/heads/*:refs/remotes/origin/*
|
||||
gh-resolved = base
|
||||
|
||||
```
|
||||
|
||||
See `gh repo set-default --help` for more details.
|
||||
46
neovim/jump-between-changes-in-current-file.md
Normal file
46
neovim/jump-between-changes-in-current-file.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# Jump Between Changes In Current File
|
||||
|
||||
With the [gitsigns.nvim plugin](https://github.com/lewis6991/gitsigns.nvim) for
|
||||
Neovim, I get some handy Git-related capabilities like gutter highlighting of
|
||||
additions, deletions, and changes to lines in the current file. These contiguous
|
||||
sections of modification to the versioned state of a file are called hunks.
|
||||
|
||||
Here are two mappings (in Lua) for gitsigns that allow me to jump to the next
|
||||
(`]h`) or previous (`[h`) hunk in the current file.
|
||||
|
||||
```lua
|
||||
---@type LazyKeysSpec[]
|
||||
M.gitsigns_mappings = {
|
||||
|
||||
-- Navigation
|
||||
{
|
||||
']h',
|
||||
function()
|
||||
if vim.wo.diff then
|
||||
vim.cmd.normal { ']c', bang = true }
|
||||
else
|
||||
require('gitsigns').nav_hunk 'next'
|
||||
end
|
||||
end,
|
||||
desc = 'Next Hunk',
|
||||
},
|
||||
|
||||
{
|
||||
'[h',
|
||||
function()
|
||||
if vim.wo.diff then
|
||||
vim.cmd.normal { '[c', bang = true }
|
||||
else
|
||||
require('gitsigns').nav_hunk 'prev'
|
||||
end
|
||||
end,
|
||||
desc = 'Prev Hunk',
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
This is particularly useful when I've just opened a big file and I want to jump
|
||||
directly to active changes in that file.
|
||||
|
||||
I got this mapping directly from [Dorian's
|
||||
dotfiles](https://github.com/dkarter/dotfiles).
|
||||
Reference in New Issue
Block a user