Skip to content
Snippets Groups Projects

Install Dotfiles

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Erik Hedenström

    Used to setup Dotfiles on the local machine.

    Edited
    install-dotfiles.sh 1.09 KiB
    #!/bin/sh
    set -e
    
    #
    # This script should be run via curl:
    #   sh -c "$(curl -fsSL https://gitlab.hedenstroem.com/-/snippets/22/raw/main/install-dotfiles.sh)"
    # or via wget:
    #   sh -c "$(wget -qO- https://gitlab.hedenstroem.com/-/snippets/22/raw/main/install-dotfiles.sh)"
    # or via fetch:
    #   sh -c "$(fetch -o - https://gitlab.hedenstroem.com/-/snippets/22/raw/main/install-dotfiles.sh)"
    #
    # As an alternative, you can first download the install script and run it afterwards:
    #   wget https://gitlab.hedenstroem.com/-/snippets/22/raw/main/install-dotfiles.sh
    #   sh install.sh
    
    USER=${USER:-$(id -u -n)}
    HOME="${HOME:-$(getent passwd $USER 2>/dev/null | cut -d: -f6)}"
    HOME="${HOME:-$(eval echo ~$USER)}"
    TIMESTAMP=$(date +%s)
    
    command_exists() {
        command -v "$@" >/dev/null 2>&1
    }
    
    setup_dotfiles() {
        if [ ! -d "${HOME}/.dotfiles" ]; then
            git clone --depth=1 git@gitlab.hedenstroem.com:erik/dotfiles.git "${HOME}/.dotfiles"
        fi
    }
    
    main() {
    
        command_exists git || {
            echo "git is not installed"
            exit 1
        }
    
        setup_dotfiles
    
        sh "${HOME}/.dotfiles/bootstrap.sh" 
    
    }
    
    main "$@"
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment