From a3ed4fbca611c3ef8ba210d4eaa007795ab01222 Mon Sep 17 00:00:00 2001 From: Alexander Hess Date: Tue, 9 Aug 2022 00:40:47 +0200 Subject: [PATCH] Add installation script - ~/.config/shell/init_dofiles.sh "installs" the provided dotfiles when sourced in an interactive shell - see the README.md for instructions --- .config/shell/init_dotfiles.sh | 46 ++++++++++++++++++++++++++++++++++ README.md | 23 +++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100755 .config/shell/init_dotfiles.sh diff --git a/.config/shell/init_dotfiles.sh b/.config/shell/init_dotfiles.sh new file mode 100755 index 0000000..f0c905f --- /dev/null +++ b/.config/shell/init_dotfiles.sh @@ -0,0 +1,46 @@ +# This file initializes the ~/.dotfiles as a bare repository + + +_command_exists() { + command -v "$1" 1>/dev/null 2>&1 +} + + +cd $HOME + + +# Get the latest ~/.dotfiles, possibly replacing the old ones +rm -rf "$HOME/.dotfiles" >/dev/null +git clone --bare https://git.webartifex.biz/alexander/dotfiles.git "$HOME/.dotfiles" + +# Distribute the dotfiles in $HOME +git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME checkout --force +git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME config --local status.showUntrackedFiles no + + +if _command_exists zsh; then + + # (Re-)Install oh-my-zsh + export ZSH="$HOME/.oh-my-zsh" + rm -rf $ZSH >/dev/null + # Let's NOT use the main repository but our personal fork + git clone --origin fork --branch forked https://git.webartifex.biz/alexander/oh-my-zsh.git $ZSH + cd $ZSH + git remote add origin https://github.com/ohmyzsh/ohmyzsh.git + cd $HOME + + # (Re-)Install zplug + export ZPLUG_HOME="$HOME/.zplug" + rm -rf $ZPLUG_HOME >/dev/null + git clone https://github.com/zplug/zplug $ZPLUG_HOME + + # Set up all the zplug plugins (-i so that the new ~/.zshrc is sourced) + zsh -i -c "zplug install" + +fi + + +echo +echo "Probably it's a good idea to restart the shell" +echo "Make sure to start bash or zsh as a login shell the next time" +echo diff --git a/README.md b/README.md index 7c57cc5..7d20b28 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,26 @@ # Dotfiles This repository contains useful (config) files that I use on my machines. + + +## Initialization + +On a freshly set up machine, run: + +```bash +curl https://gitlab.webartifex.biz/alexander/dotfiles/-/raw/main/.config/shell/init_dotfiles.sh \ + > /tmp/init_dotfiles.sh \ + && source /tmp/init_dotfiles.sh +``` + +This gives you a local copy of the latest version of this repository + (located in `~/.dotfiles`) + and initializes all the dotfiles provided here on the system. +Further, `zsh` is set up + with [`oh-my-zsh`](https://ohmyz.sh/) and [`zplug`](https://github.com/zplug/zplug) + if it is installed. + +**Note**: Log out and in again so that `bash` and `zsh` run as *login* shells. +Otherwise, `~/.profile` is probably *not* sourced. + +**Important**: Don't forget to back up your current dotfiles!