mirror of
https://github.com/tedkulp/dotfiles
synced 2026-04-16 21:34:33 -04:00
38 lines
581 B
Bash
Executable File
38 lines
581 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
function link_test() {
|
|
[[ "$1" -ef "$2" ]] && echo "same file"
|
|
}
|
|
|
|
function link_file() {
|
|
ln -sf ${2#$HOME/} ~/
|
|
}
|
|
|
|
function copy_file() {
|
|
cp -f $2 ~/
|
|
}
|
|
|
|
function post_file() {
|
|
source "$2"
|
|
}
|
|
|
|
function copy_or_link() {
|
|
local base dest
|
|
local cmd="find $HOME/dotfiles/$1 -mindepth 1 -maxdepth 1"
|
|
|
|
# If no files, bail
|
|
if [ "x`${cmd}`" == "x" ]; then return; fi
|
|
|
|
for file in `${cmd}`; do
|
|
base="$(basename $file)"
|
|
dest="$HOME/$base"
|
|
echo "$base -> $dest"
|
|
|
|
"$1_file" "$base" "$file"
|
|
done
|
|
}
|
|
|
|
copy_or_link "link"
|
|
copy_or_link "copy"
|
|
copy_or_link "post"
|