Big cleanup and more streamlined windows setup

This commit is contained in:
Michael Campagnaro 2017-02-18 13:05:08 -05:00
parent 29c01feba6
commit 178e1873a4
15 changed files with 59 additions and 115 deletions

View File

@ -1,18 +1,11 @@
dotfiles 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 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.

View File

@ -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

View File

@ -23,7 +23,7 @@ alias cd...='cd ../..'
alias cd....='cd ../../..' alias cd....='cd ../../..'
alias cd.....='cd ../../../..' alias cd.....='cd ../../../..'
alias aliases='vim ~/.dotfiles/zsh/aliases' alias aliases='vim ~/.dotfiles/aliases'
alias al='aliases' alias al='aliases'
alias b='bundle' alias b='bundle'
alias be='bundle exec' 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 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 rbl='cd $RBENV_PATH/versions/$(rbenv version | sed -e "s/ (set.*$//")/lib/ruby'
alias rg='rails generate' alias rg='rails generate'
function reload {
if [[ $platform == 'Linux' || $platform == 'Darwin' ]]; then
source ~/.zshrc
else
source ~/.bash_profile
fi
}
alias rl='reload' alias rl='reload'
alias rmr='rm -rf' alias rmr='rm -rf'
alias rc='rails console' alias rc='rails console'
alias rs='rails server' alias rs='rails server'
alias reload='source ~/.zshrc'
alias restart='sudo shutdown now -r' alias restart='sudo shutdown now -r'
alias s='cd ~/.ssh' alias s='cd ~/.ssh'
alias sc='vim ~/.ssh/config' alias sc='vim ~/.ssh/config'
@ -117,12 +125,22 @@ alias vimrc='vim ~/.vimrc'
alias weather='curl wttr.in/toronto' alias weather='curl wttr.in/toronto'
# Git # 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 am='git commit --amend'
alias ama='git commit --amend -C head --author' alias ama='git commit --amend -C head --author'
alias ams='git commit -S --amend' # signed alias ams='git commit -S --amend' # signed
alias ammend='echo "use am instead"' alias ammend='echo "use am instead"'
alias amend='echo "use am instead"' alias amend='echo "use am instead"'
alias g='gst' alias g='gitCmdWrapper'
alias ga='git add -A :/' alias ga='git add -A :/'
alias gaa='git add -A' alias gaa='git add -A'
alias gaap='git add -Ap' alias gaap='git add -Ap'
@ -212,7 +230,6 @@ alias grmr='git rm -r'
alias grp='git reset -p' alias grp='git reset -p'
alias gsnapshot='git stash save "snapshot: $(date)" && git stash apply "stash@{0}"' alias gsnapshot='git stash save "snapshot: $(date)" && git stash apply "stash@{0}"'
alias gsh='git show' alias gsh='git show'
alias gst='git status'
alias gs='git stash' alias gs='git stash'
alias gsk='git stash -k -u' alias gsk='git stash -k -u'
alias gss='git stash save' alias gss='git stash save'
@ -250,6 +267,7 @@ alias writing='cd ~/.personal-files/brain/writing'
# Projects # Projects
alias dev='cd ~/.personal-files/dev' alias dev='cd ~/.personal-files/dev'
alias games='cd ~/.personal-files/dev/games'
alias projects='cd ~/.personal-files/dev/projects' alias projects='cd ~/.personal-files/dev/projects'
alias dot='cd ~/.dotfiles' alias dot='cd ~/.dotfiles'
alias work='cd ~/.work-files' alias work='cd ~/.work-files'

View File

@ -1,3 +0,0 @@
# generated by Git for Windows
test -f ~/.profile && . ~/.profile
test -f ~/.bashrc && . ~/.bashrc

View File

@ -1,3 +1,5 @@
platform=`uname`
function activate_virtualenv() { function activate_virtualenv() {
if [ -f venv/bin/activate ]; then . venv/bin/activate; if [ -f venv/bin/activate ]; then . venv/bin/activate;
elif [ -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 git rebase master
} }
function g {
if [[ $# > 0 ]]; then
git $@
else
git status
fi
}
compdef g=git
function rrg { function rrg {
rake routes | grep $1 rake routes | grep $1
} }
@ -82,12 +75,20 @@ function gc {
# Search google for a term # Search google for a term
function google() { 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 # Open a file in chrome
function 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 # See top 10 bash commands

View File

@ -1,3 +1,5 @@
[include]
path = ~/.gitconfig.platform
[user] [user]
name = Michael Campagnaro name = Michael Campagnaro
email = mikecampo@gmail.com email = mikecampo@gmail.com
@ -5,7 +7,6 @@
summary = true summary = true
tool = vimdiff tool = vimdiff
[core] [core]
editor = /usr/bin/vim
excludesfile = ~/.gitignore excludesfile = ~/.gitignore
[push] [push]
default = upstream default = upstream

View File

@ -6,3 +6,5 @@ log/
db/*.sqlite3 db/*.sqlite3
.netrwhist .netrwhist
project-notes.txt project-notes.txt
.lvimrc
personal

2
linux/gitconfig.platform Normal file
View File

@ -0,0 +1,2 @@
[code]
editor = vim

2
osx/gitconfig.platform Normal file
View File

@ -0,0 +1,2 @@
[code]
editor = /usr/bin/vim

View File

@ -14,10 +14,3 @@
## Setup Keyboard ## Setup Keyboard
Map <CapsLock> to <Ctrl> in System Preferences -> Keyboard -> Modifier Keys. Now <caps-c> can leave insert mode. Map <CapsLock> to <Ctrl> in System Preferences -> Keyboard -> Modifier Keys. Now <caps-c> 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

1
windows/bash_profile Normal file
View File

@ -0,0 +1 @@
test -f ~/.bashrc && . ~/.bashrc

View File

@ -1,4 +1,6 @@
# For Windows setup # For Windows setup
source /d/Dev/projects/dotfiles/zsh/aliases source ~/.functions
source ~/.aliases
# Unbreak broken, non-colored terminal # Unbreak broken, non-colored terminal
export TERM=xterm-256color export TERM=xterm-256color
cd ~

View File

@ -0,0 +1,2 @@
[code]
editor = /usr/bin/vim

View File

@ -1,10 +1,13 @@
# Windows # Windows Setup
* map caps to left-ctrl using https://sharpkeys.codeplex.com/ * map caps to left-ctrl using https://sharpkeys.codeplex.com/
* install git for Windows * 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 ## Setting up Clojure

4
zshrc
View File

@ -90,8 +90,8 @@ bindkey -e
source $ZSH/lib/*.zsh source $ZSH/lib/*.zsh
# Source my custom files after oh-my-zsh so I can override things. # Source my custom files after oh-my-zsh so I can override things.
source $HOME/.dotfiles/zsh/aliases source $HOME/.dotfiles/functions
source $HOME/.dotfiles/zsh/functions source $HOME/.dotfiles/aliases
# Fix <c-h> in neovim # Fix <c-h> in neovim
infocmp $TERM | sed 's/kbs=^[hH]/kbs=\\177/' > $HOME/.$TERM.ti infocmp $TERM | sed 's/kbs=^[hH]/kbs=\\177/' > $HOME/.$TERM.ti