Skip to content

Instantly share code, notes, and snippets.

View CallumHoward's full-sized avatar
💻

Callum Howard CallumHoward

💻
  • SafetyCulture
  • Australia
View GitHub Profile
@CallumHoward
CallumHoward / try_vim.md
Last active January 24, 2018 19:42
Try Vim! - Callum Howard (2016)

image

As a programmer, your text editor is your weapon. With keyboard as conduit you manipulate what you see on screen to realise your thoughts. By honing your skill at wielding a text editor, writing code can become a more fluent process, allowing your thoughts to flow uninterrupted.

The paradigm of modal text editing with Vim is being able to edit at the speed of thought. By using compose-able hotkeys and different modes Vim allows you to move your cursor and achieve your immediate editing task in just a few keystrokes. Commanding Vim is like speaking a language. By chaining different key combos together, you can instruct Vim to manipulate the text in any way you intend - and all without using the mouse.

You may not think it, but using the mouse to edit text is awfully slow. You can think of it as an O(log n) algorithm - you move your mouse in the direction you want, and poll: "are you at the target yet?". This repeats, closing the distance each time, until finally you

@dbohdan
dbohdan / Zsh: change directory using ranger
Created August 17, 2013 16:15
Adopted from the "Bash: cd to last path after exit" example in the man page for ranger(1).
ranger-cd() {
tempfile=$(mktemp)
ranger --choosedir="$tempfile" "${@:-$(pwd)}" < $TTY
test -f "$tempfile" &&
if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then
cd -- "$(cat "$tempfile")"
fi
rm -f -- "$tempfile"
}

TMUX - Single window group, multiple session.

So I have been using tmux for a while and have grown to like it and have since added many many customizations to it. Now once you start getting the hang of it, you'll naturally want to do more with the tool.

Now tmux has a concept of window-group and session and if you are like me you'll want multiple session that connects to the same window group instead of a new window group every time. Basically I just need different views into the same set of windows that I have already created, I don't want to create a new set of windows every time I fire up my terminal.

This is the default case if you simply use the tmux command as your login shell, effectively creating a new group of windows every time you start tmux.

This is less than ideal because, if you are like me, you fire up one-off terminals all the time and you don't want all those one-off jobs to stay running in the background. Plus sometimes you need information fro