Motivation 💭
Don't you hate getting a new laptop or joining a new team and then spending a whole day setting up your system preferences and tools? Me too. That's why we automate; we did it once and we don't want to do have to do it again.
I was struggling to find a Zsh theme and that had what I was looking for so I made my own theme using Powerlevel10k!
This started as Anderson Reis's Computer shell configuration dotfiles but has grown to a multi-developer platform for machine configuration.
To get started please run:
$ sh -c "`curl -fsSL https://raw.githubusercontent.com/areisrosa/dotf/master/install.sh`"📔 NOTE: Dotf will automatically install all of its subcomponents. If you want to be asked about each one, use:
$ sh -c "`curl -fsSL https://raw.githubusercontent.com/areisrosa/dotf/master/install.sh`" -s ask- When it finishes, open a terminal of your preference and go to the
~/.dotf/config/kettyopen the file ketty.conf choose a theme for kitty however comment the line font_family if you prefer another theme. If it isn't there for some reason, import it from~/.dotf/fonts-- you may also need to select theFira Code Nerd Fontfont and check the box for non-ascii font; - I've also found that you need to reboot before fast key repeat will be enabled.
📔 NOTE: I'll regularly add new configurations so keep an eye on this repo as it grows and optimizes.
Brings huge changes. If you have made any modifications (and didn't make your
own fork), you will want to backup your dotfiles prior to running git pull --rebase on ~/.dotf.
Do the following to upgrade your ~/.dotf safely:
cd ~/.dotf- update dotfiles:
git pull --rebase - run
./install.shagain
If you have existing dotfiles for configuring git, zsh, vim, etc, these will be
backed-up into ~/.dotf_backup/$(date +"%Y.%m.%d.%H.%M.%S") and replaced with
the files from this project.
⚠️ WARNING: The restore script does not currently restore system settings--only your original dotfiles. To restore system settings, you'll need to manually undo what you don't like (so don't forget to fork, review, tweak)
Read on to learn what dofiles provides!👈 Click
Think of Zsh as a more awesome bash without having to learn anything new. Automatic spell correction for your commands, syntax highlighting, and more. We've also provided lots of enhancements:
- Vim mode, Fzf and bash style
Ctrl-Rfor reverse history finder; Ctrl-x,Ctrl-lto insert output of last command;- Fuzzy matching - if you mistype a directory name, tab completion will fix it.
Lots of things we do every day are done with two or three character mnemonic aliases, please feel free to edit them:
ae- alias editar- alias reload
Dotfiles will take over your ~/.gitconfig, so if you want to store your
usernames, please put them into ~/.gitconfig.user
It is recommended to use this file to set your user info. Alternately, you can
set the appropriate environment variables in your ~/.secrets.
git logorgl- a much more usable git loggit branchorgb- a list of branches with summary of last commitgit remote- a list of remotes with infogit tagorgt- a list of tags with infogit checkout -borgnb- a (n)ew (b)ranch - like checkout -bgcp- cherry-pick -x (showing what was cherrypicked)git simple- a clean format for creating changelogsgit recent-branches- if you forgot what you've been working ongit unstageorguns- (remove from index) andgit uncommit/gunc(revert to the time prior to the last commit - dangerous if already pushed) aliases
📔 NOTE: Some sensible default configs, such as improving merge messages, push only pushes the current branch, removing status hints, and using mnemonic prefixes in diff: (i)ndex, (w)ork tree, (c)ommit and (o)bject Slightly improved colors for diff
gdmb(g)it (d)elete (m)erged (b)ranches - Deletes all branches already merged on current branch
Github Issues: ghi gem
We include the ghi command. Try ghi list and have fun managing issues from
command line!
The tmux.conf provides some sane defaults for tmux on Mac OS like a powerful
status bar and vim keybindings. You can customize the configuration in
~/.tmux.conf.user.
The default prefix is C-b. But I prefer use my muscle memory with prefix C-a
(=C-a or ^A), if you want change the prefix then go to ~/.tmux.conf.
# remap prefix to Control + w
set -g prefix C-w
bind C-w send-prefix
unbind C-b
📔 NOTE: I'm going to assume that C-w is
your prefix.
-
Sessionis a set of windows, plus a notion of which window is current. -
Windowis a single screen covered with panes. (Once might compare it to a ‘virtual desktop’ or a ‘space’.) -
Paneis a rectangular part of a window that runs a specific command, e.g. a shell.
C-a ?- display a list of keyboard shortcuts:
Depending on the value of mode-keys. Emacs is the default, and if you want
Vim shortcuts for help and copy modes (e.g. j, k, C-u, C-d), add the
following line to ~/.tmux.conf:
setw -g mode-keys vi
📔 NOTE: Any command mentioned in this list can be executed as
tmux somethingorC-a :something(or added to~/.tmux.conf).
Creating a session:
$ tmux new-session -s workCreate a new session that shares all windows with an existing session, but has its own separate notion of which window is current:
$ tmux new-session -s work2 -t workAttach to a session:
$ tmux attach -t workSwitch between sessions:
C-a (- previous sessionC-a )- next sessionC-a L- ‘last’ (previously used) sessionC-a s- choose a session from a list
Switch between windows:
C-a 1- switch to window1, ..., 9, 0C-a p- previous windowC-a n- next windowC-a l- ‘last’ (previously used) windowC-a w- choose window from a list
Switch between windows with a twist:
C-a M-n- next window with a bell, activity or content alertC-a M-p- previous such window
Creating a new pane by splitting an existing one:
C-a v- split vertically (top/bottom)C-a s- split horizontally (left/right)
Moving panes around:
C-a {- move the current pane to the previous positionC-a }- move the current pane to the next positionC-a C-o- rotate window ‘up’ (i.e. move all panes)C-a M-o- rotate window ‘down’C-a !- move the current pane into a new separate window (‘break pane’)C-a- :move-pane -t :3.2 split window 3's pane 2 and move the current pane there
Resizing panes:
C-a M-up,C-a M-down,C-a M-left,C-a M-right- resize by 5 rows/columnsC-a C-up,C-a C-down,C-a C-left,C-a C-right- resize by 1 row/column
Applying predefined layouts:
C-a M-1- switch to even-horizontal layoutC-a M-2- switch to even-vertical layoutC-a M-3- switch to main-horizontal layoutC-a M-4- switch to main-vertical layoutC-a M-5- switch to tiled layoutC-a space- switch to the next layout
Switching between panes:
C-l- go to the next pane on the leftC-h- go to the next pane on the rightC-j- go to the next pane on the upC-k- go to the next pane on the downC-\- go to previous splitC-h/j/k/l/\- navigate between panes and including Vim splitsC-a o- go to the next pane (cycle through all of them)C-a ;- go to the ‘last’ (previously used) pane
Other:
C-a d- detach from a session:C-a c- create a new windowC-a a- rename the current window;C-a q- display pane numbers for a short whileC-a y- toggle "synchronize" to all panes of the current windows;C-a z- toggle pane zoom between full window size and normal pane size.C-a x- kill the current paneC-a ,- rename the current window orC-a &- kill the current window.
Copy and paste inside Tmux:
1) Alt-ESCAPE (=M-ESCAPE): enter copy mode, use vi keys for navigation
(h,j,k,l,H,M,L,g,G,/,?);
2) v: start selection;
3) y or Enter: The End Selection;
4) Alt-p (=M-p): paste selection.
📔 NOTE: Prefix- =: View all copy buffers and pastes selection (Press to ESCAPE (=Esc) mode or Enter select). Hold "Shift" if one wishes to copy and paste into or out-of tmux using mouse selections.
Force a reload of the config file on C-a r:
unbind r
bind r source-file ~/.tmux.conf
Some other settings that I use:
setw -g xterm-keys on
Usage, at command line:
$ tmux new -s foglamp # create a new session named foglamp
$ tmux ls # list active sessions
$ tmux attach # attach to first active session
$ tmux attach -t foglamp # attach to session named "foglamp".📔 NOTE:
tnewis an alias to create a session named using the current directory
Also an included Ctrl-R reverse history search feature in editrc, very useful
in irb, postgres command line, and etc.
- Navigation - NERDTree, EasyMotion, FZF and more
- Code manipulation - rails support, comments, snippets, highlighting
- Utils - indents, paste buffer management, lots more
- General enhancements that don't add new commands
A list of some of the most useful commands that Dotfiles provides in vim are included below. This is not a comprehensive list. To get deeper knowledge, practice a few of these every day, and then start looking into the lists of plugins above to learn more.
,z- go to previous buffer (:bp),x- go to next buffer (:bn)Cmd-jandCmd-kto move up and down roughly by functions (Altin Linux)Ctrl-o- Old cursor position - this is a standard mapping but very useful, so included hereCtrl-i- opposite of Ctrl-O (again, this is standard)
,tg- instantly Find definition of class (must have exuberant ctags installed),T- same as,tgbut in a vertical split,gforCtrl-f- same as vim normal gf (go to file), but in a vertical split (works with file.rb:123 line numbers also)gF- standard vim mapping, here for completeness (go to file at line number),k- Search the current word under the cursor and show results in quickfix window,K- Grep the current word up to next exclamation point (useful for ruby foo! methods),hl- toggle search highlight on and off,ggor,ag- Grep command line, type between quotes. Uses Ag Silver Searcher. After searching with,ggyou can navigate the results withCtrl-xandCtrl-z(or standard vim:cnand:cp),gd- Grep def (greps for 'def [function name]') when cursor is over the function name,gcf- Grep Current File to find references to the current file//- clear the search,,w(alias,<esc>) or,,b(alias,<shift-esc>) - EasyMotion, a vimperator style tool that highlights jump-points on the screen and lets you type to get there.,mc- mark this word for MultiCursor (like sublime). UseCtrl-n(next),Ctrl-p(prev),Ctrl-x(skip) to add more cursors, then do normal vim things like edit the word.gK- Opens the documentation for the word under the cursor. Spacebar - Sneak - type two characters to move there in a line. Kind of like vim'sfbut more accurate.:Gsearch foo- global search, then do your normal%s/search/replace/gand follow up with:Greplaceto replace across all files. When done use:wallto write all the files.
,fzf- Fzf-vim fuzzy file selector,fb- Fzf-vim buffer selector - great for jumping to a file you already have open,fbt- jump to method - Fzf tag search within current bufferCtrl-\- Show current file in NERDTree
- Ctrl-Space to autocomplete. Tab for snipmate snippets.
,#,",',],),}to surround a word in these common wrappers. the # does #{ruby interpolation}. works in visual mode. Normally these are done with something likeysw#Cmd-',Cmd-",Cmd-],Cmd-), etc to change content inside those surrounding marks. You don't have to be inside them (Altin Linux),.to go to last edit location (same as'.) because the apostrophe is hard on the pinky,cito change inside any set of quotes/brackets/etc
- Use
Cmd-1thruCmd-9to switch to a specific tab number (like iTerm) - and tabs have been set up to show numbers (Altin Linux) Ctrl-h,l,j,k- to move left, right, down, up between splits. This also works between vim and tmux splits thanks tovim-tmux-navigator.Q- Intelligent Window Killer. Close windowwincmd cif there are multiple windows to same buffer, or kill the bufferbwipeoutif this is the last window into it.vv- vertical split (Ctrl-w,v)ss- horizontal split (Ctrl-w,s),qo- open quickfix window (this is where output from Grep goes),qc- close quickfix
Ctrl-pafter pasting - Usepto paste andCtrl-pto cycle through previous pastes. Provided by YankRing.,yr- view the yankring - a list of your previous copy commands. also you can paste and hitctrl-pfor cycling through previous copy commandscrs,crc,cruvia abolish.vim, coerce to snake_case, camelCase, and UPPERCASE. There are more:help abolish:NR- NarrowRgn - use this on a bit of selected text to create a new split with just that text. Do some work on it, then :wq it to get the results back.,cf- Copy Filename of current file (full path) into system (not vi) paste buffer,cn- Copy Filename of current file (name only, no path),yw- yank a word from anywhere within the word (so you don't have to go to the beginning of it),ow- overwrite a word with whatever is in your yank buffer - you can be anywhere on the word. saves having to visually select it,ocf- open changed files. open all files with git changes in splits,w- strip trailing whitespacessj- split a line such as a hash {:foo => {:bar => :baz}} into a multiline hash (j = down)sk- unsplit a link (k = up)Cmd-Shift-A- align things (type a character/expression to align by, works in visual mode or by itself) (Altin Linux):ColorToggle- turn on #abc123 color highlighting (useful for css):Gitv- Git log browsers,hi- show current Highlight group. if you don't like the color of something, use this, then usehi! link [groupname] [anothergroupname]in your vimrc.after to remap the color. You can see available colors using:hi,gt- Go Tidy - tidy up your html code (works on a visual selection):Wrap- wrap long lines (e.g. when editing markdown files)Cmd-/- toggle comments (usually gcc from tComment) (Altin Linux)gcp(comment a paragraph)
,vvand,ccto switch between view and controller - these are maps to :Rcontroller and :Rview. Explore the :R family of commands for more fun from rails.vim!,rsand,rlto run rspec or a spec line in iTerm (check iTerm window for results),ssand,slfor the same usingspring rspecwhich makes your Rails specs faster by caching the Rails env (must have spring gem installed)- vim-ruby-refactoring - try
,rem,,relto extract methods or let statements :Bopen [gem name]to navigate to a gem.,orb- outer ruby block. takes you one level up from nested blocks (great for rspec)
,vc- (Vim Command) copies the command under your cursor and executes it in vim. Great for testing single line changes to vimrc.,vr- (Vim Reload) source current file as a vim file
⚠️ WARNING: This cheatsheet is summarized from personal experience and other online tutorials. It should not be considered as an official advice.
:help keyword- open help for keyword:o file- open file:saveas file- save file as:close- close current pane
h- move cursor leftj- move cursor downk- move cursor upl- move cursor rightH- move to top of screenM- move to middle of screenL- move to bottom of screenw- jump forwards to the start of a wordW- jump forwards to the start of a word (words can contain punctuation)e- jump forwards to the end of a wordE- jump forwards to the end of a word (words can contain punctuation)b- jump backwards to the start of a wordB- jump backwards to the start of a word (words can contain punctuation)0- jump to the start of the line^- jump to the first non-blank character of the line$- jump to the end of the lineg_- jump to the last non-blank character of the linegg- go to the first line of the documentG- go to the last line of the document{number}G- go to line {number}t{char}- Till before [count]'th occurrence of {char} to the rightT{char}- Till before [count]'th occurrence of {char} to the leftf{char}- To [count]'th occurrence of {char} to the rightF{char}- To [count]'th occurrence of {char} to the left;- Repeat latest f, t, F or T [count] times,- Repeat latest f, t, F or T in opposite direction}- jump to next paragraph (or function/block, when editing code){- jump to previous paragraph (or function/block, when editing code)zz- center cursor on screenCtrl + b- move back one full screenCtrl + f- move forward one full screenCtrl + d- move forward 1/2 a screenCtrl + u- move back 1/2 a screen
r- replace a single characterJ- join line below to the current onecc- change (replace) entire linecw- change (replace) to the start of the next wordce- change (replace) to the end of the next wordcb- change (replace) to the start of the previous wordc0- change (replace) to the start of the linec$- change (replace) to the end of the lines- delete character and substitute textS- delete line and substitute text (same as cc)xp- transpose two letters (delete and paste).- repeat last commandu- undoCtrl + r- redo
i- insert before the cursorI- insert at the beginning of the linea- insert (append) after the cursorA- insert (append) at the end of the lineo- append (open) a new line below the current lineO- append (open) a new line above the current lineea- insert (append) at the end of the wordEsc- exit insert mode
ctrl-h- While in Insert mode: delete character before the cursorctrl-w- While in Insert mode: delete word before the cursord{motion}- Delete text that {motion} moves overdd- Delete lineD- Delete characters under the cursor until the end of the linec{motion}- Delete {motion} text and start insertcc- Delete line and start insertC- Delete to the end of the line and start insertr{char}- Replace the character under the cursor with {char}R- Enter replace mode: Each character replaces existing onex- Delete [count] characters under and after the cursor
v- start visual mode, mark lines, then do a command (like y-yank)V- start linewise visual modeo- move to other end of marked areaO- move to other corner of blockaw- mark a wordab- a block with ()aB- a block with {}ib- inner block with ()iB- inner block with {}Esc- exit visual modeCtrl + v- start visual block mode
>- shift text right<- shift text lefty- yank (copy) marked textd- delete marked text~- switch case
yy- yank (copy) a line2yy- yank (copy) 2 linesyw- yank (copy) the characters of the word from the cursor position to the start of the next wordy$- yank (copy) to end of linep- put (paste) the clipboard after cursorP- put (paste) before cursordd- delete (cut) a line2dd- delete (cut) 2 linesdw- delete (cut) the characters of the word from the cursor position to the start of the next wordD- delete (cut) to the end of the lined$- delete (cut) to the end of the lined^- delete (cut) to the first non-blank character of the lined0- delete (cut) to the begining of thelinex- delete (cut) character
/pattern- search for pattern?pattern- search backward for pattern\vpattern- 'very magic' pattern: non-alphanumeric characters are interpreted as special regex symbols (no escaping needed)n- repeat search in same directionN- repeat search in opposite direction:%s/old/new/g- replace all old with new throughout file:%s/old/new/gc- replace all old with new throughout file with confirmations:noh- remove highlighting of search matches
:vimgrep /pattern/ {file}- search for pattern in multiple files:cn- jump to the next match:cp- jump to the previous match:copen- open a window containing the list of matches
:w- write (save) the file, but don't exit:w !sudo tee %- write out the current file using sudo:wqor:xorZZ- write (save) and quit:q- quit (fails if there are unsaved changes):q!orZQ- quit and throw away unsaved changes
:e file- edit a file in a new buffer:bnextor:bn- go to the next buffer:bprevor:bp- go to the previous buffer:bd- delete a buffer (close a file):ls- list all open buffers:sp file- open a file in a new buffer and split window:vsp file- open a file in a new buffer and vertically split windowCtrl + ws- split windowCtrl + ww- switch windowsCtrl + wq- quit a windowCtrl + wv- split window verticallyCtrl + wh- move cursor to the left window (vertical split)Ctrl + wl- move cursor to the right window (vertical split)Ctrl + wj- move cursor to the window below (horizontal split)Ctrl + wk- move cursor to the window above (horizontal split)
:tabnewor:tabnew file- open a file in a new tabCtrl + wT- move the current split window into its own tabgtor:tabnextor:tabn- move to the next tabgTor:tabprevor:tabp- move to the previous tab<number>gt- move to tab:tabmove <number>- move current tab to the th position (indexed from 0):tabcloseor:tabc- close the current tab and all its windows:tabonlyor:tabo- close all tabs except for the current one:tabdo command- run the command on all tabs (e.g. :tabdo q - closes all opened tabs)
- Debugging vim keymappings
- Overriding vim settings with ~/.vimrc.after and friends
- Adding your own vim plugins
We can use Docker to test some changes in a Linux Container.
Assuming your host system has docker and docker-compose properly installed, run:
$ docker-compose run dotfilesThis will build the container image if it never built it before (which may take
a while -- future times will be faster) and then run a zsh session inside
that container for you. There you can play around, test commands, aliases, etc.
⚠️ WARNING: This repo is primarily macOS oriented. So any support for Linux can only be done with the help of the community.
This project is licensed under GNU. Please fork, contribute and share.
- Loathing should be directed into pull requests that make it better. woot.
- Bugs with the setup should be put as GitHub issues.
- Praise should be directed to
⚠️ WARNING: The creator of this repo is not responsible if your machine ends up in a state you are not happy with. If you are concerned, look at the code to review everything this will do to your machine.