omerxx / tmux-sessionx

A Tmux session manager, with preview, fuzzy finding, and MORE
GNU General Public License v3.0
718 stars 63 forks source link

Rename does not work in fish shell #20

Closed kanwarujjaval closed 7 months ago

kanwarujjaval commented 9 months ago

The rename commands errors out with Variables cannot be bracketed.

The top also shows strings from somewhere and this is something that is also auto read by the rename command, ( does not take input)

Screenshot 2023-12-27 at 11 22 47 AM

My tmux conf

setw -g mouse on
# ctrl-a as prefix instead of ctrl-b
unbind C-b
set -g prefix C-a
# 'C-a C-a' sends C-a keypress to the current window
bind C-a send-prefix
set-window-option -g mode-keys vi
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'omerxx/tmux-sessionx'
set -g @plugin 'tmux-plugins/tmux-sensible'
#set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'egel/tmux-gruvbox'
set -g @tmux-gruvbox 'dark'
run '~/.tmux/plugins/tpm/tpm'
omerxx commented 9 months ago

Cool, need to think of a fish support method, is it only the rename?

kanwarujjaval commented 9 months ago

Its the rename for me, but also the default names are displayed incorrectly it seems (as in the screenshot)

omerxx commented 8 months ago

I can see why, I'm working with ZSH, maybe this requires some docs clarification, or, if you can find a better method for fish I'd be happy to integrate it

BigJayToDaIzo commented 8 months ago

I can see why, I'm working with ZSH, maybe this requires some docs clarification, or, if you can find a better method for fish I'd be happy to integrate it

Another fish shell user bummed out by a 'broken' rename functionality. The rest seems to work flawlessly for me so far. Thanks for a great product and ideally one of us open sourcers can figure out how to integrate 'full fish shell' support! I'm not a shell scripter by nature but I've been wanting to be more proficient customizing my box so I'll dive into the .sh to try to help.

EDIT: Adding my tmux.conf

# Set options
set-option -sa terminal-overrides ",xterm*:Tc"
set -g mouse on

# Set prefix
unbind C-b
set -g prefix C-Space
bind C-Space send-prefix
set -g detach-on-destroy off
set -g set-clipboard on
set -g status-position top

# Start windows and panes at 1, not 0
set -g base-index 1
set -g pane-base-index 1
set-window-option -g pane-base-index 1
set-option -g renumber-windows on

# Open panes in current directory
bind '"' split-window -v -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"

# set vi-mode
set-window-option -g mode-keys vi

# keybindings
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'dreamsofcode-io/catppuccin-tmux'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'omerxx/tmux-sessionx'

run '~/.config/tmux/plugins/tpm/tpm'

Did a little digging this morning. I welcome feedback from more knowledgeable fish scripters: When I try to rename a session the preview window flashes to dark. I believe this is fish attempting to load the read prompt and failing. A blank preview window loads with the following error: error

This line seems to be the only one with double quotes around the regex, but changing them to the single quotes doesn't help. The read prompt not appearing gave me the idea to try to run the following code from the RENAME_SESSION variable assignment in a shell:

printf >&2 "New name: ";read name; tmux rename-session -t {} ${name};

Fish fusses about the ${name} expansion telling me I need to put the $ inside the braces. However, doing this still results in the same failure as the image above. This greatly confused me as there are plenty of other places in the scripts that have the $ outside the braces, so I got to looking into plugins for fish to make it more bash script friendly. From this investigation I found a plugin I already have installed called Bass.
bass_plugin
I believe this is what's doing the heavy lifting for all the other working functionality, as well as why it's not trashing session names like it is for the OP but for some reason it's not playing nice with that one RENAME_SESSION variable assignment.

Worst case scenario would be to rewrite the scripts in fish-language and have the run process check $SHELL to determine which set of scripts to execute. Better is to encourage Fish users to use Bass and fix this isolated hiccup. Will update as I make progress.

Meliketoaste commented 7 months ago

I am 90 percent sure this is also an issue with nushell. Because i had issues with nushell not beeing able to rename as well. And changed default shell to zsh and now it works.