aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xinstall42
-rw-r--r--utils/inst22
2 files changed, 28 insertions, 36 deletions
diff --git a/install b/install
index 66d4251..8b33e60 100755
--- a/install
+++ b/install
@@ -10,40 +10,34 @@ git submodule update --init || (echo "Submodule update failed!"; exit 5)
#################################################################################
source private/install # private files, sorry but some privacy is required.
-read -p "Install Bashrc? (Y/n) "
-if [[ $REPLY =~ ^[Yy]?$ ]]; then
+if ask "Install Bashrc?"; then
inst bashrc ~/.bashrc
inst shellrc ~/.shellrc
inst profile ~/.profile
fi
-read -p "Install zshrc? (Y/n) "
-if [[ $REPLY =~ ^[Yy]?$ ]]; then
+if ask "Install zshrc?"; then
inst zshrc ~/.zshrc
inst shellrc ~/.shellrc
inst zprofile ~/.zprofile
fi
-read -p "Install GIT configuration? (Y/n) "
-if [[ $REPLY =~ ^[Yy]?$ ]]; then
+if ask "Install GIT configuration?"; then
inst gitconfig ~/.gitconfig
inst local/git-prompt.sh ~/.local/
fi
-read -p "Install configurations for various utility tools? (Y/n) "
-if [[ $REPLY =~ ^[Yy]?$ ]]; then
+if ask "Install configurations for various utility tools?"; then
inst screenrc ~/.screenrc
fi
-read -p "Install user services? (Y/n) "
-if [[ $REPLY =~ ^[Yy]?$ ]]; then
+if ask "Install user services?"; then
inst local/sbin/user-service.sh ~/.local/sbin/user-service.sh
inst service/ ~/.service/
fi
-read -p "Install VIM scripts? (Y/n) "
YCM_PATH=~/.vim/bundle/YouCompleteMe
-if [[ $REPLY =~ ^[Yy]?$ ]]; then
+if ask "Install VIM scripts?"; then
# See if we have anything different from what we have in repository
YCM_REV="$(cd $YCM_PATH && git --work-tree=. diff --exit-code -s && echo y)"
inst vimrc ~/.vimrc
@@ -59,16 +53,14 @@ if [[ $REPLY =~ ^[Yy]?$ ]]; then
fi
fi
-read -p "Install ranger configuration? (Y/n) "
-if [[ $REPLY =~ ^[Yy]?$ ]]; then
+if ask "Install ranger configuration?"; then
mkdir -p ~/.config/ranger
inst config/ranger/rc.conf ~/.config/ranger/rc.conf
inst config/ranger/rifle.conf ~/.config/ranger/rifle.conf
inst config/ranger/scope.sh ~/.config/ranger/scope.sh
fi
-read -p "Install email synchronization? (Y/n) "
-if [[ $REPLY =~ ^[Yy]?$ ]]; then
+if ask "Install email synchronization?"; then
inst local/bin/email-unread ~/.local/bin/email-unread
inst local/sbin/newmail-notify ~/.local/sbin/newmail-notify
inst_email_sync
@@ -77,8 +69,7 @@ if [[ $REPLY =~ ^[Yy]?$ ]]; then
# inst config/offlineimap/ ~/.config/offlineimap
fi
-read -p "Install mutt configuration? (Y/n) "
-if [[ $REPLY =~ ^[Yy]?$ ]]; then
+if ask "Install mutt configuration?"; then
inst urlview ~/.urlview
inst mutt/mailcap ~/.mutt/
inst mutt/gpg.rc ~/.mutt/
@@ -90,8 +81,7 @@ if [[ $REPLY =~ ^[Yy]?$ ]]; then
mkdir -p ~/.cache/mutt # directory for temporaly html files
fi
-read -p "Install i3 configuration and related tools? (Y/n) "
-if [[ $REPLY =~ ^[Yy]?$ ]]; then
+if ask "Install i3 configuration and related tools?"; then
inst xinitrc ~/.xinitrc
inst Xresources ~/.Xresources
inst config/i3/ ~/.config/i3
@@ -110,23 +100,19 @@ if [[ $REPLY =~ ^[Yy]?$ ]]; then
inst config/Trolltech.conf ~/.config/Trolltech.conf
fi
-read -p "Install Conkeror configuration? (Y/n) "
-if [[ $REPLY =~ ^[Yy]?$ ]]; then
+if ask "Install Conkeror configuration?"; then
inst conkerorrc ~/.conkerorrc
inst conkeror/ ~/.conkeror
fi
-read -p "Install MPD configuration? (Y/n) "
-if [[ $REPLY =~ ^[Yy]?$ ]]; then
+if ask "Install MPD configuration?"; then
inst config/mpd/ ~/.config/mpd
fi
-read -p "Install backup script? (Y/n) "
-if [[ $REPLY =~ ^[Yy]?$ ]]; then
+if ask "Install backup script?"; then
inst local/bin/system-backup ~/.local/bin/system-backup
fi
-read -p "Install lxc-net script? (Y/n) "
-if [[ $REPLY =~ ^[Yy]?$ ]]; then
+if ask "Install lxc-net script?"; then
inst local/bin/lxc-net ~/.local/bin/lxc-net
fi
diff --git a/utils/inst b/utils/inst
index b9da163..7fd648f 100644
--- a/utils/inst
+++ b/utils/inst
@@ -1,6 +1,12 @@
# Functions used for interactive installation of new changes to running system
# vim: ft=sh
+ask() {
+ echo -ne "\e[1;34m$1 (Y/n) \e[0m"
+ read
+ return [[ $REPLY =~ ^[Yy]?$ ]]
+}
+
dodiff() {
if [ -d "$2" ]; then
# If we just copying some file to directory
@@ -9,7 +15,7 @@ dodiff() {
OUT=$2
fi
if ! [ -f "$OUT" ]; then
- echo "Not installed: $1 => $OUT"
+ echo -e "\e[1;33mNot installed:\e[0m $1 => $OUT"
read -p "Install? (Y/n) "
if [[ $REPLY =~ ^[Yy]?$ ]]; then
doinst "$1" "$OUT"
@@ -17,7 +23,7 @@ dodiff() {
return
fi
if cmp "$1" "$OUT" >/dev/null; then
- echo "No difference detected: $OUT"
+ echo -e "\e[1;32mNo difference detected:\e[0m $OUT"
return
fi
vimdiff "$1" "$OUT"
@@ -31,7 +37,7 @@ checkdiff() {
# directory than it have to have trailing slash to ensure that no
# additional directory is created.
if ! echo "$1" | grep -qE '/$'; then
- echo ERROR: Directory without trailing slash detected: $1
+ echo -e "\e[1;31mERROR: Directory without trailing slash detected:\e[0m $1"
exit 1
fi
# Got trough all files ignoring git repositories
@@ -43,7 +49,7 @@ checkdiff() {
for d in `find "$1" -type d -print -exec test -e '{}'/.git \; -prune`; do
D="${d#$1}"
if [ ! -d "$2/$D" ]; then
- echo "Directory not installed: $1/$D => $2/$D"
+ echo -e "\e[1;33mDirectory not installed:\e[0m $1/$D => $2/$D"
read -p "Install? (Y/n) "
if [[ $REPLY =~ ^[Yy]?$ ]]; then
doinst "$1/$D/" "$2/$D"
@@ -57,9 +63,9 @@ checkdiff() {
cd "$2/$G"
# Check if we have any change at all
if git --work-tree=. diff --exit-code -s; then
- echo "No difference detected in git: $2/$G"
+ echo -e "\e[1;32mNo difference detected in git:\e[0m $2/$G"
else
- echo "Checkout of git repository: $2/$G"
+ echo -e "\e[0;32mCheckout of git repository:\e[0m $2/$G"
# Checkout all files to HEAD
git --work-tree=. checkout -f HEAD
# Update all submodules
@@ -77,14 +83,14 @@ checkdiff() {
# commands not on deployed tree but on tree in this repository, so we need specify
# work tree on command line every time we want target deployed work tree.
doinst() {
- echo rsync -rlpt $1 $2
+ echo -e "\e[1;34mrsync -rlpt $1 $2\e[0m"
rsync -rlpt $1 $2
# Now edit all .git files in target directory
for g in `find "$2" -name '.git' -type f`; do
if ! grep -q "gitdir: " "$g"; then
continue # Probably not a git repository or who knows.
fi
- echo "Pointing git repository $g to this repository"
+ echo -e "\e[1;34mPointing git repository $g to this repository\e[0m"
echo gitdir: $PWD/.git`sed "s/^gitdir: [./]*git//" "$g"` > "$g"
done
}