Changed some things and added autocomplete feature

main
Thomas Ba. 9 years ago
parent 1985534f69
commit 9b55535f3d

@ -29,7 +29,7 @@ function cecho() {
fi fi
} }
function backup_file() { function backup_file() {
file="${1/\~/$HOME}" file="${1}"
if [ -e "$file" ] ; then if [ -e "$file" ] ; then
if [ -d "$file" ] ; then if [ -d "$file" ] ; then
cecho purple " - Moving old '$file' directory ..." cecho purple " - Moving old '$file' directory ..."
@ -43,14 +43,14 @@ function backup_file() {
} }
function symlink() { function symlink() {
# usage: symlink <name> <destination> # usage: symlink <name> <destination>
name="${1/\~/$HOME}" name="${1}"
cecho green " + Creating symlink to '$2' ..." cecho green " + Creating symlink to '$2' ..."
ln -s $2 $name ln -s "$2" "$name"
} }
function ask() { function ask() {
cecho ask " ? Install file '$1'? [N/y] " cecho ask " ? Install file '$1'? [N/y] "
read c read -r c
if [ "$c" == "y" -o "$c" == "Y" ] ; then if [ "$c" == "y" ] || [ "$c" == "Y" ] ; then
backup_file "$1" backup_file "$1"
symlink "$1" "$2" symlink "$1" "$2"
fi fi
@ -61,10 +61,10 @@ function ask() {
####### #######
cecho cyan "Installing vim config ..." cecho cyan "Installing vim config ..."
backup_file "~/.vim" backup_file "$HOME/.vim"
backup_file "~/.vimrc" backup_file "$HOME/.vimrc"
symlink "~/.vim" "${MY_PATH}/vim" symlink "$HOME/.vim" "${MY_PATH}/vim"
symlink "~/.vimrc" "${MY_PATH}/vim/vimrc" symlink "$HOME/.vimrc" "${MY_PATH}/vim/vimrc"
if command -v vim >/dev/null 2>&1; then if command -v vim >/dev/null 2>&1; then
cecho green " + Installing plugins ... " cecho green " + Installing plugins ... "
vim -nE +"colorscheme default" +PluginInstall +qall vim -nE +"colorscheme default" +PluginInstall +qall
@ -79,31 +79,31 @@ fi
####### #######
cecho cyan "Installing zsh config" cecho cyan "Installing zsh config"
backup_file "~/.zsh" backup_file "$HOME/.zsh"
backup_file "~/.zshrc" backup_file "$HOME/.zshrc"
# check if grml is installed # check if grml is installed
grep grml\.org /etc/zsh/zshrc > /dev/null grep grml\.org /etc/zsh/zshrc > /dev/null
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
echo " + Installing grml ..." echo " + Installing grml ..."
wget -O ~/.zshrc http://git.grml.org/f/grml-etc-core/etc/zsh/zshrc wget -O "$HOME/.zshrc" http://git.grml.org/f/grml-etc-core/etc/zsh/zshrc
cecho yellow " ! You might wanna install grml-zsh-config using your packet manager" cecho yellow " ! You might wanna install grml-zsh-config using your packet manager"
cecho yellow " ! and remove the .zshrc file in your home directory. " cecho yellow " ! and remove the .zshrc file in your home directory. "
else else
cecho green " . grml-zsh-config is already installed :-)" cecho green " . grml-zsh-config is already installed :-)"
# prevent configuration dialog # prevent configuration dialog
if [ ! -f "~/.zshrc" ] ; then if [ ! -f "$HOME/.zshrc" ] ; then
cecho green " + Creating empty .zshrc" cecho green " + Creating empty .zshrc"
echo "# empty" > ~/.zshrc echo "# empty" > "$HOME/.zshrc"
fi fi
fi fi
symlink "~/.zsh" "${MY_PATH}/zsh" symlink "$HOME/.zsh" "${MY_PATH}/zsh"
symlink "~/.zshrc.local" "${MY_PATH}/zsh/zshrc.local" symlink "$HOME/.zshrc.local" "${MY_PATH}/zsh/zshrc.local"
while [ ! "$MTYPE" == "PC" -a ! "$MTYPE" == "SERVER" ] ; do while [ ! "$MTYPE" == "PC" ] && [ ! "$MTYPE" == "SERVER" ] ; do
cecho ask " ? Is this a server of a PC? [s|p] > " cecho ask " ? Is this a server of a PC? [s|p] > "
read mt read -r mt
case $mt in case $mt in
[Ss]*) [Ss]*)
MTYPE="SERVER";; MTYPE="SERVER";;
@ -113,6 +113,9 @@ while [ ! "$MTYPE" == "PC" -a ! "$MTYPE" == "SERVER" ] ; do
cecho red " ! Invalid input";; cecho red " ! Invalid input";;
esac esac
done done
git clone git://github.com/zsh-users/zsh-autosuggestions "$HOME/.zsh/zsh-autosuggestions"
cecho green " + Creating .zshrc.pre ... " cecho green " + Creating .zshrc.pre ... "
( (
echo "# Path to your oh-my-zsh configuration." echo "# Path to your oh-my-zsh configuration."
@ -121,15 +124,15 @@ cecho green " + Creating .zshrc.pre ... "
echo "export DEFAULT_USER=\"\$(whoami)\"" echo "export DEFAULT_USER=\"\$(whoami)\""
echo "# machine type" echo "# machine type"
echo "export MTYPE=\"$MTYPE\"" echo "export MTYPE=\"$MTYPE\""
) > ~/.zshrc.pre ) > "$HOME/.zshrc.pre"
######## ########
# tmux # # tmux #
######## ########
cecho cyan "Installing tmux config" cecho cyan "Installing tmux config"
backup_file "~/.tmux.conf" backup_file "$HOME/.tmux.conf"
symlink "~/.tmux.conf" "${MY_PATH}/tmux/tmux.conf" symlink "$HOME/.tmux.conf" "${MY_PATH}/tmux/tmux.conf"
###### ######
# i3 # # i3 #
@ -137,11 +140,11 @@ symlink "~/.tmux.conf" "${MY_PATH}/tmux/tmux.conf"
cecho cyan "Installing i3 config" cecho cyan "Installing i3 config"
if [ "$MTYPE" == "PC" ] ; then if [ "$MTYPE" == "PC" ] ; then
backup_file "~/.i3" backup_file "$HOME/.i3"
backup_file "~/.i3status.conf" backup_file "$HOME/.i3status.conf"
symlink "~/.i3" "${MY_PATH}/i3" symlink "$HOME/.i3" "${MY_PATH}/i3"
symlink "~/.i3status.conf" "${MY_PATH}/i3/i3status.conf" symlink "$HOME/.i3status.conf" "${MY_PATH}/i3/i3status.conf"
ask "~/.xprofile" "${MY_PATH}/xprofile" ask "$HOME/.xprofile" "${MY_PATH}/xprofile"
else else
cecho yellow " > skipping " cecho yellow " > skipping "
fi fi
@ -152,13 +155,13 @@ fi
cecho cyan "Symlinking other stuff ..." cecho cyan "Symlinking other stuff ..."
if [ "$MTYPE" == "PC" ] ; then if [ "$MTYPE" == "PC" ] ; then
ask "~/.xinitrc" "${MY_PATH}/xinitrc" ask "$HOME/.xinitrc" "${MY_PATH}/xinitrc"
ask "~/.pentadactylrc" "${MY_PATH}/pentadactylrc" ask "$HOME/.pentadactylrc" "${MY_PATH}/pentadactylrc"
ask "~/.gitconfig" "${MY_PATH}/gitconfig" ask "$HOME/.gitconfig" "${MY_PATH}/gitconfig"
else else
backup_file "~/.gitconfig" backup_file "$HOME/.gitconfig"
symlink "~/.gitconfig" "${MY_PATH}/gitconfig" symlink "$HOME/.gitconfig" "${MY_PATH}/gitconfig"
fi fi
backup_file "~/bin" backup_file "$HOME/bin"
symlink "~/bin" "${MY_PATH}/bin" symlink "$HOME/bin" "${MY_PATH}/bin"

Loading…
Cancel
Save