mirror of
https://github.com/jimeh/dotfiles.git
synced 2026-02-19 03:26:42 +00:00
chore(install): update install.sh and Makefile
This commit is contained in:
55
Makefile
55
Makefile
@@ -1,62 +1,19 @@
|
|||||||
.SILENT:
|
links:
|
||||||
|
./install.sh links
|
||||||
|
|
||||||
#
|
terminfo:
|
||||||
# Default tasks
|
./install.sh terminfo
|
||||||
#
|
|
||||||
|
|
||||||
install:
|
launch-agents:
|
||||||
make $(DEP_PATHS)
|
./install.sh launch-agents
|
||||||
|
|
||||||
update:
|
|
||||||
make $(foreach path,$(DEP_PATHS),$(shell echo "update_$(path)"))
|
|
||||||
|
|
||||||
clean:
|
|
||||||
make $(foreach path,$(DEP_PATHS),$(shell echo "remove_$(path)"))
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Backups
|
# Backups
|
||||||
#
|
#
|
||||||
|
|
||||||
.PHONY: backup
|
|
||||||
backup: backup-tmux-plugins backup-zplug
|
|
||||||
|
|
||||||
.PHONY: backup-tmux-plugins
|
.PHONY: backup-tmux-plugins
|
||||||
backup-tmux-plugins: \
|
backup-tmux-plugins: \
|
||||||
tmux/tmux-plugins-$(shell date "+%Y-%m-%d").tar.bz2
|
tmux/tmux-plugins-$(shell date "+%Y-%m-%d").tar.bz2
|
||||||
|
|
||||||
.PHONY: backup-zplug
|
|
||||||
backup-zplug: \
|
|
||||||
zsh/zplug-$(shell date "+%Y-%m-%d").tar.bz2
|
|
||||||
|
|
||||||
tmux/tmux-plugins-%.tar.bz2: tmux/plugins
|
tmux/tmux-plugins-%.tar.bz2: tmux/plugins
|
||||||
cd tmux && tar -cjf "$(shell basename "$@")" plugins
|
cd tmux && tar -cjf "$(shell basename "$@")" plugins
|
||||||
|
|
||||||
zsh/zplug-%.tar.bz2: zsh/zplug
|
|
||||||
cd zsh && tar -cjf "$(shell basename "$@")" zplug
|
|
||||||
|
|
||||||
#
|
|
||||||
# Internals
|
|
||||||
#
|
|
||||||
|
|
||||||
DEP_PATHS =
|
|
||||||
|
|
||||||
define dep-file
|
|
||||||
DEP_PATHS += $(1)
|
|
||||||
$(1):
|
|
||||||
echo "fetching $(1)..."
|
|
||||||
mkdir -p "$(shell dirname "$(1)")" && \
|
|
||||||
curl -s -L -o "$(1)" "$(2)"
|
|
||||||
|
|
||||||
.PHONY: remove_$(1)
|
|
||||||
remove_$(1):
|
|
||||||
( test -f "$(1)" && rm "$(1)" && echo "removed $(1)" ) || exit 0
|
|
||||||
|
|
||||||
.PHONY: update_$(1)
|
|
||||||
update_$(1): remove_$(1) $(1)
|
|
||||||
endef
|
|
||||||
|
|
||||||
#
|
|
||||||
# Specify Dependencies
|
|
||||||
#
|
|
||||||
|
|
||||||
$(eval $(call dep-file,zsh/completion/_docker-compose,https://github.com/docker/compose/raw/master/contrib/completion/zsh/_docker-compose))
|
|
||||||
|
|||||||
91
install.sh
91
install.sh
@@ -59,7 +59,7 @@ install_symlinks() {
|
|||||||
|
|
||||||
# Setup private dotfiles
|
# Setup private dotfiles
|
||||||
if [ -f "$ROOT_PATH/$PRIVATE_PATH/install.sh" ]; then
|
if [ -f "$ROOT_PATH/$PRIVATE_PATH/install.sh" ]; then
|
||||||
"$ROOT_PATH/$PRIVATE_PATH/install.sh" links
|
"$ROOT_PATH/$PRIVATE_PATH/install.sh" symlinks
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Symlink each path
|
# Symlink each path
|
||||||
@@ -81,10 +81,17 @@ install_launch_agents() {
|
|||||||
|
|
||||||
# Setup private launch_agents
|
# Setup private launch_agents
|
||||||
if [ -f "$ROOT_PATH/$PRIVATE_PATH/install.sh" ]; then
|
if [ -f "$ROOT_PATH/$PRIVATE_PATH/install.sh" ]; then
|
||||||
"$ROOT_PATH/$PRIVATE_PATH/install.sh" launch_agents
|
"$ROOT_PATH/$PRIVATE_PATH/install.sh" launch-agents
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
install_terminfo() {
|
||||||
|
for file in $ROOT_PATH/terminfo/*.terminfo; do
|
||||||
|
log ok "tic -x" "$file"
|
||||||
|
tic -x "$file"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
install_homebrew() {
|
install_homebrew() {
|
||||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
|
||||||
}
|
}
|
||||||
@@ -104,23 +111,69 @@ install_emacs_config() {
|
|||||||
# Helper functions
|
# Helper functions
|
||||||
#
|
#
|
||||||
|
|
||||||
ok() {
|
# Colors
|
||||||
printf "OK:\t%s\n" "$1"
|
C_RED="$(tput setaf 1)"
|
||||||
}
|
C_GREEN="$(tput setaf 2)"
|
||||||
|
C_YELLOW="$(tput setaf 3)"
|
||||||
|
C_BLUE="$(tput setaf 4)"
|
||||||
|
C_MAGENTA="$(tput setaf 5)"
|
||||||
|
C_CYAN="$(tput setaf 6)"
|
||||||
|
C_GREY="$(tput setaf 7)"
|
||||||
|
C_RESET="$(tput sgr0)"
|
||||||
|
|
||||||
info() {
|
# Symbols
|
||||||
printf "INFO:\t%s\n" "$1"
|
S_RARROW="${C_CYAN}-->${C_RESET}"
|
||||||
|
|
||||||
|
log() {
|
||||||
|
local type="$1"
|
||||||
|
local prefix="$2"
|
||||||
|
shift 2
|
||||||
|
local message="$@"
|
||||||
|
|
||||||
|
type="$(echo "$type" | tr '[:lower:]' '[:upper:]')"
|
||||||
|
case "$type" in
|
||||||
|
OK)
|
||||||
|
type="${C_GREEN}${type}:${C_RESET}"
|
||||||
|
;;
|
||||||
|
WARN | ERROR)
|
||||||
|
type="${C_RED}${type}:${C_RESET}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
type="${C_YELLOW}${type}:${C_RESET}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -n "$prefix" ]; then
|
||||||
|
prefix="${C_GREY}${prefix}: ${C_RESET}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "${type}\t${prefix}${message}\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
symlink() {
|
symlink() {
|
||||||
local source="$1"
|
local source="$1"
|
||||||
local target="$2"
|
local target="$2"
|
||||||
|
local linksource
|
||||||
|
|
||||||
if [ ! -e "$target" ]; then
|
if [ "$target" == "$source" ]; then
|
||||||
ok "symlink: $target --> $source"
|
log ok symlink "$target"
|
||||||
|
elif [ ! -e "$target" ] && [ ! -L "$target" ]; then
|
||||||
|
log link symlink "$target ${S_RARROW} $source"
|
||||||
ln -s "$source" "$target"
|
ln -s "$source" "$target"
|
||||||
|
elif [ -L "$target" ]; then
|
||||||
|
linksource="$(readlink "$target")"
|
||||||
|
if [ "$linksource" == "$source" ]; then
|
||||||
|
log ok symlink "$target ${S_RARROW} $source"
|
||||||
else
|
else
|
||||||
info "symlink: $target exists"
|
log warn symlink "$target ${S_RARROW} $linksource" \
|
||||||
|
"${C_CYAN}(should be ${C_RESET}$source${C_CYAN})${C_RESET}"
|
||||||
|
fi
|
||||||
|
elif [ -f "$target" ]; then
|
||||||
|
log warn symlink "$target exists and is a file"
|
||||||
|
elif [ -d "$target" ]; then
|
||||||
|
log warn symlink "$target exists and is a directory"
|
||||||
|
else
|
||||||
|
log warn symlink "$target exists"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,18 +183,15 @@ dot_symlink() {
|
|||||||
local target="$3/.${name}"
|
local target="$3/.${name}"
|
||||||
local cur_name
|
local cur_name
|
||||||
|
|
||||||
if [ ! -e "$target" ]; then
|
if [ "$(dirname "$name")" != "." ] && [ "$(dirname "$name")" != "/" ]; then
|
||||||
cur_name="$(dirname "$name")"
|
cur_name="$(dirname "$name")"
|
||||||
while [ "$cur_name" != "." ] && [ "$cur_name" != "/" ]; do
|
while [ "$cur_name" != "." ] && [ "$cur_name" != "/" ]; do
|
||||||
source="../${source}"
|
source="../${source}"
|
||||||
cur_name="$(dirname "$cur_name")"
|
cur_name="$(dirname "$cur_name")"
|
||||||
done
|
done
|
||||||
mkdir -p "$(dirname "$target")"
|
|
||||||
ok "symlink: $target --> $source"
|
|
||||||
ln -s "$source" "$target"
|
|
||||||
else
|
|
||||||
info "symlink: $target exists"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
symlink "$source" "$target"
|
||||||
}
|
}
|
||||||
|
|
||||||
git_clone() {
|
git_clone() {
|
||||||
@@ -150,9 +200,9 @@ git_clone() {
|
|||||||
|
|
||||||
if [ ! -e "$target" ]; then
|
if [ ! -e "$target" ]; then
|
||||||
git clone "$clone_url" "$target"
|
git clone "$clone_url" "$target"
|
||||||
ok "git clone: $clone_url --> $target"
|
log ok git-clone "$clone_url ${S_RARROW} $target"
|
||||||
else
|
else
|
||||||
info "git clone: $target already exists"
|
log info git-clone "$target already exists"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,9 +226,12 @@ case "$1" in
|
|||||||
rbenv)
|
rbenv)
|
||||||
install_rbenv
|
install_rbenv
|
||||||
;;
|
;;
|
||||||
launch_agents | agents)
|
launch-agents | launch_agents | agents)
|
||||||
install_launch_agents
|
install_launch_agents
|
||||||
;;
|
;;
|
||||||
|
terminfo)
|
||||||
|
install_terminfo
|
||||||
|
;;
|
||||||
info)
|
info)
|
||||||
echo "Target directory: $TARGET"
|
echo "Target directory: $TARGET"
|
||||||
echo "Detected dotfiles root: $ROOT_PATH"
|
echo "Detected dotfiles root: $ROOT_PATH"
|
||||||
|
|||||||
Reference in New Issue
Block a user