Skip to content

Commit

Permalink
use make for installation, put linux-specific config in subdir
Browse files Browse the repository at this point in the history
  • Loading branch information
mjhoy committed Jun 29, 2017
1 parent 3a71fed commit cf24919
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 7 deletions.
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.PHONY: update-submodules install install-linux

update-submodules:
git submodule update --init

install:
sh scripts/install-dotfiles.sh

install-linux:
sh scripts/install-dotfiles.sh
sh scripts/install-dotfiles-linux.sh
17 changes: 14 additions & 3 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,26 @@ out submodules.
git clone --recursive https://github.com/mjhoy/dotfiles.git
#+end_src

Or, run =make= after doing a normal clone to init and update git
submodules:

#+begin_src sh
cd dotfiles
make
#+end_src

** installing symlinks to $HOME

Running the install script generates the appropriate symbolic links
(e.g., ~/.xmonad -> dotfiles/xmonad, etc):
Running =make install= will generate the appropriate symbolic links
(e.g., ~/.vimrc -> dotfiles/vim/vimrc, etc):

#+begin_src sh
./install.sh
make install
#+end_src

Running =make install-linux= will do the same and include
linux-specific configuration (such as .Xresources).

** nix/NixOS

I am detailing my setup of a NixOS VM (where I hope to do most of my
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
43 changes: 43 additions & 0 deletions scripts/install-dotfiles-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
#
# Install linux-specific dotfiles (i.e., anything that doesn't apply
# to macOS) to the user's HOME by symbolically linking them.

set -e

function run() {
echo "$@"
$($@)
}

function lns() {
run "ln -s $1 $2"
}

dotfiles=( linux/xmonad
linux/xmobarrc
linux/gtkrc-2.0
linux/Xresources
)
regex="/?([^/]+)$"
for i in "${dotfiles[@]}" ; do
[[ $i =~ $regex ]]
filename=${BASH_REMATCH[1]}
dotfilename="$HOME/.$filename"
if [[ ! -e $dotfilename ]]; then
cmd="ln -s $(pwd)/$i $dotfilename"
run $cmd
fi
done

mkdir -p $HOME/bin
for i in bin/* ; do
if [[ ! -e $HOME/$i ]]; then
cmd="ln -s $(pwd)/$i $HOME/$i"
run $cmd
fi
done

if [[ ! -e $HOME/.dotfiles ]]; then
lns $(pwd) $HOME/.dotfiles
fi
6 changes: 2 additions & 4 deletions install.sh → scripts/install-dotfiles.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env bash
#
# Install dotfiles to the user's HOME by symbolically linking them.

set -e

Expand All @@ -19,11 +21,7 @@ dotfiles=( gemrc
ghci
tmux.conf
emacs.d
xmonad
xmobarrc
nix/nixpkgs
gtkrc-2.0
Xresources
)
regex="/?([^/]+)$"
for i in "${dotfiles[@]}" ; do
Expand Down

0 comments on commit cf24919

Please sign in to comment.