A few things you could use to improve your software development experience
In which I give a few pointers to things I use regularly (meaning: on a daily basis) and that generally save time or makes your life easier.
Mastery of git is more than essential. It’s better to start using the command line (with the included helpers
git gui) rather than a full GUI in order to (really) learn what it does. As a heavy emacs user I use magit and got so used to it that it is sometimes the sole reason I have an emacs client running.
Whichever client you use, you should be super comfortable doing these very basic actions:
- cloning a repository
- creating/switching branches
- staging and commiting code
- pushing commits
- merging or rebasing a remote branch
- create short aliases for often use commands (eg
More arcane functionalities you could use on a daily basis:
- interactive rebase on the latest commits (
git rebase -i HEAD~5): move commits, squash useless commits, edit the commit message
- set the upstream of a branch to
origin/masterso you can easily pull the latest changes
- use the stash when there is a conflict during a branch change/pull
- use the staging area to “save” your work in progress
- stage and commit hunks of code and not the whole diff in a file
- Add additional missing things to your latest commit with
git commit --amend --no-edit
- safely force push to fixup things or just update your pending pull request:
git push --force-with-lease
pull --rebase(will rebase your work on top of the remote branch) and rebase autostash (will stash all your pending changes, rebase then re-apply your pending work)
Instead of learning the peculiarities of a fancy terminal GUI with tabs and split screen, use tmux.
The first good reason is that it will work the same way anywhere (OSX, linux, cygwin windows…). The second good reason is that when you are connected to a remote host or inside a docker container you’ll be happy to know the commands fluently.
C-B wshows the windows list and allow quick navigation with a freaking preview
C-B lgo to the latest tab. Useful when you need to constantly switch between the same two tabs
C-B z“zoom” the current window. Super useful when you have a split and need to see a large file or log. Type the same again to unzoom.
C-B [enter copy mode, the useful thing here is the search forward
C-sand search backward
C-rfunctionality. Leave with
:setw synchronize-panestype the same things in multiple panes (eg: you have three ssh sessions and want to do exactly the same things on the three host quickly)
set-window-option -g automatic-rename on: so tabs are named after the current directory
set-option -g set-titles on: so your fancy terminal title means something
set -g mouse on: because resizing panes or scrolling using the keyboard is just painful. And sometimes it is way easier to click on a window to activate it.
- tpm: plugin manager
- resurrect: save and restore sessions (your tabs, splits and their content)
- continuum: automatically saves your sessions so you don’t have to
Apart from your IDE, your text editor of choice, maybe a compiler and a few basic tools you should be able to work without installing anything. If you have to setup nginx or mysql locally you could probably use docker instead.
Command line docker with more than just a few options is painful. So, use docker-compose for anything complex (eg: you need to mount 3 directories and 2 files, open 2 port, set 4 environment variables, change the default command). Things will be much more clear and easily reusable.
Interesting usage during your daily work is the ability to try different version of a software painlessly.
For instance, to try build your java project in java 8 and 10 this would work:
$ docker run --rm -v "$(pwd):/data" -w "/data" -u $UID openjdk:8 ./gradlew build -x check
$ docker run --rm -v "$(pwd):/data" -w "/data" -u $UID openjdk:10 ./gradlew build -x check
Here you execute a command in a specific java environment, sharing your current working directory and creating files using your current user UID (so you won’t have
root owned files created)
If you want a web based ui to see what containers are running, what images do you have and whatnot, you can use portainer.io, and yes, you can run it with docker:
docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer --no-auth
visit http://127.0.0.1:9000, choose “local environment” and you are good to go
Builtin command to paginate files. Among the thing you can do:
G: go to the end of the file
42G: go to line 42
/: search a string
F: go to the end of the file and starts pulling the file for changes. Think of it as a
tail -fyou can interrupt and search anytime
grep , taking into account
.gitignorefile among other things like programming language based file extensions filtering (eg: filter for C language considers both
An easier to use
NCurses Disk Usage
Ncdu is a disk usage analyzer with an ncurses interface. It is designed to find space hogs on a remote server where you…
An interactive shell based and faster
perl for recursive find and replace
The easier/faster way I found to find and replace a regex in multiple files is to use perl:
perl -p -i.bkp -e 's/to replace/new text/g' **/*
This is extremely fast and with the previous example will backup all modified files with a
.bkp extension (if you don’t want that, just remove the
.bkp in the command. Or name it differently if you want).
Many logging tools, like Splunk, provide great features but are optimized for large-scale deployments. They require…
Powerful and easy to use log viewer. Can display multiple log files in the same screen, syntax coloring, quick error navigation.
For your daily work, drop bash and install a decent shell. Meaning one with bells and whistles.
Vanilla zsh is painful to configure. oh-my-zsh fixes this.
A delightful community-driven (with 1,100+ contributors) framework for managing your zsh configuration. Includes 200+…
I have the following plugins enabled:
git: autocompletes git commands
safe-paste: write a return character in your shell when you paste something with an EOL character in it instead of executing the command right away.
docker: docker auto completion
zsh-autosuggestions: show you a possible completion of the current line you are typing based on your history
lsalternative, shows git status of files and uses informative colors
command-no-found: shows you how to install the required missing package when you type a not found command
tmux: aliases and run helpers for tmux
autojump: sources the autojump configuraton file (see after)
autojump - A cd command that learns - easily navigate directories from the command line
Keeps a weighted history of your visited paths and allows you to quickly go back anywhere by typing
j and a few letters of the directory you want to visit.
A better way to navigate your shell history, removes duplicates (with
setopt HIST_IGNORE_ALL_DUPS) and fuzzy finds words.