How to run a command inside tmux

i am on alacritty.
i want to run tmux
while it is on i want to run echo hi
i tried tmux -c 'echo hi
but it just returns hi (just like echo hi)
it doesn't open tmux session.

❯ tmux -c 'echo hi'
hi
❯     

And you are already doing what you described, the command run inside tmux and then the tmux session is closed as soon as the command ends.

2 Likes

so if i run 'nnn' or something which doesn't end on it's own i should be able to see that on tmux interface. which i don't. it's like i didn't even types 'tmux -c'
i want to see my command output in the tmux interface.

Are you sure this is the right command?

-c shell-command
Execute shell-command using the default shell. If
necessary, the tmux server will be started to
retrieve the default-shell option. This option is
for compatibility with sh(1) when tmux is used as a
login shell.

How about this?

tmux new -s foo 'echo intmux; $SHELL'

Source: bash - How to run tmux with shell command - Stack Overflow

2 Likes

Why are you using -c?

Unless I'm missing something, tmux is normally used interactively to provide multiple windows within a single terminal session.

I use tmux all day long and don't close it.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.