joshmedeski / sesh

Smart session manager for the terminal
MIT License
417 stars 17 forks source link

Fix script in the readme #70

Closed PbVrCt closed 4 months ago

PbVrCt commented 4 months ago

I had some problems getting this script to work:

 bind-key "T" run-shell "sesh connect $(
    sesh list -tz | fzf-tmux -p 55%,60% \
        --no-sort --border-label ' sesh ' --prompt '⚡  ' \
        --header '  ^a all ^t tmux ^x zoxide ^f find' \
        --bind 'tab:down,btab:up' \
        --bind 'ctrl-a:change-prompt(⚡  )+reload(sesh list)' \
        --bind 'ctrl-t:change-prompt(🪟  )+reload(sesh list -t)' \
        --bind 'ctrl-x:change-prompt(📁  )+reload(sesh list -z)' \
        --bind 'ctrl-f:change-prompt(🔎  )+reload(fd -H -d 2 -t d -E .Trash . ~)'
)"

Here's how I fixed them:

After applying those changes I got this working:

tmux.conf

bind "T" run-shell "~/.config/scripts/tmux/sessionizer.sh"

sessionizer.sh:

#!/bin/bash
export PATH="$HOME/.cargo/bin:$PATH"
$HOME/go/bin/sesh connect $(
    $HOME/go/bin/sesh list -tz | fzf-tmux -p 55%,60% \
        --no-sort --prompt '⚡  ' \
        --header '  ^a all ^t tmux ^x zoxide ^f find' \
        --bind 'tab:down,btab:up' \
        --bind 'ctrl-a:change-prompt(⚡  )+reload($HOME/go/bin/sesh list)' \
         --bind 'ctrl-t:change-prompt(🪟 )+reload($HOME/go/bin/sesh list -t)' \
        --bind 'ctrl-x:change-prompt(📁  )+reload($HOME/go/bin/sesh list -z)' \
         --bind 'ctrl-f:change-prompt(🔎 )+reload(fdfind -H -d 2 -t d -E .Trash . ~)'
)

Thank you for making this software. Looking forward to its final version.

Version

❯ sesh --version sesh version dev

Relevant log output

No response

Reviewed

joshmedeski commented 4 months ago

Hey @PbVrCt, thanks for the feedback.

  1. The --border-label 'sesh' is related to using an older version of fzf, if you upgrade to the latest version that feature will work
  2. I highly recommend adding $HOME/go/bin to your path, not a requirement but makes it easier when interacting with sesh in general.
  3. fd is just an example. You can create any find command that works for you as a fallback if you don't have a record stored in zoxide yet and want to start a new session from the fzf tmux popup.

I hope that helps, I'm not going to update the README but if someone else runs into these issues hopefully this feedback will help.

PbVrCt commented 4 months ago

Hi @joshmedeski, yes it helps, thank you.

Regarding 2. , I have $HOME/go/bin in path, but tmux is not getting the same paths as my default shell.

Anyways, the problem is solved. Thanks!

qrockz commented 3 months ago

@joshmedeski @PbVrCt where did you store fzf-tmux so that you can access it gobally? Did you create a sym link to tmux/plugins/tmux-fzf/scripts/.fzf-tmux or an alias in .bashrc which points to .fzf-tmux or did you copy .fzf-tmux to /usr/local/bin/fzf-tmux ?

I'm just curios because this script:

bind-key "T" run-shell "sesh connect \"$(
    sesh list -tz | fzf-tmux -p 55%,60% \
        --no-sort --border-label ' sesh ' --prompt '⚡  ' \
        --header '  ^a all ^t tmux ^x zoxide ^d tmux kill ^f find' \
        --bind 'tab:down,btab:up' \
        --bind 'ctrl-a:change-prompt(⚡  )+reload(sesh list)' \
        --bind 'ctrl-t:change-prompt(🪟  )+reload(sesh list -t)' \
        --bind 'ctrl-x:change-prompt(📁  )+reload(sesh list -z)' \
        --bind 'ctrl-f:change-prompt(🔎  )+reload(fd -H -d 2 -t d -E .Trash . ~)' \
        --bind 'ctrl-d:execute(tmux kill-session -t {})+change-prompt(⚡  )+reload(sesh list)'
)\""

does requiere fzf-tmux to be globally accessible and I want to know a smart way to do so :D

PbVrCt commented 3 months ago

@joshmedeski @PbVrCt where did you store fzf-tmux so that you can access it gobally? Did you create a sym link to tmux/plugins/tmux-fzf/scripts/.fzf-tmux or an alias in .bashrc which points to .fzf-tmux or did you copy .fzf-tmux to /usr/local/bin/fzf-tmux ?

I'm just curios because this script:

bind-key "T" run-shell "sesh connect \"$(
  sesh list -tz | fzf-tmux -p 55%,60% \
      --no-sort --border-label ' sesh ' --prompt '⚡  ' \
      --header '  ^a all ^t tmux ^x zoxide ^d tmux kill ^f find' \
      --bind 'tab:down,btab:up' \
      --bind 'ctrl-a:change-prompt(⚡  )+reload(sesh list)' \
      --bind 'ctrl-t:change-prompt(🪟  )+reload(sesh list -t)' \
      --bind 'ctrl-x:change-prompt(📁  )+reload(sesh list -z)' \
      --bind 'ctrl-f:change-prompt(🔎  )+reload(fd -H -d 2 -t d -E .Trash . ~)' \
      --bind 'ctrl-d:execute(tmux kill-session -t {})+change-prompt(⚡  )+reload(sesh list)'
)\""

does requiere fzf-tmux to be globally accessible and I want to know a smart way to do so :D

@qrockz I did not do none of those 3 options. The only thing I did with fzf-tmux is install it with the tmux plugin manager. Revelant part of my tmux.conf :

set -g @tpm_plugins '             \
  tmux-plugins/tpm               \
  tmux-plugins/tmux-sensible     \
  tmux-plugins/tmux-resurrect    \
  tmux-plugins/tmux-continuum    \
  sainnhe/tmux-fzf               \
'

set -g @resurrect-save 'C-s'
set -g @resurrect-restore 'C-r'
set -g @resurrect-strategy-nvim 'session'
set -g @continuum-restore 'on'
set -g @continuum-save-interval '1'

set-environment -g TMUX_PLUGIN_MANAGER_PATH '~/.tmux/plugins/'
# Keep this line at the very bottom
run '~/.tmux/plugins/tpm/tpm'
joshmedeski commented 3 months ago

fzf-tmux was installed to /opt/homebrew/opt/fzf/bin/fzf-tmux when I setup fzf on my mac. See fzf to see how it needs to be installed on your OS.

qrockz commented 3 months ago

Yeah, I think I've downloaded only the fzf binary and did not have used the package installer. With the package installer, in my case apt, there comes extra stuff like fzf-tmux.

Thx guys.