Stratus3D
Everything I need to get setup on a new machine.
This repository contains my Vim, tmux, Zsh, Bash, and asdf config files, a script to symlink all the config files and directories in place, and a set of setup scripts that install all the tools I need on Ubuntu or OSX. The Solarized Color Scheme (http://ethanschoonover.com/solarized) is used for Vim and the terminal emulator profiles.
- Vim, tmux, Zsh, Bash, asdf, and Git configurations
- Setup script that symlinks dotfiles and installs all the software I use
- A collection of Bash scripts I rely on for software development
- List of commands I often forget (see below)
curl
- For the command below
-
Run the
setup.sh
. This will install all the necessary software, setup commonly used directories, and install dotfiles. Since the setup script is idempotent it can be run on machines that have already been setup without causing issues.curl -s https://raw.githubusercontent.com/Stratus3D/dotfiles/master/scripts/setup.sh | bash 2>&1 | tee ~/setup.log
On Debian this is all you need to do. Everything should be installed and configured correctly. On OSX there are two remaining steps.
-
(OSX only) Configure iTerm2 to use the custom profile stored in the dotfiles directory. In the iTerm2 preferences window click the "browse" button and navigate to
~/dotfiles/iterm2_profile/
and select the plist file.
This is software that I need for my day-to-day programming work. I try to keep this list updated with the latest software I am using. This allows me to quickly setup new development machines. I am developing a script named checkenv.sh that will verify everything is setup properly.
- Git (https://git-scm.com/)
- Vim (http://www.vim.org/)
- Tmux (https://tmux.github.io/)
- Z shell (http://zsh.sourceforge.net/)
- asdf (https://github.com/asdf-vm/asdf)
- oh-my-zsh (https://github.com/robbyrussell/oh-my-zsh)
- Tmuxinator (https://github.com/tmuxinator/tmuxinator)
- Exuberant Ctags (http://ctags.sourceforge.net/)
- Virtual Box (https://www.virtualbox.org/) & ievms (https://github.com/xdissent/ievms)
- pgAdmin (http://www.pgadmin.org/download/)
- Dash/ZealDocs (http://zealdocs.org/)
OSX Only
- ipmenulet (https://github.com/mcandre/IPMenulet)
- ShiftIt (https://github.com/fikovnik/ShiftIt)
- Firefox
- Chrome
Use asdf for version management (https://github.com/asdf-vm/asdf) for each language.
- Erlang
- Elixir
- Ruby
- Python
- Lua
- Javascript (NodeJS)
Offline documentation suitable for day to day use.
- Erlang: http://erldocs.com/
- Elixir: http://elixir-lang.org/docs.html
- Ruby: http://pjkh.com/articles/building-your-own-rails-and-ruby-searchable-api-docs/ and http://shynnergy.com/2012/02/create-local-ruby-on-rails-documentation-for-offline-use/
- JavaScript: https://developer.mozilla.org/media/developer.mozilla.org.tar.gz
- C: http://www.gnu.org/software/libc/manual/html_mono/libc.html
- Make: http://www.gnu.org/software/make/manual/make.html
- Joshua Steele's dotfiles (https://github.com/joshukraine/dotfiles)
- thoughtbot/laptop (https://github.com/thoughtbot/laptop)
- Michael J. Smalley's dotfiles (https://github.com/michaeljsmalley/dotfiles)
- Gary Bernhardt's dotfiles (https://github.com/garybernhardt/dotfiles)
- Andrew Stambrosky's dotfiles (https://github.com/astambrosky/dotfiles)
- Complete the
clone_all_bitbucket_repos.sh
script so that all private repos can be cloned. - Complete the
hosts_manager.sh
script. - Figure out how to setup docsets locally when running the setup script.
- Make vim highlight HTML and scripts in HTML correctly.
- Add solarized light/dark toggle functions.
- Make vim read color scheme from zsh.
- Make cursor stay in last position when switching back to buffer kien/ctrlp.vim#240 https://askubuntu.com/questions/223018/vim-is-not-remembering-last-position
Suggestions/improvements are welcome! Please open an issue or contact me directly.
Bash/Zshell Commands
open .
to open current directory in Finderopen -a TextEdit textfile.txt
to open a file in a specific applicationpython -m SimpleHTTPServer 8000
runs a webserver that serves the contents of the directorypython -m smtpd -n -c DebuggingServer localhost:25
runs a SMTP server that logs all messages to the console^X, ^E
to edit the currently typed command in vim!!
run the last command againcd -
change back to the previous directory^A
move to the start of the line^E
move to the end of the line^B
move back one character^P
scroll backward one item in history^N
scroll forward obackne item in historyEsc-B
move back one wordEsc-F
move forward one word^U
delete from cursor to the beginning of the line^K
delete from the cursor to the end of the line^Y
paste previously deleted command (separate from global Cmd-C buffer). Delete a line with^A ^K
and then paste it back with^Y
- Files/directories can be dragged onto the terminal and the path will be pasted at the current cursor position
command <<< "input text"
can be used in place ofcommand < file.in
pkill <process_name>
kills all processes with the given name (e.g.pkill HipChat
kills the HipChat app). The-u
flag limits the killing to all processes with a certain euid (e.g.pkill -u username HipChat
)kill <process_id>
kills the process identified by<process_id>
.-9
can be used to kill the process immediatelyecho -n ✘ | hexdump
to print the encoding of a character by the console. Useful for bash scriptsfor f in directory/* ; do echo -e \\n\\n$f\\n 1>&1 ; cat $f ; done ;
print out all file name and file contents for all files indirectory
.ssh -vT [email protected]
useful for debugging SSH authentication issues.sudo -u git -H ssh -vT bitbucket.org
similar to the SSH command above, only test the connection for a specific user.ssh-add
allows identity to be used on remote machines by using the-A
flag with thessh
command.tar -cvzf tarballname.tar.gz file_or_directory
compressesfile_or_directory
to a tarball namedtarballname.tar.gz
.ssh -A -L 5432:localhost:5432 remoteserver
to proxy whatever (e.g. PostgreSQL) is listening on port5432
onremoteserver
to port 5432 onlocalhost
.ss -tunapl
show which processes are running on which ports.ss -lntu
show which ports have listeners.ls -i -P
show which processes are running on which ports.iptables -vnL
show default firewall rules.tcpdump -A
print out all packets.tcpdump -i lo -s0 -w xyz.pcap
save all packets from interface to file.export $(cut -d= -f1 <file>)
export all variables in file containing environment variablesfind ./ -type f -exec sed -i -e 's/foo/bar/g' {} \;
find and replace string in all files in a directoryfind src -name 'old*' -type f -exec bash -c 'mv "$1" "${1/old/new}"' -- {} \;
rename every filename that matches patternsudo getent passwd | cut -d : -f 6 | sudo sed 's:$:/.bash_history:' | sudo xargs -d '\n' grep -H -e "$command"
orgrep -e "$pattern" /home/*/.bash_history
to see how others use a commandbindkey
show Zsh commandscat *.c *.h | cpp -fpreprocessed | sed 's/[_a-zA-Z0-9][_a-zA-Z0-9]*/x/g' | tr -d ' \012' | wc -c
count words in C projectcolumn -t -s ',' data.csv
print CSV as a table in the terminalfile <img file>
show general image info like format and dimensionsidentify -verbose <img file>
show colorspace, channel depth, dimensions, and other metadata for an imagefor ((n=0;n<10;n++)); do { time bundle exec rspec ./spec ; } 2>> time.txt; done
run a command ten times and write the execution time of each run to a filexmllint --valid --encode utf-8 <file>; echo $?
validate that an XML file is valid and encoded as UTF-8nmcli d wifi
show signals for wifi networksnohup <long running command> &
leave a command running in the background. Even after logout.
OSX Commands
su
needs to besudo su
| paste
needs to be| paste -
lsvfs
get details on file systemskillall -STOP AppName
pause an appkillall -CONT AppName
resume an appditto -x -k <source> <destination dir>
unzip large file on OSX.
Vim Commands
vim -u NONE
start vim without any vimrc.vim -u ~/.othervimrc
to specify a custom vimrc.vit
select contents of html tag.v
isual select texti
n at
ag.dit
would delete the contents of the tag.^A
and^X
allow you to increment the number your cursor is over, or first number after the cursor that is on the same line.<F4>
toggles everything that occupies space to the left of the text (line numbers, gitgutter, etc...)^F-[
in tmux works the same as^F <PageUp>
, which puts tmux into scroll mode. This command comes in handy on keyboards that don't have<PageUp>
and<PageDown>
.:21,25s/old/new/g
to substitutenew
forold
on lines 21 through 25.- When scrolling in tmux,
<fn> <UpArrow>
and<fn> <DownArrow>
can be used instead of<PageUp>
and<PageDown>
. This also comes in handy on keyboards that lack Page Up and Page Down. set list!
to toggle showing of whitespace characters.g;
go back a change positiong,
go forward a change positionvim -V9logfile
tell Vim to log to file a namedlogfile
in the current directory:'<,'>:w !<command>
pipe selection to STDIN of<command>
. For example, to count the words selected run:'<,'>:w !wc -w
or:'<,'>:w !haste|pbcopy
to send to pastebin and copy the URL.g^g
print number of selected lines when in visual mode^x^l
complete whole linecfdo s/foo/bar/g | update
- find and replace in all files in quickfix:g/^\d/norm A;
- use g + norm to add a semicolon to every line that starts with a number.vim --startuptime timeCost.txt timeCost.txt
- record the startup time of vim.e! ++enc=<encoding>
- reopen the file as a different encoding.:r https://stratus3d.com/index.html
load remote file into buffer:e https://stratus3d.com/index.html
load remote file into new buffer
SSH/SCP Commands
scp localfile user@remotehost:~
to copylocalfile
up to your home directory onremotehost
.scp user@remotehost:remote/file local/directory/
to downloadfile
fromremotehost
Make Targets and Commands
print-%: ; @echo $*=$($*)
orprint-%: ; @echo '$(subst ','\'',$*=$($*))'
allows you to runmake print-<variable_name>
and print the value of any variable. Can be used without modifying the file in GNU make 3.82 or greater like this:make --eval="print-%: ; @echo $*=$($*)" print-SOURCE_FILES
.
Screen Commands
^A d
detach current window.screen -rd
to reattach a window. Follow the prompts if there are multiple windows.
Git Commands
git tag --contains <commit hash>
- Lists the tags that include the specified commit.git clean -X
- Remove files ignored by Gitgit checkout $(git rev-list -n 1 --before="2016-07-05 21:00" master)
- Checkout a branch at a specific point in time.git show $(git rev-list -n 1 --before="2016-07-05 21:00" master):path/to/file
- Show what a file looked like at a specific point in time on a specific branch.--ignore-all-space
- Ignore whitespace only changes when showing diff.git stash save --keep-index
- Stash everything except what is already staged.git add -p
- Stage specific changes in a file.git merge-base --is-ancestor <commit-1> <commit-2>
- Check ifcommit-1
is an ancestor ofcommit-2
.git describe --long
- version string suitable for Erlang module-vsn
attributes.git log --grep="^prefix" --pretty='format:%h - %cn - %s'
find all commits withprefix
git log -p --cc
show only resolved conflicts in merge commitsgit shortlog -sn --since='10 weeks' --until='2 weeks'
show number commits by each committer between two timesgit diff --word-diff
show changed words rather than linesgit mergetool --tool-help
show merge tools availablegit checkout -m FILE
restores a file to it's unresolved stategit push --force-with-lease
only overwrites changes in the remote branch if the remote branch has not changed since you last pushed to it.git diff master --name-only
list filenames of files that have been changed.
Irssi Commands
/server
/connect <server name>
- Connect to an IRC server (/connect irc.freenode.net
)/join <channel name>
- Join a channel on an IRC server (/join #erlang
)/disconnect
/q <users nick>
starts a private message with a user./wc
closes the current window. This parts from the current channel or disconnects from the current network.Alt + Left Arrow/Right Arrow
scroll through Irssi windows.
VirtualBox Commands
VBoxManage unregistervm --delete <vm name>
Completely removes the VM and all associated files
Gcc Flags
-ftrapv
trap signed integer overflows
Erlang Flags
bin_opt_info
print warnings and information about how binaries are used+pc unicode
increase the range of characters that the system will consider printable. Helpful when testing with unicode in the shell
Bash Flags
-
set -x
- Turn on debug mode. -
set -e
- Exit if any command has a non-zero exit status. This ensures all commands that can fail are handled properly. -
set -u
- Exit if any variable is undefined (other than$* and $ @, which are assumed to be available). -
set -o pipefail
- Causes any non-zero exit status in a pipeline to be the exit status of the entire pipeline. http://redsymbol.net/articles/unofficial-bash-strict-mode/
Curl Commands
-w "%{http_code}\n"
- Show the status code of the response.
AWK and sed
#!/usr/bin/sed 1d .
- prints all but the first line of the sed file.
Postgres
SHOW hba_file;
- Show the path topg_hba.conf
config file.\du
- Show all roles\x ON
- Turn extended display on in the psql console. This prints columns vertically, and is useful for when a table too wide to display in the console.\df+ <function_name>
- Show the source code of a Postgres function.
Pranks
say -v whisper "I am watching you"