Skip to content

Instantly share code, notes, and snippets.

@afaur
Last active November 23, 2018 14:28
Show Gist options
  • Save afaur/1b3ecbed3252b429d0fcdc939c7945e6 to your computer and use it in GitHub Desktop.
Save afaur/1b3ecbed3252b429d0fcdc939c7945e6 to your computer and use it in GitHub Desktop.
Interactive Walkthrough Notes - Iterm2, Tmux, Zsh, Vim, Dotties, Visual Studio Code, and Other CLI Tools
Visual Studio Code
- Terminal Integration
- Big benefit as your able to create multiple sessions and supports color.
- Plugins
Visual Studio Code Settings Sync
- Sync Settings, Snippets, launch, keybindings files and extensions Across Multiple Machines using Github GIST.
File Peek
- Allow peeking to file name strings as definitions from js and ts code.
- Allows peek and goto definition. Great for Angular templates and style files.
Bookmarks
- Mark lines and jump to them
Project Manager
- Easily switch between projects
htmltagwrap
- Wraps selected code with HTML tags
jshint
- Integrates JSHint into VS Code. JSHint is a linter for js.
Git History (git log)
View git log, file or line History
TSLint
- TSLint for Visual Studio Code
Relative Path
- Get relative url paths from files in the current workspace.
Angular 2 TypeScript Snippets
- Angular 2 TypeScript snippets
Encode Decode
- An extension for Visual Studio Code that allows you to quickly convert text selections.
Prettify JSON
- Visual Studio Code Prettify JSON Extension
Duplicate file
Ability to duplicate files in VS Code
Git Blame
- See git blame information in the status bar
change-case
- Quickly change the case (camelCase, CONSTANT)
Open in GitHub / Bitbucket / VisualStudio.com
- Jump to a source code line in Github, Bitbucket, etc
DOTTIES
- https://github.com/afaur/dotties
- Dotties is a tool for managing your dotfiles.
- It allows you to have a base set of config files that you can keep in source control easily.
- It goes a step further and lets you create new github repos for parts of your dotfiles configurations.
- Example: If you have some ruby specific configuration that spans multiple dotfiles in your home directory.
TERMINAL VS ITERM2
- Both are good however if you want mouse support, regex matchers based on terminal streams, or any features listed here:
-- https://www.iterm2.com/features.html
-- Then iterm2 would be worth installing and using.
TMATE
- Make sure not in tmux by default when terminal starts
- tmate attach -- will create/attach to a created tmate session and display how others can connect below.
- To display the connect links again look here:
- http://stackoverflow.com/questions/25122666/in-a-tmate-session-how-do-i-get-the-tmate-session-token-again
- tmux command mode -- display -p '#{tmate_ssh}'
- tmux command mode -- display -p '#{tmate_ssh_ro}'
- If others have a public key issue when connecting they need to create an id_rsa ssh key
- https://docs.joyent.com/public-cloud/getting-started/ssh-keys/
generating-an-ssh-key-manually/manually-generating-your-ssh-key-in-mac-os-x
BASH / ZSH / FISH
- BASH VS ZSH* -- The completion is more customizable and often faster
-- (there is bash-completion that can do per-command completion, but it's often slow)
- BASH VS ZSH* -- ZSH for Oh My ZSH, which includes a ton of useful themes.
-- ZSH also has nicer autocompletion and other little things like that.
- ZSH* VS FISH -- FISH has a nice readline enabled autocomplete which can be used in zsh via a plugin
-- https://github.com/zsh-users/zsh-autosuggestions
TMUX
Added benefits of tmux sessions
- Need to copy text from vim on a remote server to vim on local machine?
- In tmux you can do this tmux can hold the data and allow paste into another window.
- See 'How to copy and paste between tmux windows' below
How to copy and paste between tmux windows
- In tmux window running vim (in file you want to copy from) make sure number mode is off ( :set nonumber )
- While in command mode execute your tmux prefix ( default is control+b ) then press `[`
- Press Shift+v on one of the lines you need to copy and then use `j` and `k` to highlight additional lines
- Press enter to copy the selection to your default tmux pasteboard
- Move to the tmux window running vim where you need to paste ( default is control+b then the window number )
- Make sure paste mode is enabled for vim ( :set paste )
- Go into insert mode ( i, a, or o/O )
- Press the tmux prefix ( default is control+b ) then press `]`
Default prefix vs dotties defaults
- ctrl+b is the default
- meta+i is the dotties default
Most often used commands (* dotties specific (tmux-movements))
Windows
- Prefix+c - Create new window
- Prefix+n - Cycle forward through windows
- Prefix+p - Cycle forward through windows
Panes
- Prefix+% - New vertical pane
- Prefix+" - New horizontal pane
- Prefix+z - Toggles zoom on current pane
- Prefix+arrow keys - Move between panes (default)
- Meta+hjkl - Move between panes *dotties
Manual command
- Prefix+: - Allows you to type in a manual tmux command (doesn't work in tmate unless your the session owner)
- :kill-session - kills the tmux session
- :kill-window - kills the active tmux window
- :kill-pane - kills the active tmux pane
Other Shortcuts
- http://www.dayid.org/comp/tm.html
VIM
Ctrl+p Plugin
- Open multiple files (ctrl+z to mark, ctrl+o to open them)
- :on to eliminate all splits except the one your currently on
- Search buffers (ctrl+p to open, then ctrl+f to switch to buffer search)
Themes/Plugins
- How to install a theme/plugin (add Plug to vimrc.bundles then run dotties update)
- For theme change you adjust your vimrc file
Other Plugins
- https://github.com/afaur/dotties/blob/master/vimrc.bundles
- scrooloose/syntastic -- Lets you know about errors on buffer write (save).
- https://github.com/scrooloose/syntastic
- bling/vim-airline -- Ability to add buffer bar at top, and comes with status bar at bottom.
- https://github.com/vim-airline/vim-airline
- ctrlpvim/ctrlp.vim -- Quick file, and open buffer fuzzy match switch to/open.
- https://github.com/kien/ctrlp.vim
- ihacklog/HiCursorWords -- Any word your currently on will be highlighted across the buffer/file.
- https://github.com/ihacklog/HiCursorWords
- airblade/vim-gitgutter -- Shows +/- for additions and subtractions (of each line in a file) since last git commit.
- https://github.com/airblade/vim-gitgutter
- tpope/vim-sleuth -- Automatically adjusts 'shiftwidth' and 'expandtab' settings.
- https://github.com/tpope/vim-sleuth
- tpope/vim-fugitive -- Git wrapper that enhances the accessing of git from inside vim.
- https://github.com/tpope/vim-fugitive
- tpope/vim-repeat -- Lets '.' repeat plugin actions.
- https://github.com/tpope/vim-repeat
- tpope/vim-surround -- The plugin provides mappings to easily delete, change and add such surroundings in pairs.
- https://github.com/tpope/vim-surround
- Lokaltog/vim-easymotion -- Advanced movements to speed up vim edits.
- https://github.com/easymotion/vim-easymotion
- terryma/vim-multiple-cursors -- Allows for multiple cursors like other visual editors. Multiple selections for Vim.
- https://github.com/terryma/vim-multiple-cursors
Movements, splits, buffers
- Leader+hjkl to move between vim splits
- Open new buffer/file in a new split
:sp filename Open a file in a new buffer and split window
- Notes on splits
ctrl+ws Split windows
ctrl+ww switch between windows
ctrl+wq Quit a window
ctrl+wv Split windows vertically
- Notes on buffers
:e filename Edit a file in a new buffer
:bnext (or :bn) go to next buffer
:bprev (of :bp) go to previous buffer
:bd delete a buffer (close a file)
- Dotties specific buffer management
Leader+n - Cycle forward through buffers
Leader+p - Cycle backward through buffers
Leader+# - Move to buffer by number
Misc tools
exa -- 'ls' replacement written in rust.
- https://github.com/ogham/exa
JSON Tooling (Two options: A and B):
- A. Install JQ
- Install `JQ` which is a command line tool for parsing json.
- https://stedolan.github.io/jq/
- This will allow you to pipe json responses to `jq`, example:
- `curl -X GET -H "Content-Type: application/json" "https://jsonplaceholder.typicode.com/posts/1" | jq`
- This will give you a colored and indented json response in your terminal.
- B. Install `Pygments`
- Create an alias named `json` in your `.bashrc` or `.zshrc`
- `alias json="python -m json.tool | pygmentize -l javascript"`
- Install `pygmentize` by running `easy_install pygments`
- (If easy_install doesn't exist then you need to install python)
- (If you install vim through brew you will get python automatically)
- This will allow you to pipe json responses to `json`, example:
- `curl -X GET -H "Content-Type: application/json" "https://jsonplaceholder.typicode.com/posts/1" | json`
- This will give you a colored and indented json response in your terminal.
ccat -- Colorized 'cat'.
- https://github.com/jingweno/ccat
ngrok -- local tunnels for remote debugging http.
- https://github.com/inconshreveable/ngrok
@afaur
Copy link
Author

afaur commented Dec 10, 2016

Initial Project Investigation Workflow (vim+ctrlp+dotties):

  • Browse to a project directory inside terminal
  • Type vim
  • Type ctrl+p
  • Type a fuzzy partial match for files your interested in
  • Hold ctrl while pressing j and k to move up and down list
  • Type ctrl+z to mark each file your interested in looking at
  • Type ctrl+o to open each file you have marked into a buffer
  • Type :on to remove the multiple panes that were created for each file buffer created without clearing the buffers
  • Use leader+n or p to navigate between the buffers you have open

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