nushell: Sending keys on tmux does not work as expected
Question
I have this custom bash scripts to create tmux sessions and they always work with bash or fish but not with nushell.
#!/usr/bin/env sh
SESSION_TYPE=$1
if [ -z "$SESSION_TYPE" ]; then
echo "No session type provided"
exit 1
fi
WORK_PATH="$HOME/clones/$SESSION_TYPE"
# Selecting a repository to work on
SELECTED_REPO=$(ls "$WORK_PATH" | fzy)
REPO=$(echo $SELECTED_REPO | sed 's/\//-/g' | sed 's/\./-dot-/g')
SESSION="$SESSION_TYPE-$REPO"
REPO_NAME="$WORK_PATH/$SELECTED_REPO/"
# Generating the session name using the repository
SHELL=nu
EDITOR=nvim
# CUSTOM_COMMAND=""
if ! tmux has-session -t "$SESSION" 2>/dev/null; then
echo "Creating new session..."
tmux new-session -d -s "$SESSION"
tmux new-window -n $EDITOR
tmux send-keys "$SHELL" C-m
tmux send-keys "cd $REPO_NAME" C-m
# tmux send-keys "$CUSTOM_COMMAND" C-m
tmux send-keys "$EDITOR" C-m
tmux send-keys C-l
tmux split-window -v
tmux select-pane -t 1
tmux send-keys "$SHELL" C-m
tmux send-keys "cd $REPO_NAME" C-m
# tmux send-keys "$CUSTOM_COMMAND" C-m
tmux send-keys C-l
tmux resize-pane -D 80
else
echo "Session already exists"
fi
tmux -2 attach-session -t "$SESSION"
The C-m key are not send and when opening the session I get the following:
It shoul cd to the dir and open nvim, but it just gets the two lines together.
Do you know why this happens? The scripts runs inside bash so it is strange. Should I create a nushell equivalent script?
About this issue
- Original URL
- State: open
- Created 10 months ago
- Comments: 16 (1 by maintainers)
Thanks @fdncred for trying to help.
I’m not sure what to tell you. This example isn’t easily reproducible so it’ll take someone who knows tmux and nushell to figure it out.
I guess you’ll need to find someone that uses tmux for further help. You can drop by our Discord I’m sure there are a few in there.