diff --git a/README.md b/README.md index 67fe7a7..64a5fdf 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ # dotfiles -Collection of tracked dotfiles and supporting install scripts. +Collection of experimental dotfiles and supporting install scripts. Tested on and compatible with: * Ubuntu 18.04 * Ubuntu 20.04 ## Install - wget https://raw.githubusercontent.com/andrejusk/dotfiles/master/bootstrap.sh -qO - | bash + wget https://raw.githubusercontent.com/andrejusk/dotfiles/master/setup -qO - | perl ## Stack @@ -20,8 +20,10 @@ Tools: * docker (+ docker-compose) * firebase * terraform +* screenfetch Languages: +* elm * java * node (+ yarn, nvm) * python (+ poetry, pyenv) diff --git a/bootstrap.sh b/bootstrap.sh deleted file mode 100755 index 45e8421..0000000 --- a/bootstrap.sh +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env bash -set -o pipefail - -# Script to set up dependencies and run installer -# -# 1. Install git using `apt-get` if not already in $PATH -# * see $FAST_MODE -# -# 2. Create workspace folder if one doesn't already exist -# * see $WORKSPACE -# -# 3. Pull latest target repository using `git` -# * see $REPOSITORY, $FAST_MODE -# -# 4. Run installer -# * see $INSTALLER -# -# -# Usage -# -# i. Run script -# -# * $ ./bootstrap.sh -# * $ /path/to/bootstrap.sh -# -# ii. Download and run script -# -# a. non-interactively -# * $ wget path.to/bootstrap.sh -qO - | bash -# -# b. interactively -# * $ bash <(wget -qO- path.to/bootstrap.sh) -# -# -# Configuration -# -# $REPOSITORY - GitHub repository to clone -# @default "andrejusk/dotfiles" -# -# $WORKSPACE - parent directory to clone repository into -# @default "$HOME/workspace" -# -# $INSTALLER - installer file name -# @default "install.sh" -# -# $FAST_MODE - whether to skip git (and speed up install steps) -# @defualt false - -echo "setting up..." - -# Inistialise variables -if [ -z "$WORKSPACE" ]; then - export WORKSPACE="$HOME/workspace" -fi -export dotfiles_dir="$WORKSPACE/dotfiles" -echo "using dir: $dotfiles_dir" - -if [ -z "$REPOSITORY" ]; then - export REPOSITORY="andrejusk/dotfiles" -fi -repository_url="git@github.com:$REPOSITORY.git" -echo "using repository: $repository_url" - -if [ -z "$INSTALLER" ]; then - INSTALLER="install.sh"; -fi -installer="$dotfiles_dir/$INSTALLER" -echo "using installer: $installer" - -# Ensure repo is available -if [ -z "$FAST_MODE" ]; then - export FAST_MODE=false - - if ! [ -x "$(command -v git)" ]; then - echo "installing git..." - sudo apt-get update -qqy - sudo apt-get install git -qqy - fi - - echo "pulling latest..." - if ! [ -d "$dotfiles_dir" ]; then - mkdir -p "$dotfiles_dir" - git clone -q "$repository_url" "$dotfiles_dir" - else - git --git-dir="$dotfiles_dir/.git" fetch -q - git --git-dir="$dotfiles_dir/.git" rebase -q --autostash FETCH_HEAD - fi - -fi - -# Run installer -echo "installing..." -source "$dotfiles_dir/bash/.profile" -chmod +x "$installer" -"$installer" - -echo "done!" diff --git a/install/16-vim.sh b/install/16-vim.sh index 9930723..a278ab2 100755 --- a/install/16-vim.sh +++ b/install/16-vim.sh @@ -8,16 +8,15 @@ echo "vim dotfiles are linked" mkdir -p "$XDG_DATA_HOME/nvim/backup" plug_target="$XDG_DATA_HOME/nvim/site/autoload/plug.vim" if [ ! -f $plug_target ]; then - sh -c 'curl -fLo "$plug_target" --create-dirs \ - https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' + curl -fLo "$plug_target" --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim fi -nvim -E PlugInstall -c q -nvim -E PluginInstall -c q pip3 install neovim node --version yarn global add neovim sudo gem install neovim +nvim -E PlugInstall -c q +nvim -E PluginInstall -c q nvim --version diff --git a/setup.pl b/setup.pl new file mode 100755 index 0000000..585d964 --- /dev/null +++ b/setup.pl @@ -0,0 +1,43 @@ +#!/usr/bin/env perl +use strict; +use warnings; + + +use Archive::Tar; +use File::Temp (); +use IPC::System::Simple qw(capture); +use LWP::Simple; + + +print "Setting up...\n"; + +# GitHub repository to clone +my $author = $ENV{'DOTFILES_AUTHOR'} // 'andrejusk'; +my $repository = $ENV{'DOTFILES_REPOSITORY'} // 'dotfiles'; +my $branch = $ENV{'DOTFILES_BRANCH'} // 'master'; +print "Using repository $author/$repository at $branch\n"; + +# Installer filename +my $installer = $ENV{'DOTFILES_INSTALLER'} // 'install.sh'; +print "Using installer $installer\n"; + +# Download repo +my $repository_url = "https://github.com/$author/$repository/archive/$branch.tar.gz"; +my $temp_handle = File::Temp->new(); +my $repository_temp = $temp_handle->filename; +print "Downloading $repository_url to $repository_temp\n"; +getstore($repository_url, $repository_temp); + +# Extract repo +my $temp_dir = File::Temp->newdir(); +my $tar = Archive::Tar->new; +print "Extracting $repository_temp to $temp_dir\n"; +$tar->read($repository_temp); +$tar->setcwd($temp_dir); +$tar->extract(); + +# Install repo +my $installer_path = "$temp_dir/$repository-$branch/$installer"; +print 'Running installer <' . $installer_path . ">\n"; +my $output = capture([0,1,2], $^X, $installer_path); +print $output;