Posts tagged: cli

All posts with the tag "cli"

pipx examples

count lines of code ¶ # pipx run pygount markata pipx run pygount markata --format=summary pipx run pygount markata --suffix=cfg,py,yml

tmux targeted session

https://youtu.be/5KE7Il7SOEk

This is something that I made up but use every single day, this is what keeps much of what is on my blog or my teams private work wiki going. I have a few very important directories that I have assigned directly to a hotkey for fast session switching.

bind -n M-i new-session -A -s waylonwalker_com "cd ~/git/waylonwalker.com/ && nvim" bind i popup -E -h 95% -w 95% -x 100% "tmux new-session -A -s waylonwalker_com 'cd ~/git/waylonwalker.com/ && nvim'" bind -n M-I popup -E "tmux new-session -A -s waylonwalker_com 'cd ~/git/waylonwalker.com/ && nvim'"

tmux new-session

...

tmux detach

https://youtu.be/A1qx3tNKDdA

tmux detach is a handy tmux command that will quit your current session while keeping it running. The full name of the comamnd is detach-client, detach is a shorthand.

default keybinding

...

notify-send

xinput float $(xinput list --id-only "AT Translated Set 2 keyboard") | notify-send "laptop keeb floated" -i ~/Pictures/8bitcc.png

tmux attach

https://youtu.be/JQ0yDCVu44E

attach is one of the most useful features of tmux. If you have no interest in tmux for pane and window management, you should use tmux for this. It can be a life saver if you ever get disconnected from the host machine or accidently close your terminal you can connect right back into the session you were just in using attach.

tmux attach

this command will simply attach back to tmux if you are ever disconnected

...

tmux command line

https://youtu.be/SNu-4IrkjAs

So far we have covered a lot of tmux commands and how they map to keybindings but these same commands can be executed at the command line.

Let’s make a popup that displays our git status for 5s or until we close it manually. We can run the following command at the command line, in a split.

...

tmux copy-mode

https://youtu.be/-ypY_-VmBKk

tmux copy-mode is a tmux mode that lets you scroll, search, copy, and jump your way through a pane. There are a ton of keybindings for copy-mode, the main ones you will need to know are / for searching down ? for searching up, n for next item, space for starting a selection, and enter to copy the selection. Arrow keys will be used for navigation unless you have specified vi mode, then it will be hjkl.

Default keybinding to get into copy mode is prefix+[.

...

tmux join-pane

https://youtu.be/Vm5rRtcVXLw

Join-pane allows you to join panes that you have broken away from your window, or created in a different window to the window you want it in. As far as I know there is not a default keybinding for it.

Before you can join a pane you must first have a pane marked to join. Once you mark a pane, go back to the window you want to join it to and join-pane.

...

tmux break-pane

https://youtu.be/ICL609F2xnc

Break-pane is a handy tmux command when your layout gets too cramped and you want to just move a split into its own window. Calling break-pane does exactly that, it creates a new-window for you and moves your currently selected split into that window

Default key binding for break-pane

...

tmux zoom

https://youtu.be/Rn6mOarCQ-Y

Zooming into the current split in tmux is a valuable tool to give yourself some screen real estate. These days I am almost always presenting, streaming, or pairing up with a co-worker over a video call. Since I am always sharing my screen I am generally zoomed in to a level that is just a bit uncomfortable, so anytime I make a split it is really uncomfortable, being able to zoom into the split I am focused on is a big help, and also help anyone watching follow where I am currently working.

Default key bindings for zooming the current split

...

tmux new-window

https://youtu.be/YRPZBv-iYyE

New window as it sounds makes new windows in tmux. Windows are kind of like tabs. They are another screen within your sessions that you can name and make new panes in.

Default key bindings for creating and navigating windows in tmux.

...

tmux slect-pane

https://youtu.be/CPZJZjN9YTY

These are my MOST often used keybindings that I use in tmux. They allow me to jump between splits with ease with a vim style layout. I can hold mod and jump between panes with a familiar arrow key.

bind -n M-h select-pane -L bind -n M-l select-pane -R bind -n M-k select-pane -U bind -n M-j select-pane -D

How I navigate tmux in 2021

...

tmux select-layout

https://youtu.be/F0mHnwTrNNc

When you get many splits going in tmux sometimes its time for a new layout. There are four layout strategies that I use, main-vertical, main-horizontal, even-vertical, even-horizontal. Almost always I am useing the main ones with mod plus a or mod plus shift a keybindings.

# Select Layouts #――――――――――――――――― bind -n M-a select-layout main-vertical bind -n M-A select-layout main-horizontal bind -n M-E select-layout even-vertical bind -n M-V select-layout even-horizontal

How I navigate tmux in 2021

...

tmux resize-panes

https://youtu.be/hpFYE2LU7xc

Resizing panes in tmux can be quite difficult in default tmux, I use a set of keybingings to help resize panes in the rare occasions that I do need just a bit more space. I set the keybinding to the same as my split navigation bindings but shifted. They are very vim like (h,j,k,l).

# resize panes #――――――――――――――――――――――――――――― bind -n M-H resize-pane -L 2 bind -n M-L resize-pane -R 2 bind -n M-K resize-pane -U 2 bind -n M-J resize-pane -D 2

Most often when I need to resize panes I just grab the edge of the pane with my mouse. Yes the mouse, its not that often that I actually need to change the size of a pane.

...

tmux choose-tree

https://youtu.be/79Y-kqAiMpw

Choose tree is a powerful tmux utility that provides a graphical interface to preview all sessions, windows, and panes, move between them kill them, move them and much more.

The default keybinding

...

tmux prefix

https://youtu.be/BMkpbfhbkKM

The prefix key is an essential part of tmux, by default all of tmux’s key-bindings sit behind a prefix. This prefix is very similar to vim’s leader key. It is common for folks to change the default C-b (control b) to C-a or if they are a vim user something to match their vim leader key.

set -g prefix C-Space bind Space send-prefix

A few of the essential default key-bindings.

...