Skip to content

Instantly share code, notes, and snippets.

@mitio
Last active December 19, 2018 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mitio/edc115038a049aa7d581e9598974172c to your computer and use it in GitHub Desktop.
Save mitio/edc115038a049aa7d581e9598974172c to your computer and use it in GitHub Desktop.
An overview of the tooling I use

Tooling

Basic setup, macOS tips & misc

  • Homebrew for installing packages & brew cask for precompiled binaries.
  • brew services list for managing daemons.
  • Booting Rack apps with puma-dev via HTTPS – I've added its unique CA to my system's trusted certs (see how here).
  • Dash for offline docs. It's running constantly and a global hotkey (Cmd + Shift + Space) shows its window. It's also integrated with my editor.
  • rbenv for Ruby version management.
  • macOS: I use spaces. 50/50 on this one, not sure how efficient it is.
  • I use Alfred instead of Spotlight but the latter also works pretty fine. Spotlight-like tools are a killer macOS feature.
  • macOS tip: Cmd + Shift + ? to focus in the app's Help -> Search menu.
  • Muzzle turns on "Do not disturb" mode on my Mac when I'm sharing my screen in Zoom.
  • Slate for basic window management plus Karabiner-Elements for remapping keys (Capslock & F4 currently).

Terminal

  • iTerm + https://github.com/robbyrussell/oh-my-zsh. It might be slower to render but it has so much conveniences that I can't let it go.
  • Cmd + D to split the terminal vertically or Cmd + Shift + D to split horizontally and view multiple sessions on a single screen. Cmd + Alt + Ctrl + ARROWS moves me between panes. Panes can be rearranged with the mouse as well and converted to or from tabs at will.
  • Cmd + Shift + E to toggle timestamps.
  • Cmd + click on files (works even with line numbers). Your editor must be the default program to open that file type.
  • A global hotkey (Cmd + Alt + /) to start up or show a terminal. Configured via Spark.app.
  • A ton of other features.

Editor

  • I use Sublime Text 3. Although it's closed source and paid, it's fast and has a very good and convenient UX out of the box, with minimal configuration. It's scriptable via a good Python API (it has Python built in). I'm on the dev channel (paid only) – it's stable enough and the newest features arrive there.

  • Top features I use NON STOP:

    • The "Command palette" (via a key binding) - 98% of the editor and files can be manipulated via commands in there.
    • Fuzzy finding – works in the Command pallete and in the "Go to anything" dialogs.
    • "Go to anything" dialog – jump to files, method definitons, lines, identifiers.
    • Has ctags support. Indexes files automatically. Understands most syntaxes and allows me to quickly jump to method definitions.
  • It keeps state somewhere and when restarted, preserves things exactly where I left them (including new and unsaved file changes).

  • Multiple cursors are super useful and I use them all the time. Many ways to activate them, e.g. Cmd + D to find and select the next occurrence of the current selection or word under the the cursor. I also often use Cmd + Shift + L to split the selection into lines.

  • Integrates with the terminal via subl, e.g. subl . to open the current folder in the editor.

  • I've configured Sublime to be the default app to open a lot of code files (e.g. *.rb) to allow Cmd + click in iTerm to open them in the editor.

  • Some useful plugins:

    • PackageControl – for managing other packages (installing, removing, etc.) It might come preinstalled in the latest versions, haven't checked lately.
    • DashDoc – integrates with Dash. Ctrl + H searches for the word under the cursor in Dash.
    • AdvancedNewFile & SideBarEnhancements – these provide some convenient file manipulation options, e.g. duplicate file, move & rename file and more. All via the Command palette.
    • Git + GitGutter provide various convenient Git integrations. E.g. show added/modified/removed status for the current file, Git blame, open Git commits and more.
    • Hayaku for writing CSS faster. Works for SCSS too as its simple word completion based on a fuzzy match with intelligent defaults. E.g. w + Tab autocompletes to width: 100%;.
    • JSON Reindent – I reindent JSON files on a daily basis. Helps me comprehend JSON blobs I've pasted from somewhere.
    • Alignment – align variable assignments around =.
    • ChangeQuotes – toggle between single and double quotes smartly. Works for most languages.
    • RubyBlockConverter & RubyHashConverter – toggle between one- and multiline blocks and between the old- and new-style Ruby hashes.
    • Wrap Plus – smart word wrapping (up to your first defined ruler). Works fine with e.g. Markdown files.
    • TrailingSpaces – highlights trailing spaces and allows me to strip them with one keystroke.
  • Shortcuts – a ton of them. Just open "Preferences: Key Bindings" from the Command palette and dig in.

  • Some notable custom config options I've set:

     "rulers":
     [
     	100,
     	120
     ],
     "draw_white_space": "all",
     "show_full_path": true,
  • For linting I use SublimeLinter and its plugins, SublimeLinter-rubocop, SublimeLinter-Ruby and more. I've had some trouble making it work with local per-project Rubocop configs. Not sure how it'll deal with a remote Rubocop config.

  • I've had problems with making Sublime properly pick up my user's ENV as that's required to make rbenv function properly.

Git & shell aliases

  • grep-in-project greps for something in all the Ruby code your project is using – including its gems. It depends on bundler. It's simple but very useful:

     grep-in-project () {
     	git --no-pager grep "$@"
     	grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn} -RI "$@" `bundle show --paths`
     }
  • A default macOS trick – open URL_OR_PATH will launch the default app for URL_OR_PATH and open it there. open . also works.

  • A Git integration in the shell (showing branch names and state) is a must.

  • rgo GEM_NAME opens the Rubygems page for a gem. gho opens the GH url of a repo. gho REFSPEC opens the GH URL of a commit or a branch:

     ghurl () {
     	repo=`git config --get remote.origin.url | sed 's/\.git$//'`
     	if echo $repo | grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn} '@' > /dev/null
     	then
     		repo="https://github.com/`echo $repo | cut -d':' -f2`"
     	fi
     	echo $repo
     }
    
     gho () {
     	commit_ref="$1"
     	if [ -z "$commit_ref" ]
     	then
     		open `ghurl`
     	else
     		open "`ghurl`/commit/$commit_ref"
     	fi
     }
    
     rgo () {
     	open "https://rubygems.org/gems/$1"
     }

Git aliases & workflow

  • When I have to do a force push, I always do it with --force-with-lease. I do it explicitly every time (no default somewhere). I rarely do force pushes and I like the explicitness.

  • gp is an alias for git pull. I've also configured to do a rebase when pulling, so gp is essentially git pull --rebase.

  • I update projects with gp -p which prunes local cache of branches deleted at the upstream.

  • I've got the following global Git config – the more interesting options there:

    • Always commit in verbose mode (a must) – shows a diff of the changes below the commit message. Helps me type in a more suitable commit.

    • vim is my default $EDITOR in the terminal and I use it to write commit messages. I've also got the following in my ~/.vimrc to make it do spell checking and wrap lines at 72 chars:

       " Wrap Git commit messages wrapping and spell
       checking au FileType gitcommit set spell tw=72
      
[color]
diff = auto
status = auto
branch = auto
grep = auto
[alias]
st = status
ci = commit
br = branch
co = checkout
df = diff
lg = log -p
[merge]
conflictstyle = diff3
[pull]
rebase = preserve
[push]
default = tracking
[branch]
autosetuprebase = always
[rerere]
enabled = true
[commit]
verbose = true
[rebase]
autosquash = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment