How do I load a particular line in a TMUX session? - tmux

The scrolling is soo slow in TMUX 2.7+. I have a TMUX session with a window that has 5,000 lines of code and I'd like to access a command that I sent around line 2,000. It would take forever to load it up.
I've tried going into command mode and putting in the number.
How do I access a specific line in a tmux session?

The goto-line command lets you jump directly to given line. If you use vi mode, it's :2000. If you use emacs mode, it's g2000.

Related

Is there any way to detect exiting a session on tmux?

I was wondering if there is a way to detect when I exit a tmux session.
It is common that I have multiple sessions in my workflow and I manage them with tmux-fzf plugin. Everything is good but there are some times when I am done with a session and want to exit it. after exiting, it would completely exit tmux and put me where I ran tmux command in the first place, and if I want to reattach to my sessions, I have to type tmux a. So ideally, I wanted to detect when I exit a session and in my tmux.conf file set a hook to check for existing tmux sessions and if there is attached to them instead of completely detaching from tmux.
Ok, I finally got it, by putting this line on the .tmux.conf file, Whenever a session is exited, the client will switch to the most recently active of the remaining sessions.
set -g detach-on-destroy off
As the explanation for this option on the tmux man page says :
If on (the default), the client is detached when the session it is attached to is destroyed. If off, the client is switched to the most recently active of the remaining sessions. If no-detached, the client is detached only if there are no detached sessions; if detached sessions exist, the client is switched to the most recently active.

How to stop retyping "ssh user#domain.com" over and over

My workflow always consists of opening a new terminal window, typing ssh user#domain.com (or scp) followed by cd remote/directory/of/project
The domain is long and hard to type, as well as it being a big file path so this takes me ~20 seconds every time. What's the canonical, efficient way to do this that you would see a senior dev doing?
For not retyping ssh user#domain.com that often, you can put it in you .ssh/config:
Host my_alias
HostName domain.com
User user
Afterwards, you can just type ssh my_alias.
For not retyping the path, you can
put the path in an alias in your .bashrc (alias cd_my_proj='cd remote/directory/of/project')
look it up in your bash history (usually with Ctrl+R)
use a soft link (ln -s remote/directory/of/project ~)
keep the path open in a tmux (or screen) session
You may also google these pointers for more details (like how to save tmux session and further details in your .ssh/config)
You can create a script file with the commands you want to execute so you can just execute it instead of manually typing your ssh/scp/cd commands every time you have to do so.

Minecraft console get wrong commands

I started a local server and want to add some simple commands with python, the server is running with forge 1.12 and a couple of mods.
My idea was it to catch wrong commands and send the right result instead.
An easy test command would be /echo Hello World with the result in the chat Hello World.
To get the command I am using the last line of the latest console log file, which is equal to the current console content. But in the console I cant read wrong commands. So if I run the echo command I get an message in the chat Unknown command. Try /help for a list of commands.
I think there could be two solutions:
Add in any register the command to get it in the console, prevent on this way the server to response and get the command in the console to use it.
Find a config to print also wrong commands in the console.
Thanks for helping
There is no way to 'cancel' commands through API, but there is a trick to effectively cancel commands anyways. You want to be listening to the Forge CommandEvent, modifying the command to another existing command that does nothing (you can create one yourself). This gives you a place to handle all commands (you'll have to filter for unexisting commands, otherwise you'd cancel all commands), and it will prevent the Unknown Command message from showing.

Stash a command in zsh with key command

I'm running using oh-my-zsh. I was writing a fairly long commit message on the command line, and I hit something on the keyboard that caused it to disappear. I pushed the up key, hoping it would remain in the history, but it was not there.
So, I grumbled, rewrote the commit message, and as soon as I executed that command, the command I was writing before populated the command line, ready for editing.
This seems like a handy feature occasionally, to stash a command to run something else first. How do I do this on purpose?
You probably typed Esc-q, which is bound by default to the push-line command documented in man zshzle:
push-line (^Q ESC-Q ESC-q) (unbound) (unbound)
Push the current buffer onto the buffer stack and clear the
buffer. Next time the editor starts up, the buffer will be
popped off the top of the buffer stack and loaded into the edit-
ing buffer.

How to start two or more tmux (or tmuxinator) sessions simultaneously?

I'm a huge fan of tmux + tmuxinator. Buy recently I found myself working with different sessions, and despite I configured'em with tmuxinator, I still need to open one at a time every day.
Is there a way to open two or more sessions at once so I can navigate between them as soon as I start tmux ot tmuxinator?
Check out this little mac os script I wrote:
#!/bin/bash
sessions=( session1 session2 )
for i in "${sessions[#]}"
do
osascript <<EOF
tell application "iTerm" to activate
tell application "System Events" to tell process "iTerm" to keystroke "t" using command down
tell application "System Events" to tell process "iTerm" to keystroke "tmuxinator start ${i}"
tell application "System Events" to tell process "iTerm" to key code 52
EOF
done

Resources