Skip to content

Commit 0c3480c

Browse files
authored
feat: add preview command (#203)
- Add a new `sesh preview` command - Add configuration support for the preview command
1 parent 023e772 commit 0c3480c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+984
-38
lines changed

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ In order to integrate with tmux, you can add a binding to your tmux config (`tmu
111111

112112
```sh
113113
bind-key "T" run-shell "sesh connect \"$(
114-
sesh list --icons | fzf-tmux -p 55%,60% \
114+
sesh list --icons | fzf-tmux -p 80%,70% \
115115
--no-sort --ansi --border-label ' sesh ' --prompt '' \
116116
--header ' ^a all ^t tmux ^g configs ^x zoxide ^d tmux kill ^f find' \
117117
--bind 'tab:down,btab:up' \
@@ -121,6 +121,8 @@ bind-key "T" run-shell "sesh connect \"$(
121121
--bind 'ctrl-x:change-prompt(📁 )+reload(sesh list -z --icons)' \
122122
--bind 'ctrl-f:change-prompt(🔎 )+reload(fd -H -d 2 -t d -E .Trash . ~)' \
123123
--bind 'ctrl-d:execute(tmux kill-session -t {2..})+change-prompt(⚡ )+reload(sesh list --icons)' \
124+
--preview-window 'right:55%' \
125+
--preview 'sesh preview {}'
124126
)\""
125127
```
126128

@@ -222,9 +224,14 @@ mkdir -p ~/.config/sesh && touch ~/.config/sesh/sesh.toml
222224

223225
The default session can be configured to run a command when connecting to a session. This is useful for running a dev server or starting a tmux plugin.
224226

227+
Additionally, you can define a preview command that runs when previewing the session's directory. This can be handy for displaying files with tools like [eza](https://github.com/eza-community/eza) or [lsd](https://github.com/lsd-rs/lsd).
228+
229+
Note: The `{}` will be automatically replaced with the session's path.
230+
225231
```toml
226232
[default_session]
227233
startup_command = "nvim -c ':Telescope find_files'"
234+
preview_command = "eza --all --git --icons --color=always {}"
228235
```
229236

230237
If you want to disable the default start command on a specific session, you can set `disable_startup_command = true`.
@@ -235,7 +242,9 @@ A startup command is a command that is run when a session is created. It is usef
235242

236243
**Note:** If you use the `--command/-c` flag, then the startup script will not be run.
237244

238-
I like to use a command that opens nvim on session startup:
245+
I like to use a command that opens nvim on session startup.
246+
247+
You can also define a preview command to display the contents of a specific file using [bat](https://github.com/sharkdp/bat) or any another file previewer of your choice.
239248

240249
```toml
241250
[[session]]
@@ -247,6 +256,7 @@ startup_command = "ls"
247256
name = "tmux config"
248257
path = "~/c/dotfiles/.config/tmux"
249258
startup_command = "nvim tmux.conf"
259+
preview_command = "bat --color=always ~/c/dotfiles/.config/tmux/tmux.conf"
250260
```
251261

252262
### Listing Configurations

cloner/mock_Cloner.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configurator/mock_Configurator.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

connector/mock_Connector.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dir/mock_Dir.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

execwrap/mock_Exec.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

execwrap/mock_ExecCmd.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

git/mock_Git.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

home/mock_Home.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

icon/mock_Icon.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)