Skip to content

Instantly share code, notes, and snippets.

@seefood
Last active February 28, 2024 09:23
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save seefood/d70672cccb551935827ece2554592f96 to your computer and use it in GitHub Desktop.
Save seefood/d70672cccb551935827ece2554592f96 to your computer and use it in GitHub Desktop.
Development Env recommendations, my humble 2 cents.

Basic tools you want to know

We are managing our code versions with Git. It's like Subversion, Perforce and other VCS you may have worked with, but with a P2P twist. Although we work with a central server (bitbucket, github, gitlab and the like), it is just one of many types of workflows used in the industry, so here are some of the major points you need to know:

Dev environment enrichment

I usually work at unix shops, or rather Linux, but the following is useful also for development on OSX machines, which are really Unix. Here are a few useful things you may want to install to get your environment usefully set up with nice tools, informative colorful command prompt and other fun gadgets. Go over these one by one, or if you want to try out my own dotfiles repo that includes all the tools mentioned here and more, see the bottom on this page.

Enjoy!

  • Bash-It is a YUGE set of add-ons for the bash shell. It will give you plugins and completion macros for most of the tools we use, and nice colorful prompts. I recommend the powerline ones or liquidprompt (which bashit will install for you if selected), but it means you may want to add special fonts to render them correctly, see below.
    • Recommended basic settings for Bash-it: (Well, for me, as a DevOps guy)
bash-it enable completion makefile pip ssh system \
  git git_flow docker docker-compose dirs defaults bash-it
  
bash-it enable plugins alias-completion base battery browser docker docker-compose \
  dirs edit-mode-emacs git history less-pretty-cat python ssh virtualenv \
  xterm z_autoenv
  
bash-it enable aliases apt docker vim git general fuck tmux 
  • Additional plugins/completions/aliases exist for MacOS environments. look for textmate, osx, homebrew etc.

  • More prompt colors? check out https://OhMyPosh.dev for a fast tool (written in go), works for bash, zsh, PowerShell, fish and many more, cross platform of course. requires Nerd Fonts, see below.

  • Editors worth checking out, if you are not a vi/vim/neovim/emacs/eclipse/pycharm zealot:

  • Excellent original fonts of the Powerline project and more that you should know:

    • Input font for Xterm/iTerm2/Textmate or any other editor. It pre-includes powerline symbols.
    • Nerd Fonts even more logos and graphics right in your terminal, Powerline is only the beginning!
    • Programming Ligatures: This is an insane idea that I love, may not be for everyone. Supported in VS Code, iTerm2 (on Mac) and Konsole (on GNU/Linux), this takes terminal eye candy to the next level. The most known is Fira Code AKA Fura Code on Nerd Fonts above, but they also exist in Hasklug and other fonts. You may have to tick a "Use Ligatures" box in your terminal's config after selecting them.
    • Other good fonts: https://www.programmingfonts.org/, http://wesbos.com/programming-fonts/ and IBM Plex Mono.
  • sudo apt install silversearcher-ag on Ubuntu or brew install the_silver_searcher on a mac - when you need a smart grep -r, and your target is not a git repo (where git grep is your friend), this little tool is a time saver. I hightly recommend it. usege is ag <RE> [PATH], and it will recursively search but skip swap files, temps, git and subversion DBs, etc.

  • fd is a faster finder than find, but a slightly different feature set. It's nice to know.

  • fzf is a useful tool and works great in the shell for smart history completions (Bash ^R) and tabs. works wondefully with ag and fd above. Excellent experience if you turn on the plugins for fd and fzf in bash-it, or the equivalent plugins in oh-my-zsh, vim etc.

  • Useful github enhancements via local browser plugins, here is a comprehensive list, but use at your own risk, this code has access to your pages and can be malicious, I didn't do security reviews on any of them, naturally)

Global editor settings

To keep the coding style consistant across editors (tabs-vs-spaces especially), please consider using EditorConfig. Most editors have a plugin to support it, and this is my default ~/.editorconfig:

# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4

# Matches multiple files with brace expansion notation
# Set default charset
[*.{js,py}]
charset = utf-8

# 4 space indentation
[*.py]
indent_style = space
indent_size = 4

[*.sh]
indent_style = space
indent_size = 2

# Tab indentation (no size specified)
[Makefile]
indent_style = tab

# Indentation override for all JS under lib directory
[lib/**.js]
indent_style = space
indent_size = 2

# Matches the exact files either package.json or .travis.yml
[{package.json,.travis.yml}]
indent_style = space
indent_size = 2

Useful settings for your ~/.gitconfig

[user]
#  email = <your email>
#  name = <Your Name>
#  signingkey = <PGP Key ID for signing. very optional

[credential]
  # OS-X specific
  helper = osxkeychain

[hub]
  protocol = https

[alias]
  aliases = config --get-regexp alias
  amend = commit --amend --reuse-message=HEAD
  ba = branch -a
  br = branch
  branches = branch -a
  c = clone --recursive
  ca = !git add -A && git commit -av
  ca = commit -a
  ci = commit
  co = checkout
  contributors = shortlog --summary --numbered
  count   = !git shortlog -sn
  cp = cherry-pick
  credit = "\"!f() { git commit --amend --author \\\"$1 <$2>\\\" -C HEAD; }; f\""
  d = "!\"git diff-index --quiet HEAD -- || clear; git --no-pager diff --patch-with-stat\""
  dc = diff --cached
  df = diff
  dfs = diff --cached
  di = "di = !\"d() { git diff --patch-with-stat HEAD~$1; }; git diff-index --quiet HEAD -- || clear; d\""
  dm = \"!git branch --merged | grep -v \\* | xargs -n 1 git branch -d\"
  dump = cat-file -p
  fb = "!f() { git branch -a --contains ; }; f"
  fc = "!f() { git log --pretty=format:'%C(yellow)%h  %Cblue%ad  %Creset%s%Cgreen  [%cn] %Cred%d' --decorate --date=short -S; }; f"
  # fixup is like amend but for older commits. From https://blog.filippo.io/git-fixup-amending-an-older-commit/
  fixup = "!f() { TARGET=$(git rev-parse "$1"); git commit --fixup=$TARGET ${@:2} && EDITOR=true git rebase -i --autostash --autosquash $TARGET^; }; f"
  fm = "!f() { git log --pretty=format:'%C(yellow)%h  %Cblue%ad  %Creset%s%Cgreen  [%cn] %Cred%d' --decorate --date=short --grep=; }; f"
  ft = "!f() { git describe --always --contains ; }; f"
  go = "\"!f() { git checkout -b \\\"$1\\\" 2> /dev/null || git checkout \\\"$1\\\"; }; f\""
  graph = log --graph --pretty=format:'%C(red)%h%Creset%C(red bold)%d%Creset %s%Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative --all
  hist = log --graph --pretty=format:'%C(bold)%h%Creset%C(yellow)%d%Creset %s %C(yellow)%an %C(cyan)%cr%Creset' --abbrev-commit --date=relative
  l = log --pretty=oneline -n 20 --graph --abbrev-commit
  last = log 1 - HEAD
  lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
  lg1 = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
  lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n''          %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
  ll = log -p
  lol = log --graph --decorate --pretty=oneline --abbrev-commit
  lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
  ls = ls-files
  new = !sh -c 'git log $1@{1}..$1@{0} "$@"'
  p = !git checkout master && git pull origin master && git push origin master && git checkout -
  patch = !git --no-pager diff --no-color
  plog = log --pretty=fixes
  pop = stash pop
  pp = !git checkout develop && git pull origin develop && git push origin develop && git checkout -
  promote = !$ZSH/bin/git-promote
  pu = push --force-with-lease
  r = reset
  rank-contributors = !$ZSH/bin/git-rank-contributors
  reb = "\"!r() { git rebase -i HEAD~$1; }; r\""
  remotes = remote -v
  retag = "\"!r() { git tag -d $1 && git push origin :refs/tags/$1 && git tag $1; }; r\""
  review = git-review
  rh = reset --hard
  s = status -s
  slog = log --oneline --decorate
  squash = !"f() { NL=$1; GIT_EDITOR=\"sed -i '2,$NL s/pick/squash/;/# This is the 2nd commit message:/,$ {d}'\"; git rebase -i HEAD~$NL; }; f"
  st = status
  tags = tag -l
  type = cat-file -t
  unstash = stash apply
  wdiff = diff --word-diff=color --ignore-all-space
  wtf     = !$ZSH/bin/git-wtf
  
[push]
  default = simple
  # Read this to set to your needs: https://stackoverflow.com/questions/21839651/git-what-is-the-difference-between-push-default-matching-and-simple
[color]
  ui = auto
[color "branch"]
  current = yellow reverse
  local = yellow
  remote = green
[color "diff"]
  meta = yellow bold
  frag = magenta bold
  old = red bold
  new = green bold
  commit = yellow bold
  whitespace = red reverse
[color "status"]
  added = yellow
  changed = green
  untracked = cyan
[color "decorate"]
  tag = blue

[diff "zip"]
  textconv = unzip -v
  
[pretty]
  fixes = Fixes: %h (\"%s\")
[log]
  decorate=true

[url "https://"]
  insteadOf = git://

[core]
  editor = vim
  pager = less -R
  abbrev = 12
  #whitespace = nowarn
  # Install deff-so-fancy or mark this out:
  pager = diff-so-fancy | less --tabs=4 -RFX
  excludesfile = /Users/ira/.gitignore_global
  autocrlf = input

[merge]
  # Mac or Linux:
  tool = meld
  # Optional, only on Mac:
  #tool = diffmerge
  log = true
  renamelimit = 2000

[filter "lfs"]
  clean = git-lfs clean %f
  smudge = git-lfs smudge %f
  required = true
  process = git-lfs filter-process

[help]
  autocorrect = 1
[http]
  postBuffer = 1048576000
[pack]
  threads = 1

[rerere]
  enabled = true

[pull]
  # Change as appropriate (or per repo)
  rebase = false
[diff]
  renameLimit=1000

Remarks:

  • The above examples assume you prefer vim and meld, feel free to fix this to your personal needs.
  • The examples assume you are using merges. if the default mode is rebase, you can use this.

Advice+tools specific for Mac users

  • Turn on filevault, hook you up to the office TimeCapsule if you have one.

  • Install and use Firefox, Safari is OK but I just can't get used to it.

  • iTerm2 (a better terminal than the built in one, actually better than any available for GNU/Linux).

  • Lots of stuff in the UI that you may want to tweek. And another vid.

  • brew.sh will help you feel at home if you are used to Linux package installers, it can even be used to install some of the tools below. Latest versions now also support GNU/Linux.

  • BetterTouchTool - costs a bit, but worth every penny. You may become adicted to the trackpad and never go back to mice.

  • Karabiner - Fix keyboard layout and shortcuts for Hebrew, development or just if yuou are used to the way things are done in Linux/Windows.

  • Hammerspoon - Automate MacOS with Lua code, this is Karabiner for tasks.

  • Textmate, VS Code, Atom (code editors)

Not just for developers: managing your dot files and configurations

I've been working with GNU/Linux and unix systems for well over 2 decades almost exclusively. There's a silly ritual to get all your favourite tools aligned with what you are used to on other machines. Talkin' about bashrc, profile, aliases, history management, externals like fasd and BashIt, vimrc (or maybe yuou like NeoVIM) and all the plugins it domes with, etc. etc.

Simple solution - prepare a zip and unpack it ecerywhere, or a disrectory you can rsync, but that's a bit naiive and won't let you follow changes in several sites, version and merge things.

I then tried one guy's solution and build my files into it, but it changed often and was a bit rough in my opinion, all the different vim plugins as submodules (before nice plugin manageres like dein or vim-plug came to be) and then one day I see he switched to rcm. I knew I was going to look at one of those new solutions, but being a BashIt user I thought homesick was the Correct Answer(TM).

Looking for a comparison site that will help me pick a solution, I bumped into the great page at https://dotfiles.github.io/ and despaired. There are dozens of solutions out there. Might as well pick out the one I saw named most open, assuming it means it has the more active community, and at the moment it seems to be homesick (homeshick is also an option, it's homesick written in bash, I may need it for smaller environments like RasPi one day).

So if you want an automated install of the above tools and others not mentioned (TheFuck, FZF, fd and more), head on to My Dotfiles repo. There's a quick bootstrap included, go over it and see it does what you expect. If it does not, you may prefer to run parts of it manually or fork and tweak it for yourself. If you come up with good fixes to the problems I bumped into, please send me a PR.

Other honorable mentions:

And remember, wherever you go with this, start at https://dotfiles.github.io/ :-)

Other resources

Bash-it not enough? Prefer Zsh syntax coloring and completion? here are a few things to check:

https://github.com/robbyrussell/oh-my-zsh

https://medium.com/@caulfieldOwen/youre-missing-out-on-a-better-mac-terminal-experience-d73647abf6d7

https://coderwall.com/p/t7a-tq/change-terminal-color-when-ssh-from-os-x

https://medium.com/the-code-review/make-your-terminal-more-colourful-and-productive-with-iterm2-and-zsh-11b91607b98c

https://medium.com/the-code-review/powerlevel9k-personalise-your-prompt-for-any-programming-language-68974c127c63

https://jessicadeen.com/badass-terminal-fcu-wsl-edition-oh-my-zsh-powerlevel9k-tmux-and-more/

https://jessicadeen.com/badass-terminal-wsl-macos-and-ubuntu-dotfiles-update/

https://medium.com/@caulfieldOwen/turn-your-keyboard-into-a-text-editing-rocket-1514d8474d2d

And there's more crazy fun stuff.

https://fishshell.com/

https://github.com/lukaszkorecki/color-tail-ruby

https://0x46.net/thoughts/2019/02/01/dotfile-madness/

Made this gist with help from Github's Markdown guide

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment