diff --git a/README.md b/README.md index 10cc23c..a2e2368 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,11 @@ dotfiles ======== -My vim and git config files. Some of it is customized around my system setup (like aliases pointing to paths) but you should be able to easily remove that stuff. +Various dotfiles and misc configs. Some of it is customized around my system setup +(like aliases pointing to paths) but you should be able to easily remove that stuff. Installing ========== -Installation is done via Rake. Just run +Symlink files in the root directory. OS specific configs are in their respective folders. - rake install - -This will create symlinks in your home folder to the various dotfiles in this repo. - -Note to self -============ - -The bashrc file is meant for Windows. diff --git a/Rakefile b/Rakefile deleted file mode 100644 index ad06dad..0000000 --- a/Rakefile +++ /dev/null @@ -1,73 +0,0 @@ -require 'rake' - -desc "install the dot files into user's home directory" -task :install do - replace_all = false - # link dotfiles first - create_dotfile_link - - Dir['*'].each do |file| - next if %w[Rakefile README notes fonts iterm id_dsa.pub .git .gitignore gitignore].include? file - - if File.exist?(File.join(ENV['HOME'], ".#{file}")) - if replace_all - replace_file(file) - else - print "overwrite ~/.#{file}? [ynaq] " - case $stdin.gets.chomp - when 'a' - replace_all = true - replace_file(file) - when 'y' - replace_file(file) - when 'q' - exit - else - puts "skipping ~/.#{file}" - end - end - else - link_to_dotfile file - end - end - - setup_some_folder "Where are your personal files?", "~/.personal-files" - setup_some_folder "Where are your work files?", "~/.work-files" - setup_temp_folder - setup_work_aliases - - puts "Setup is nearly complete. The last step is to run `git submodule update --init`" -end - -def create_dotfile_link - system %Q{rm -f "$HOME/.dotfiles"} - system %Q{ln -s $PWD "$HOME/.dotfiles"} -end - -def replace_file(file) - system %Q{rm -r "$HOME/.#{file}"} - link_to_dotfile file -end - -def link_to_dotfile(file) - link_file "$HOME/.dotfiles/#{file}", "$HOME/.#{file}" -end - -def link_file(source, dest) - puts "linking #{source} to #{dest}" - system %Q{ln -s #{source} #{dest}} -end - -def setup_some_folder(msg, file_name) - puts msg - dir = $stdin.gets.chomp - link_file dir, file_name -end - -def setup_temp_folder - system %Q{mkdir -p ~/.tmp} -end - -def setup_work_aliases - system %Q{touch ~/.work-aliases} -end diff --git a/zsh/aliases b/aliases similarity index 95% rename from zsh/aliases rename to aliases index 79fafd0..8236cef 100644 --- a/zsh/aliases +++ b/aliases @@ -23,7 +23,7 @@ alias cd...='cd ../..' alias cd....='cd ../../..' alias cd.....='cd ../../../..' -alias aliases='vim ~/.dotfiles/zsh/aliases' +alias aliases='vim ~/.dotfiles/aliases' alias al='aliases' alias b='bundle' alias be='bundle exec' @@ -95,11 +95,19 @@ alias rbg='rbenv gemset active' alias rbp='cd $RBENV_PATH/versions/$(rbenv version | sed -e "s/ (set.*$//")' alias rbl='cd $RBENV_PATH/versions/$(rbenv version | sed -e "s/ (set.*$//")/lib/ruby' alias rg='rails generate' + +function reload { + if [[ $platform == 'Linux' || $platform == 'Darwin' ]]; then + source ~/.zshrc + else + source ~/.bash_profile + fi +} + alias rl='reload' alias rmr='rm -rf' alias rc='rails console' alias rs='rails server' -alias reload='source ~/.zshrc' alias restart='sudo shutdown now -r' alias s='cd ~/.ssh' alias sc='vim ~/.ssh/config' @@ -117,12 +125,22 @@ alias vimrc='vim ~/.vimrc' alias weather='curl wttr.in/toronto' # Git + +function gitCmdWrapper { + # If no args are provided then run `git status` + if [[ $# > 0 ]]; then + git $@ + else + git status + fi +} + alias am='git commit --amend' alias ama='git commit --amend -C head --author' alias ams='git commit -S --amend' # signed alias ammend='echo "use am instead"' alias amend='echo "use am instead"' -alias g='gst' +alias g='gitCmdWrapper' alias ga='git add -A :/' alias gaa='git add -A' alias gaap='git add -Ap' @@ -212,7 +230,6 @@ alias grmr='git rm -r' alias grp='git reset -p' alias gsnapshot='git stash save "snapshot: $(date)" && git stash apply "stash@{0}"' alias gsh='git show' -alias gst='git status' alias gs='git stash' alias gsk='git stash -k -u' alias gss='git stash save' @@ -250,6 +267,7 @@ alias writing='cd ~/.personal-files/brain/writing' # Projects alias dev='cd ~/.personal-files/dev' +alias games='cd ~/.personal-files/dev/games' alias projects='cd ~/.personal-files/dev/projects' alias dot='cd ~/.dotfiles' alias work='cd ~/.work-files' diff --git a/bash_profile b/bash_profile deleted file mode 100644 index abb35c3..0000000 --- a/bash_profile +++ /dev/null @@ -1,3 +0,0 @@ -# generated by Git for Windows -test -f ~/.profile && . ~/.profile -test -f ~/.bashrc && . ~/.bashrc diff --git a/zsh/functions b/functions similarity index 89% rename from zsh/functions rename to functions index e3ad15b..9b90d87 100644 --- a/zsh/functions +++ b/functions @@ -1,3 +1,5 @@ +platform=`uname` + function activate_virtualenv() { if [ -f venv/bin/activate ]; then . venv/bin/activate; elif [ -f ../venv/bin/activate ]; then . ../venv/bin/activate; @@ -57,15 +59,6 @@ function git-on-master { git rebase master } -function g { - if [[ $# > 0 ]]; then - git $@ - else - git status - fi -} -compdef g=git - function rrg { rake routes | grep $1 } @@ -82,12 +75,20 @@ function gc { # Search google for a term function google() { - open /Applications/Google\ Chrome.app/ "http://www.google.com/search?q= $1"; + if [[ $platform == 'Darwin' ]]; then + open /Applications/Google\ Chrome.app/ "http://www.google.com/search?q= $1"; + else + crome "http://www.google.com/search?q= $1"; + fi } # Open a file in chrome function chrome () { - open -a /Applications/Google\ Chrome.app/ "$1" + if [[ $platform == 'Darwin' ]]; then + open -a /Applications/Google\ Chrome.app/ "$1" + else + chrome "$1" + fi } # See top 10 bash commands diff --git a/gitconfig b/gitconfig index cf08dc5..5d871c2 100644 --- a/gitconfig +++ b/gitconfig @@ -1,3 +1,5 @@ +[include] + path = ~/.gitconfig.platform [user] name = Michael Campagnaro email = mikecampo@gmail.com @@ -5,7 +7,6 @@ summary = true tool = vimdiff [core] - editor = /usr/bin/vim excludesfile = ~/.gitignore [push] default = upstream diff --git a/gitignore b/gitignore index 3e7e6b1..f7adcbc 100644 --- a/gitignore +++ b/gitignore @@ -6,3 +6,5 @@ log/ db/*.sqlite3 .netrwhist project-notes.txt +.lvimrc +personal diff --git a/linux/gitconfig.platform b/linux/gitconfig.platform new file mode 100644 index 0000000..caad4c1 --- /dev/null +++ b/linux/gitconfig.platform @@ -0,0 +1,2 @@ +[code] + editor = vim diff --git a/osx/gitconfig.platform b/osx/gitconfig.platform new file mode 100644 index 0000000..58ab4f2 --- /dev/null +++ b/osx/gitconfig.platform @@ -0,0 +1,2 @@ +[code] + editor = /usr/bin/vim diff --git a/osx/readme.md b/osx/readme.md index 43553b5..25b9e52 100644 --- a/osx/readme.md +++ b/osx/readme.md @@ -14,10 +14,3 @@ ## Setup Keyboard Map to in System Preferences -> Keyboard -> Modifier Keys. Now can leave insert mode. - - -## Setup Git - -Vim might not work properly when writing commit messages. To fix, run: - - $ git config --global core.editor /usr/bin/vim diff --git a/windows/bash_profile b/windows/bash_profile new file mode 100644 index 0000000..a82a60e --- /dev/null +++ b/windows/bash_profile @@ -0,0 +1 @@ +test -f ~/.bashrc && . ~/.bashrc diff --git a/bashrc b/windows/bashrc similarity index 66% rename from bashrc rename to windows/bashrc index a5c95fe..d1db7e9 100644 --- a/bashrc +++ b/windows/bashrc @@ -1,4 +1,6 @@ # For Windows setup -source /d/Dev/projects/dotfiles/zsh/aliases +source ~/.functions +source ~/.aliases # Unbreak broken, non-colored terminal export TERM=xterm-256color +cd ~ diff --git a/windows/gitconfig.platform b/windows/gitconfig.platform new file mode 100644 index 0000000..58ab4f2 --- /dev/null +++ b/windows/gitconfig.platform @@ -0,0 +1,2 @@ +[code] + editor = /usr/bin/vim diff --git a/windows/readme.md b/windows/readme.md index 47e01ef..9179c79 100644 --- a/windows/readme.md +++ b/windows/readme.md @@ -1,10 +1,13 @@ -# Windows +# Windows Setup * map caps to left-ctrl using https://sharpkeys.codeplex.com/ * install git for Windows -* create ~/.profile and add `source ~/.bashrc` -* after installing dotfiles, edit ~/.gitconfig and change the editor to be `vim` instead of `/usr/bin/vim` +* symlink dotfiles to ~/.dotfiles with `cmd //c 'mklink .dotfiles drive:\path\to\dotfiles'` +* symlink files in the dotfiles windows folder using `cmd //c 'mklink .some-file .dotfiles\some-file'` +* symlink appropriate files in the root dotfiles directory + * ignore all zsh files + * don't symlink .vim folder because Plugged will fail to install the plugins. Just make a copy. ## Setting up Clojure diff --git a/zshrc b/zshrc index 8742dd7..1ed6389 100644 --- a/zshrc +++ b/zshrc @@ -90,8 +90,8 @@ bindkey -e source $ZSH/lib/*.zsh # Source my custom files after oh-my-zsh so I can override things. -source $HOME/.dotfiles/zsh/aliases -source $HOME/.dotfiles/zsh/functions +source $HOME/.dotfiles/functions +source $HOME/.dotfiles/aliases # Fix in neovim infocmp $TERM | sed 's/kbs=^[hH]/kbs=\\177/' > $HOME/.$TERM.ti