Skip to content

Commit 48fad56

Browse files
committed
Some tweaking to install symlinks.
1 parent 2fb76ea commit 48fad56

File tree

16 files changed

+370
-2820
lines changed

16 files changed

+370
-2820
lines changed

.gitshrc

Lines changed: 0 additions & 23 deletions
This file was deleted.

Rakefile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Ruby. Yuck. Turn into Python when I have time.
2+
3+
require 'rake'
4+
5+
desc "Hook our dotfiles into system-standard positions."
6+
task :install do
7+
linkables = Dir.glob('*/**{.symlink}')
8+
9+
skip_all = false
10+
overwrite_all = false
11+
backup_all = false
12+
13+
linkables.each do |linkable|
14+
overwrite = false
15+
backup = false
16+
17+
file = linkable.split('/').last.split('.symlink').last
18+
target = "#{ENV["HOME"]}/.#{file}"
19+
20+
if File.exists?(target) || File.symlink?(target)
21+
unless skip_all || overwrite_all || backup_all
22+
puts "File already exists: #{target}, what do you want to do? [s]kip, [S]kip all, [o]verwrite, [O]verwrite all, [b]ackup, [B]ackup all"
23+
case STDIN.gets.chomp
24+
when 'o' then overwrite = true
25+
when 'b' then backup = true
26+
when 'O' then overwrite_all = true
27+
when 'B' then backup_all = true
28+
when 'S' then skip_all = true
29+
when 's' then next
30+
end
31+
end
32+
FileUtils.rm_rf(target) if overwrite || overwrite_all
33+
`mv "$HOME/.#{file}" "$HOME/.#{file}.backup"` if backup || backup_all
34+
end
35+
`ln -s "$PWD/#{linkable}" "#{target}"`
36+
end
37+
end
38+
39+
task :uninstall do
40+
41+
Dir.glob('**/*.symlink').each do |linkable|
42+
43+
file = linkable.split('/').last.split('.symlink').last
44+
target = "#{ENV["HOME"]}/.#{file}"
45+
46+
# Remove all symlinks created during installation
47+
if File.symlink?(target)
48+
FileUtils.rm(target)
49+
end
50+
51+
# Replace any backups made during installation
52+
if File.exists?("#{ENV["HOME"]}/.#{file}.backup")
53+
`mv "$HOME/.#{file}.backup" "$HOME/.#{file}"`
54+
end
55+
56+
end
57+
end
58+
59+
task :default => 'install'
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

.bash_completion renamed to bash/bash_completion.symlink

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22
# user bash completion definitions
33

4-
: ${USER_BASH_COMPLETION_DIR:=~/.bash_completion.d}
4+
: ${USER_BASH_COMPLETION_DIR:=~/.dotfiles/bash_completion.d}
55

66
test -n "$USER_BASH_COMPLETION_DIR" && {
77
# source completion directory definitions
File renamed without changes.

.bashrc renamed to bash/bashrc.symlink

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ umask 0022
4949
PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin"
5050
PATH="/usr/local/bin:$PATH"
5151

52-
# put ~/bin on PATH if you have it
53-
test -d "$HOME/bin" &&
54-
PATH="$HOME/bin:$PATH"
52+
# put ~/.dotfiles/bin on PATH if you have it
53+
test -d "$HOME/.dotfiles/bin" &&
54+
PATH="$HOME/.dotfiles/bin:$PATH"
5555

5656
# ----------------------------------------------------------------------
5757
# ENVIRONMENT CONFIGURATION
@@ -164,18 +164,6 @@ prompt_color() {
164164
# ----------------------------------------------------------------------
165165

166166
if [ "$UNAME" = Darwin ]; then
167-
# put ports on the paths if /opt/local exists
168-
test -x /opt/local -a ! -L /opt/local && {
169-
PORTS=/opt/local
170-
171-
# setup the PATH and MANPATH
172-
PATH="$PORTS/bin:$PORTS/sbin:$PATH"
173-
MANPATH="$PORTS/share/man:$MANPATH"
174-
175-
# nice little port alias
176-
alias port="sudo nice -n +18 $PORTS/bin/port"
177-
}
178-
179167
test -x /usr/pkg -a ! -L /usr/pkg && {
180168
PATH="/usr/pkg/sbin:/usr/pkg/bin:$PATH"
181169
MANPATH="/usr/pkg/share/man:$MANPATH"
@@ -190,6 +178,13 @@ if [ "$UNAME" = Darwin ]; then
190178
test -d /opt/jruby &&
191179
JRUBY_HOME="/opt/jruby"
192180
export JRUBY_HOME
181+
182+
# Python environment
183+
source /usr/local/bin/virtualenvwrapper.sh
184+
[[ -s $HOME/.pythonbrew/etc/bashrc ]] && source $HOME/.pythonbrew/etc/bashrc
185+
186+
# Node environment
187+
export NODE_PATH=/usr/local/lib/node_modules
193188
fi
194189

195190
# ----------------------------------------------------------------------
@@ -330,9 +325,6 @@ man () {
330325
# USER SHELL ENVIRONMENT
331326
# -------------------------------------------------------------------
332327

333-
# bring in rbdev functions
334-
. rbdev 2>/dev/null || true
335-
336328
# source ~/.shenv now if it exists
337329
test -r ~/.shenv &&
338330
. ~/.shenv

0 commit comments

Comments
 (0)