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

Compare commits

...

3 Commits

Author SHA1 Message Date
nick-w-nick
0ae77d28f2 Merge 295fe153ad into 8a682e3a89 2024-11-07 10:49:11 -05:00
jbranchaud
8a682e3a89 Add Open New Splits To The Current Directory as a tmux TIL 2024-11-07 09:43:46 -06:00
nick-w-nick
295fe153ad added mention of ES6 compatibility
Hello, I've added a small blockquote below the description to indicate that this method of accessing an indefinite number of function arguments has been superseded by the use of the spread operator via rest parameters for ES6+ compatibility.
2022-01-06 11:39:04 -05:00
3 changed files with 41 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).
_1499 TILs and counting..._
_1500 TILs and counting..._
---
@@ -1354,6 +1354,7 @@ _1499 TILs and counting..._
- [Kill The Current Session](tmux/kill-the-current-session.md)
- [List All Key Bindings](tmux/list-all-key-bindings.md)
- [List Sessions](tmux/list-sessions.md)
- [Open New Splits To The Current Directory](tmux/open-new-splits-to-the-current-directory.md)
- [Open New Window With A Specific Directory](tmux/open-new-window-with-a-specific-directory.md)
- [Organizing Windows](tmux/organizing-windows.md)
- [Paging Up And Down](tmux/paging-up-and-down.md)

View File

@@ -5,6 +5,8 @@ an array-like object with all of the arguments to the function. Even if not
all of the arguments are referenced in the function signature, they can
still be accessed via the `arguments` object.
> For ES6+ compatibility, the `spread` operator used via [rest parameters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters) is preferred over the `arugments` object when accessing an abritrary number of function arguments.
```javascript
function argTest(one) {
console.log(one);

View File

@@ -0,0 +1,37 @@
# Open New Splits To The Current Directory
I typically work in one project per tmux session. When I create a given tmux
session, the default directory is for that project. All new windows and pane
splits will open at that default directory. This generally is the default
behavior I want.
One caveat: I often open a new window within an existing session that I want
anchored to another directory. This could be because I'm working in a monorepo
and I need to work from a subdirectory for a specific package or app. Or it
could be that I'm temporarily digging into another project and it isn't worth
create a whole new session.
Regardless of the reason, I run into a bit of friction with tmux's defaults.
First I open the new window and `cd` to another project. After some working, I
need to open a split pane, maybe to run a project command like a build or dev
server. Hitting `prefix-"` (horizontal split) or `prefix-%` (vertical split)
opens a pane with the shell defaulting back to the original directory, not the
current directory.
The trick to fixing this bit of friction is overriding the directory of pane
splits. I can do that by adding the following to my `~/.tmux.conf`:
```
# Pane splits should open to the same path as the current pane
bind '"' split-window -v -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
```
Make sure to run `tmux source-file ~/.tmux.conf` to apply these config changes.
The `pane_current_path` is called a "Format" in tmux parlance. It resolves to
the absolute path of the current pane's current directory. You can find all the
formats in the manpage with this command: `man tmux | less +'/^FORMATS'`. You
can also show yourself that this format resolves to what you expect by running
`tmux display-message -p '#{pane_current_path}'`.