1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-18 06:28:02 +00:00

Compare commits

..

3 Commits

Author SHA1 Message Date
nick-w-nick
b00b0201ed Merge 295fe153ad into e0db60f6ce 2024-11-27 11:34:14 -05:00
jbranchaud
e0db60f6ce Add Colocate jj And git Directories For Project as a jj TIL 2024-11-27 08:41:23 -06:00
jbranchaud
5c81ddc151 Add Type Fewer Paths With Brace Expansion as a Unix TIL 2024-11-26 17:55:12 -06:00
3 changed files with 115 additions and 1 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).
_1517 TILs and counting..._
_1519 TILs and counting..._
---
@@ -41,6 +41,7 @@ _1517 TILs and counting..._
* [Internet](#internet)
* [Java](#java)
* [JavaScript](#javascript)
* [jj](#jj)
* [jq](#jq)
* [Kitty](#kitty)
* [Linux](#linux)
@@ -569,6 +570,10 @@ _1517 TILs and counting..._
- [Yarn Commands Without The Emojis](javascript/yarn-commands-without-the-emojis.md)
- [Yup Schemas Are Validated Asynchronously](javascript/yup-schemas-are-validated-asynchronously.md)
### jj
- [Colocate jj And git Directories For Project](jj/colocate-jj-and-git-directories-for-project.md)
### jq
- [Combine An Array Of Objects Into A Single Object](jq/combine-an-array-of-objects-into-a-single-object.md)
@@ -1540,6 +1545,7 @@ _1517 TILs and counting..._
- [Switch Versions of a Brew Formula](unix/switch-versions-of-a-brew-formula.md)
- [Tell direnv To Load The Env File](unix/tell-direnv-to-load-the-env-file.md)
- [Touch Access And Modify Times Individually](unix/touch-access-and-modify-times-individually.md)
- [Type Fewer Paths With Brace Expansion](unix/type-fewer-paths-with-brace-expansion.md)
- [Undo Changes Made To Current Terminal Prompt](unix/undo-changes-made-to-current-terminal-prompt.md)
- [Undo Some Command Line Editing](unix/undo-some-command-line-editing.md)
- [Unrestrict Where ripgrep Searches](unix/unrestrict-where-ripgrep-searches.md)

View File

@@ -0,0 +1,59 @@
# Colocate jj And git Directories For Project
When doing a standard clone of a git repository with `jj`, you'll get a copy of
the project with a `.jj` directory containing the version control information.
```bash
$ jj git clone git@github.com:jbranchaud/my-repo
Fetching into new repo in "/path/of/local/repo"
...
$ exa --tree --all -L 1
.
├── .gitignore
├── .jj
├── Cargo.lock
├── Cargo.toml
└── src
```
This is fine if I'm completely familiar with using
[jujutsu](https://martinvonz.github.io/jj/latest/). However, if I'm coming from
`git` and still learning, then it would be nice to be able to fallback to
familiar `git` commands when needed.
But without a `.git` directory, I get this:
```bash
$ git log
fatal: not a git repository (or any of the parent directories): .git
```
When cloning a git repo with `jj`, I can instruct it to _colocate_ which means
that it will create both the `.jj` and the `.git` data directories in the
project.
```bash
$ jj git clone --colocate git@github.com:jbranchaud/my-repo
Fetching into new repo in "/path/of/local/repo"
...
$ exa --tree --all -L 1
.
├── .git
├── .gitignore
├── .jj
├── Cargo.lock
├── Cargo.toml
└── src
```
Now I can run `jj` commands or `git` commands:
```bash
$ git log
commit 0c72abbb83657096677f9a3d5ddc7bce20839165 (HEAD, origin/trunk, trunk)
...
```
[source](https://martinvonz.github.io/jj/latest/git-compatibility/#co-located-jujutsugit-repos)

View File

@@ -0,0 +1,49 @@
# Type Fewer Paths With Brace Expansion
Bash has a feature called _brace expansion_ that allows us to do a kind of
shorthand when writing out file paths. We can specify multiple variants
comma-separated between curly braces and they'll each be expanded into separate
arguments.
It's easier to understand this by seeing it. If we type the following (don't
hit `Enter` yet):
```bash
$ mkdir src/{one,two,three}
```
And then hit _Tab_:
```bash
$ mkdir src/one src/two src/three
```
Bash uses the portion in braces to expand into separate arguments. The part
outside the braces gets reused for each. That's where we get some savings from
typing out the same path each time.
Here is another example where we use `mv` to rename a file deeply nested in our
project:
```bash
$ mv projects/project1/src/app/utils/{names,constants}.js
```
We don't even have to _Tab_ it out. We can hit _Enter_ directly and `mv` gets
both arguments.
Similarly, how about we change the extension of our renamed file:
```bash
$ mv projects/project1/src/app/utils/constants.{js,ts}
```
I've always found this feature most useful with paths and filenames, but you
can do brace expansion with any arguments.
```bash
$ echo 1{3,1,6,4,9,2,7,5}
13 11 16 14 19 12 17 15
```
[source](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html)