Developer Productivity
Introduction
My First “Big” Interview
- Explain the problem
讲了个故事,第一次重要面试,题目是在 1000 个文件中找出特定字符串,使用 java 写了 40 分钟,实际可以用
grep
完成~~ - The length of knowledge is a measurement of its value
- Explain the problem
What is developer Productivity?
- Definition: All the things that separate you from working
Ansible
The Problem Statement
- I have new computer(not a problem) and I want zsh installed(the problem)
1 | sudo apt install zsh |
1 | # The thing we forget to do |
Please don’t make fun of me. oh-my-zsh does give you a -1 BTW
1 | curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh |
Add autosuggest to the plugins
1 | plugins=(git zsh-autosuggestions) |
Ansible Overview
- The problem statement
- I have a new computer(it is the problem)
- Installing the things I need
ANSIBLE!!
Isn’t that a cloud configuration thing?? Something like Koobernetes
Let’s talk about the anatomy of ansible
Top level
1 | - hosts: localhost |
- Task
1 | - name: string |
Creating Ansible Tasks to Install zsh
- Let’s create the zsh install but with ansible
GUN Stow
1 | brew install stow |
YADM & Setup Tools Review
Terminals
Navigation & Window Management
- What is a window manager?
My theory on navigation
- i3 for ubuntu (very disorienting the first time)
1 | sudo apt install i3 |
Shell
The difference between shell and terminal
Terminal just take input and output the result
Shell is to prevent you doing something wrong break the terminal
OhMyZsh
How to install
1
curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
So what do I get out of oh-my-zsh?
Open up .zshrc and go to lines plugins
Personal Opinion
- Choose something
- Learn about it to some small amount
- Get good at core utils
- Take advantage of already built tools that are amazing.
Terminal & Multiplexing
What do I use?
- xterm
- tmux
Tmux
Install tmux
1 | brew install tmux |
Ctrl + d
write an EOF(end of file) to the stdin, which closes the shell
Basic tmux Commands
1 | tmux list-sessions |
1 | tmux a # or tmux attach |
Terminology
- Prefix Key
- The key combo you press(default
Ctrl + b
) - Draw it out
- The key combo you press(default
Creating sessions
1 | tmux kill-server |
1 | tmux list-sessions |
1 | tmux |
1 | tmux list-sessions |
1 | tmux # error, can't open new tmux server in a tmux server nested |
1 | tmux new-session -d # with parameter -d, can open a new session in a tmux session |
Navigation tip
- to the next session
<prefix> - (
- to the prev session
<prefix> - )
Close and create new session
1 | tmux kill-server |
Windows & Sessions Management with tmux
1 | ctrl + b d # detached session |
Navigation tip
- You can see all of the sessions and their windows by pressing
<prefix> + w
Create a bunch of windows
- That way we can really see what happened there. For you to do this on your own use detach in conjunction with
tmux new-session
command
Fun fact, Ctrl - d vs prefix - d
Ctrl + d
= EOFprefix + d
= tmux detach
So those are sessions
- It may be hard to see the difference between a session, a window, and a pane
Creating Windows
1 | tmux |
this is equivalent to <prefix> + c
Navigation tip
<prefix> + n
for next window<prefix> + p
for prev window<prefix> + #
for the # window
You can name sessions and windows
1 | tmux new-session -d -s "foo" |
1 | tmux new-window -n "foooo" |
Usability tip
- You can’t have sessions with the same tip
There are panes
- You can definitely look into panes to be able to split your view.
<prefix> + %
split window in half horizontalctrl + d
to close the pane
Directories with tmux
Taking tmux to the next level
We know some tmux commands
1 | tmux new-session -s 'foobar' -d |
BUT DID YOU KNOW?
1 | tmux new-session -s 'foobar' -d -c '$HOME/personal/develop' |
We can specify a command
1 | tmux new-window -n 'foobar' [some command goes here] |
1 | man tmux |
CLI Piping
Quick intro into CLI piping
1 | prog1 | prog2 | prog3 |
Bash
fzf
We have one more thing to learn
1 | brew install fzf |
create a new file name tmux-sessionizer
1 |
|
Create a tmux Navigation Bash Script
1 |
|
Improve the tmux Navigation Bash Script
Steaming hot Navigation Tip
<prefix> + L
go to previous session
But how do I make this easy to use?
- We can use zsh to bindkey
- We can use tmux to bindkey
- Make it available in your path
- call out from vim
We also need to store in a place that we don’t lose… Where could that be?
Cheat Sheet
Take it to the next level
Common problem we face as developers?
- What’s that splice interface to an array in JavaScript?
- How do I tokenize a string in C?
- How do I create a class in cpp?
- What’s the syntax for an enum in TypeScript?
1 | curl cht.sh/find~exec |
Learning
1 | curl cht.sh/golang/:learn |
Creating the Cheat Sheet Script
We have the knowledge this time, let’ build it
1 |
|
tmux Plugins & RC
How I link it up!
1 | bind-key -r i run-shell "tmux neww tmux-cht.sh" |
TmuxRC
Location will be $HOME/.tmux.conf
Tools
Tools: Git worktrees
So what is a work tree?
First, checking out maybe a bit different than you are use to. You are going to use the --bare
option when checking out.
1 | git clone --bare git@github.com:ThePrimeagen/refactoring.nvim.git refactoring.nvim |
Notice that I did name my checkout. When using --bare
I notice that it always includes the .git
in the folder name.
1 | # /refactoring.nvim on git:master o [21:35:23] |
1 | $ git status |
So what do we have available?
1 | git worktree list |
1 | man git-worktree |
The first paragraph gives you the information you need to know, but a way I streamline getting the exact commands to run is using cht.sh
1 | $ curl cht.sh/git~worktree |
git log
1 | git log -S QUERY #search |
Linux Core Utils
What are core utils?
- A set of programs that can make your life easier doing ad hoc tasks
1 | cat text.file | xargs | tr " " "\n" | sort | uniq -c | sort -n |
Linux Core Utils & sed Tips
Sum each line and display the max sum
1 | echo "5 7 9\n11 13 15" | tr " " "+" | bc | sort -nr | head -1 |
Some utils you should just know
cat
read
grep
tr
echo
awk
bc
sort
head
sed