Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use LinuxBrew for Ubuntu 22 under WSL #27

Merged
merged 5 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ irm 'https://raw.githubusercontent.com/davidjenni/dotfiles/main/bootstrap.ps1' |
to bootstrap, run this in a default Terminal.app prompt:

````shell
curl -fsSL https://github.com/davidjenni/dotfiles/raw/master/bootstrap.sh | bash
curl -fsSL https://raw.githubusercontent.com/davidjenni/dotfiles/main/bootstrap.sh | bash
````

### Linux (Ubuntu/Debian)
Expand All @@ -29,5 +29,5 @@ still missing apps!
* open terminal/WSL:

````shell
curl -fsSL https://github.com/davidjenni/dotfiles/raw/master/bootstrap.sh | bash
curl -fsSL https://raw.githubusercontent.com/davidjenni/dotfiles/main/bootstrap.sh | bash
````
56 changes: 52 additions & 4 deletions bash/bash_aliases
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
function have {
hash "$1" >&/dev/null
}

alias cls='clear'
alias la='ls -AGF'
alias ls='ls -GF'
alias ll='ls -lGF'
if have lsd; then
alias la='lsd -a --group-directories-first'
alias ls='lsd --group-directories-first'
alias ll='lsd -l --group-directories-first'
else
alias la='ls -aGF'
alias ls='ls -GF'
alias ll='ls -lGF'
fi

if have bat; then
alias l='bat'
else
alias l='less'
fi

alias l='less'
export LESS="-c -i -x4 -J -w -M -r"
export VISUAL='nvim'
alias v='nvim'
Expand All @@ -23,3 +38,36 @@ if uname -r | grep -q "WSL"; then
alias ssh='ssh.exe'
alias ssh-add='ssh-add.exe'
fi

case `uname` in
'Darwin')
if [ -d "/opt/homebrew/bin" ] ; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
;;
'Linux')
if [ -d "/home/linuxbrew/.linuxbrew/bin" ] ; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
fi
;;
esac

if have starship; then
eval "$(starship init bash)"
fi
if have zoxide; then
eval "$(zoxide init bash)"
fi

case $- in
*i*) # interactive
if `shopt -q login_shell`; then
if have neofetch; then
neofetch
else
echo " $(uname -a)"
uptime
fi
fi
;;
esac
83 changes: 36 additions & 47 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/bin/bash
# install with:
# > curl -fsSL https://raw.githubusercontent.com/davidjenni/dotfiles/main/bootstrap.sh | bash

originGitHub='https://github.com/davidjenni/dotfiles.git'
dotPath=$HOME/dotfiles
scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

shopt -s nocasematch

Expand Down Expand Up @@ -65,9 +68,23 @@ function ensureBrew {
brew update
return
fi
case `uname` in
'Darwin')
xcode-select --install
;;
'Linux')
sudo apt-get install -y build-essential procps curl file git
;;
esac
echo "Installing Homebrew..."
# TODO: Test brew install
# https://brew.sh/
# https://docs.brew.sh/Homebrew-on-Linux
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
case `uname` in
'Darwin') eval "$(/opt/homebrew/bin/brew shellenv)" ;;
'Linux') eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" ;;
esac
# TODO: Test brew install
}

function cloneDotFiles {
Expand All @@ -84,7 +101,7 @@ function cloneDotFiles {
git clone $originGitHub $dotPath
}

function installAppsMacOS {
function installApps {
echo "Installing apps via brew..."
local var apps=(
7zip
Expand All @@ -105,54 +122,32 @@ function installAppsMacOS {
tmux
tre-command
tokei
wget
zoxide
xz
)

local var casks=(
alacritty
font-jetbrains-mono-nerd-font
)

local var _apps=${apps[*]}
echo ">> brew install $_apps"
brew install $_apps
if [ $? -ne 0 ] ; then
echo "Failed to install apps via brew"
exit 2
fi
brew tap homebrew/cask-fonts
local var _casks=${casks[*]}
echo ">> brew install --cask $_casks"
brew install --cask $_casks
exit $?
}

function installAppsLinux {
echo "Installing apps via apt..."
echo "NOTE: apps install for Linux is still very brittle and incomplete, YMMV !!!"
local var apps=(
bat
fd-find
fish
fzf
git
# git-delta # no apt installer for git-delta, but snap has it?
less
# lsd # no lsd installer for linux :-()
neovim
ripgrep
tmux
wget
xz-utils
)

# curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
# curl -sS https://starship.rs/install.sh | sh

local var _apps=${apps[*]}
# echo ">> sudo apt install $_apps"
sudo apt install $_apps
exit $?
local var _casks=${casks[*]}
case `uname` in
'Darwin')
brew tap homebrew/cask-fonts
echo ">> brew install --cask $_casks"
brew install --cask $_casks
;;
esac
return $?
}

function copyFile {
Expand All @@ -164,7 +159,7 @@ function copyFile {
fi
targetDir=$(dirname $target)
mkdir -p $targetDir
sourceFile=$dotPath/$sourceRelPath
sourceFile=$scriptDir/$sourceRelPath
echo " $sourceFile -> $target"
cp $sourceFile $target
}
Expand All @@ -177,15 +172,15 @@ function copyDir {
rm -rf $targetDir >&/dev/null
fi
mkdir -p $targetDir
sourceDir=$dotPath/$sourceRelPath
sourceDir=$scriptDir/$sourceRelPath
echo " $sourceDir -> $targetDir"
cp -R $sourceDir/* $targetDir
}

function setupShellEnv {
echo "Setting up shell environment..."
ensureGitNames noprompt
writeGitConfig $dotPath/gitconfig.ini
writeGitConfig $scriptDir/gitconfig.ini

local configDir=$HOME/.config
if [ ! -d "$configDir" ] ; then
Expand Down Expand Up @@ -266,17 +261,11 @@ main() {
;;
"setup")
echo "Setting up..."
case `uname` in
'Darwin') ensureBrew ;;
'Linux') ;;
esac
ensureBrew
main apps
;;
"apps")
case `uname` in
'Darwin') installAppsMacOS ;;
'Linux') installAppsLinux ;;
esac
installApps
if [ $? -ne 0 ] ; then
exit $?
fi
Expand All @@ -302,5 +291,5 @@ main() {
echo "Done."
}

echo "Starting bootstrap.sh..."
echo "Starting bootstrap.sh (in $scriptDir with working dir: $(pwd))..."
main $*
6 changes: 4 additions & 2 deletions fish/config.fish
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ set fish_greeting ""

switch (uname)
case Linux
if test -d /home/linuxbrew/.linuxbrew/bin
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
end
if test -x /usr/bin/lesspipe.sh
set -x LESSOPEN "|lesspipe.sh %s"
end
case Darwin
if test -d /opt/homebrew/bin
fish_add_path /opt/homebrew/bin
set -g fish_user_paths "(brew --prefix)/bin" $fish_user_paths
eval "$(brew shellenv)"
if test -x (brew --prefix)/bin/lesspipe.sh
set -x LESSOPEN "|lesspipe.sh %s"
end
Expand Down