|
@@ -4,7 +4,7 @@ set -e |
|
|
# setup.sh --- 10sr setup script |
|
|
# setup.sh --- 10sr setup script |
|
|
# 2014, 10sr. Unlicensed <http://unlicense.org> |
|
|
# 2014, 10sr. Unlicensed <http://unlicense.org> |
|
|
|
|
|
|
|
|
__setups="shrc_common gitconf tmux scripts darwin dirs selfupdate windirs dotfiles" |
|
|
|
|
|
|
|
|
__setups="shrc_common gitconf tmux scripts darwin dirs selfupdate windirs dotfiles env" |
|
|
|
|
|
|
|
|
__homelocal="$HOME/.local" |
|
|
__homelocal="$HOME/.local" |
|
|
__homevar="$HOME/.var" |
|
|
__homevar="$HOME/.var" |
|
@@ -35,6 +35,26 @@ islinux= |
|
|
########################### |
|
|
########################### |
|
|
# utils |
|
|
# utils |
|
|
|
|
|
|
|
|
|
|
|
##########################33 |
|
|
|
|
|
# Utilities |
|
|
|
|
|
|
|
|
|
|
|
__tput_bold=`tput bold || true` |
|
|
|
|
|
__tput_default=`tput sgr0 || true` |
|
|
|
|
|
__tput_yellow=`tput setaf 3 || true` |
|
|
|
|
|
|
|
|
|
|
|
_msg(){ |
|
|
|
|
|
echo ">> ${__tput_bold}$*${__tput_default}" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_warn(){ |
|
|
|
|
|
echo ">>> ${__tput_yellow}${__tput_bold}$*${__tput_default}" 1>&2 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_die(){ |
|
|
|
|
|
_warn "$@" |
|
|
|
|
|
exit 1 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
_download(){ |
|
|
_download(){ |
|
|
# download <url> <file> |
|
|
# download <url> <file> |
|
|
if type wget >/dev/null 2>&1 |
|
|
if type wget >/dev/null 2>&1 |
|
@@ -43,6 +63,9 @@ _download(){ |
|
|
elif type curl >/dev/null 2>&1 |
|
|
elif type curl >/dev/null 2>&1 |
|
|
then |
|
|
then |
|
|
curl --url "$1" --output "$2" |
|
|
curl --url "$1" --output "$2" |
|
|
|
|
|
else |
|
|
|
|
|
_warn "No download program found." |
|
|
|
|
|
_die "Install wget or curl." |
|
|
fi |
|
|
fi |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -71,7 +94,7 @@ detect_systems(){ |
|
|
($ismsys || $iscygwin) && iswindows=true |
|
|
($ismsys || $iscygwin) && iswindows=true |
|
|
# is this true? |
|
|
# is this true? |
|
|
($isdarwin || $isfreebsd) && isbsd=true |
|
|
($isdarwin || $isfreebsd) && isbsd=true |
|
|
return 0 |
|
|
|
|
|
|
|
|
_msg "Detecting the system...done" |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
################################ |
|
|
################################ |
|
@@ -82,6 +105,7 @@ detect_systems(){ |
|
|
# setup selfupdate |
|
|
# setup selfupdate |
|
|
|
|
|
|
|
|
setup_selfupdate(){ |
|
|
setup_selfupdate(){ |
|
|
|
|
|
_msg "Download latest setup.sh from 10sr repository." |
|
|
mkdir -p "$DOTFILES_DIR" |
|
|
mkdir -p "$DOTFILES_DIR" |
|
|
_download $_dotfiles_url_base/setup.sh "$DOTFILES_DIR/"setup.sh |
|
|
_download $_dotfiles_url_base/setup.sh "$DOTFILES_DIR/"setup.sh |
|
|
chmod +x "$DOTFILES_DIR"/setup.sh |
|
|
chmod +x "$DOTFILES_DIR"/setup.sh |
|
@@ -92,20 +116,23 @@ setup_selfupdate(){ |
|
|
# setup dotfiles |
|
|
# setup dotfiles |
|
|
|
|
|
|
|
|
setup_dotfiles(){ |
|
|
setup_dotfiles(){ |
|
|
|
|
|
_msg "Prepare latest dotfiles." |
|
|
mkdir -p "$DOTFILES_DIR" |
|
|
mkdir -p "$DOTFILES_DIR" |
|
|
if test "$1" = "--git" |
|
|
if test "$1" = "--git" |
|
|
then |
|
|
then |
|
|
# git clone |
|
|
# git clone |
|
|
|
|
|
_msg "Using git" |
|
|
if test -d "$DOTFILES_DIR"/.git |
|
|
if test -d "$DOTFILES_DIR"/.git |
|
|
then |
|
|
then |
|
|
echo "Git repository $DOTFILES_DIR already exists" |
|
|
|
|
|
echo "Skipping" |
|
|
|
|
|
|
|
|
_warn "Git repository $DOTFILES_DIR already exists" |
|
|
|
|
|
_warn "Skipping" |
|
|
else |
|
|
else |
|
|
git clone git@github.com:10sr/dotfiles.git "$DOTFILES_DIR" |
|
|
git clone git@github.com:10sr/dotfiles.git "$DOTFILES_DIR" |
|
|
fi |
|
|
fi |
|
|
else |
|
|
else |
|
|
for f in $@ |
|
|
for f in $@ |
|
|
do |
|
|
do |
|
|
|
|
|
_msg "Prepareing $f" |
|
|
mkdir -p "`dirname $f`" |
|
|
mkdir -p "`dirname $f`" |
|
|
_download $_dotfiles_url_base/$f "$DOTFILES_DIR"/$f |
|
|
_download $_dotfiles_url_base/$f "$DOTFILES_DIR"/$f |
|
|
done |
|
|
done |
|
@@ -122,6 +149,7 @@ setup_dotfiles(){ |
|
|
__shrc_common="$HOME/.shrc.common" |
|
|
__shrc_common="$HOME/.shrc.common" |
|
|
|
|
|
|
|
|
setup_shrc_common(){ |
|
|
setup_shrc_common(){ |
|
|
|
|
|
_msg "Generate $__shrc_common" |
|
|
test -f "$__shrc_common" && rm -- "$__shrc_common" |
|
|
test -f "$__shrc_common" && rm -- "$__shrc_common" |
|
|
|
|
|
|
|
|
cat <<__EOC__ >"$__shrc_common" |
|
|
cat <<__EOC__ >"$__shrc_common" |
|
@@ -149,9 +177,10 @@ __EOC__ |
|
|
# setup gitconf |
|
|
# setup gitconf |
|
|
|
|
|
|
|
|
setup_gitconf(){ |
|
|
setup_gitconf(){ |
|
|
|
|
|
_msg "Configure git environment" |
|
|
if ! command -v git >/dev/null |
|
|
if ! command -v git >/dev/null |
|
|
then |
|
|
then |
|
|
echo "git not found" |
|
|
|
|
|
|
|
|
_msg "Git program not found" |
|
|
return 0 |
|
|
return 0 |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
@@ -212,6 +241,7 @@ git checkout master && git merge --no-ff --stat --verbose -'" |
|
|
|
|
|
|
|
|
setup_tmux(){ |
|
|
setup_tmux(){ |
|
|
tmux_conf_local="$HOME/.tmux.conf.local" |
|
|
tmux_conf_local="$HOME/.tmux.conf.local" |
|
|
|
|
|
_msg "Generate $tmux_conf_local" |
|
|
|
|
|
|
|
|
case "`hostname`" in |
|
|
case "`hostname`" in |
|
|
arch-aspireone) |
|
|
arch-aspireone) |
|
@@ -236,9 +266,9 @@ setup_tmux(){ |
|
|
;; |
|
|
;; |
|
|
esac |
|
|
esac |
|
|
|
|
|
|
|
|
cat <<__EOC__ >"$tmux_conf_local" |
|
|
|
|
|
|
|
|
_date= `date` cat <<__EOC__ >"$tmux_conf_local" |
|
|
# $tmux_conf_local |
|
|
# $tmux_conf_local |
|
|
# Automatically generated by $0 |
|
|
|
|
|
|
|
|
# Automatically generated by $0 at $_date |
|
|
|
|
|
|
|
|
set -g status-right "${USER}@$(hostname) | #(tmux -V) " |
|
|
set -g status-right "${USER}@$(hostname) | #(tmux -V) " |
|
|
|
|
|
|
|
@@ -268,10 +298,13 @@ _fetch_script(){ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
setup_scripts(){ |
|
|
setup_scripts(){ |
|
|
|
|
|
_msg "Download some utility scripts" |
|
|
_fetch_script \ |
|
|
_fetch_script \ |
|
|
https://gist.github.com/10sr/6852317/raw/colortable16.sh colortable16.sh |
|
|
https://gist.github.com/10sr/6852317/raw/colortable16.sh colortable16.sh |
|
|
_fetch_script \ |
|
|
_fetch_script \ |
|
|
https://gist.github.com/10sr/6852331/raw/256colors2.pl 256colors2.pl |
|
|
https://gist.github.com/10sr/6852331/raw/256colors2.pl 256colors2.pl |
|
|
|
|
|
_fetch_script \ |
|
|
|
|
|
https://github.com/icy/pacapt/raw/ng/pacapt pacapt |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
################################ |
|
|
################################ |
|
@@ -316,6 +349,7 @@ setup_darwin(){ |
|
|
|
|
|
|
|
|
setup_windirs(){ |
|
|
setup_windirs(){ |
|
|
$iswindows || return 0 |
|
|
$iswindows || return 0 |
|
|
|
|
|
_msg "Setup some directories for windows environment" |
|
|
|
|
|
|
|
|
if $iscygwin |
|
|
if $iscygwin |
|
|
then |
|
|
then |
|
@@ -325,6 +359,7 @@ setup_windirs(){ |
|
|
|
|
|
|
|
|
if test -n "$__winhome" -a -d "$__winhome" -a '!' -e "$HOME/.winhome" |
|
|
if test -n "$__winhome" -a -d "$__winhome" -a '!' -e "$HOME/.winhome" |
|
|
then |
|
|
then |
|
|
|
|
|
_msg Make symlink to "$__winhome" with name "$HOME/.winhome" |
|
|
ln -s "$__winhome" "$HOME/.winhome" |
|
|
ln -s "$__winhome" "$HOME/.winhome" |
|
|
fi |
|
|
fi |
|
|
} |
|
|
} |
|
@@ -333,12 +368,26 @@ setup_windirs(){ |
|
|
# setup dirs |
|
|
# setup dirs |
|
|
|
|
|
|
|
|
setup_dirs(){ |
|
|
setup_dirs(){ |
|
|
mkdir -p "$__homelocal" |
|
|
|
|
|
mkdir -p "$__homelocal/bin" |
|
|
|
|
|
mkdir -p "$__homevar" |
|
|
|
|
|
|
|
|
_msg Make some direcoties |
|
|
|
|
|
mkdir -vp "$__homelocal" |
|
|
|
|
|
mkdir -vp "$__homelocal/bin" |
|
|
|
|
|
mkdir -vp "$__homevar" |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#################################### |
|
|
|
|
|
# setup env |
|
|
|
|
|
# setup new environment with default options |
|
|
|
|
|
|
|
|
|
|
|
setup_env(){ |
|
|
|
|
|
setup_shrc_common |
|
|
|
|
|
setup_dirs |
|
|
|
|
|
setup_gitconf |
|
|
|
|
|
setup_tmux |
|
|
|
|
|
setup_scripts |
|
|
|
|
|
setup_dotfiles --git |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
######################### |
|
|
######################### |
|
|
# main |
|
|
# main |
|
@@ -357,9 +406,9 @@ main(){ |
|
|
_cmd=$1 |
|
|
_cmd=$1 |
|
|
shift |
|
|
shift |
|
|
|
|
|
|
|
|
set -x |
|
|
|
|
|
|
|
|
_msg Running setup_$_cmd |
|
|
setup_$_cmd "$@" |
|
|
setup_$_cmd "$@" |
|
|
set +x |
|
|
|
|
|
|
|
|
_msg Setup done |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
main "$@" |
|
|
main "$@" |