install: fixes for Linux install

This commit is contained in:
Charles Gould 2020-03-13 05:39:00 +00:00
parent a4e57fe5c7
commit 386c9ac793
15 changed files with 71 additions and 55 deletions

View File

@ -7,5 +7,5 @@ My personal configuration files.
1. Clone this repository into `~/dotfiles` 1. Clone this repository into `~/dotfiles`
2. Install [Homebrew](https://brew.sh/): `./install-brew.sh` 2. Install [Homebrew](https://brew.sh/): `./install-brew.sh`
3. Install tools: `brew bundle install --file=brew/Brewfile` 3. Install tools: `brew bundle install --file=brew/Brewfile`
4. (Optional) Install more tools: `brew bundle install --file=brew/Brewfile.opt` 4. (Optional) Install more tools: `brew bundle install --file=brew/opt/Brewfile`
5. Install everything else, including symlinks: `./install.sh` 5. Install everything else, including symlinks: `./install.sh`

View File

@ -1,8 +1,3 @@
# Set global variables
export EDITOR=nvim
export LANG='en_US.UTF-8'
export MANPAGER='nvim +Man!'
# Path # Path
export PATH="$HOME/bin" export PATH="$HOME/bin"
export PATH="$PATH:/usr/local/bin" export PATH="$PATH:/usr/local/bin"
@ -12,22 +7,6 @@ export PATH="$PATH:/usr/local/sbin"
export PATH="$PATH:/usr/sbin" export PATH="$PATH:/usr/sbin"
export PATH="$PATH:/sbin" export PATH="$PATH:/sbin"
# Java environment
export JAVA_HOME_8=$(/usr/libexec/java_home -v 1.8)
export JAVA_HOME_11=$(/usr/libexec/java_home -v 11)
export JAVA_HOME=$JAVA_HOME_8
export SBT_OPTS='-Dsbt.supershell=false'
# Aliases
alias adventure='emacs -batch -l dunnet'
alias afk='pmset displaysleepnow'
alias dnsflush='sudo killall -HUP mDNSResponder'
alias java8="export JAVA_HOME=$JAVA_HOME_8"
alias java11="export JAVA_HOME=$JAVA_HOME_11"
alias md5sum="md5 -r"
alias vi='nvim'
alias vim='nvim'
# Do not save lines which begin with a space character # Do not save lines which begin with a space character
# Do not save lines which match the previous history entry # Do not save lines which match the previous history entry
# Remove from history all previous lines matching the current line # Remove from history all previous lines matching the current line
@ -35,10 +14,3 @@ export HISTCONTROL=ignoreboth:erasedups
# Completions # Completions
[ -f /usr/local/etc/bash_completion ] && source /usr/local/etc/bash_completion [ -f /usr/local/etc/bash_completion ] && source /usr/local/etc/bash_completion
# Colorized prompt with Git information
export CLICOLOR=1
GIT_PS1_SHOWDIRTYSTATE=true
GIT_PS1_SHOWSTASHSTATE=true
GIT_PS1_SHOWUNTRACKEDFILES=true
export PS1='\[\e[33m\]\w\[\e[36m\]$(__git_ps1)\[\e[m\] $ '

1
brew/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
Brewfile.lock.json

View File

@ -4,23 +4,29 @@ tap "homebrew/cask"
tap "homebrew/core" tap "homebrew/core"
brew "bash" brew "bash"
brew "bat" brew "bat"
brew "cowsay"
brew "diff-so-fancy" brew "diff-so-fancy"
brew "diskus" brew "diskus"
brew "dos2unix" brew "dos2unix"
brew "fd" brew "fd"
brew "fish" brew "fish"
brew "fortune"
brew "fzf" brew "fzf"
brew "gawk"
brew "git" brew "git"
brew "htop" brew "htop"
brew "jq" brew "jq"
brew "most"
brew "neovim" brew "neovim"
brew "pup"
brew "python"
brew "ripgrep" brew "ripgrep"
brew "telnet"
brew "tig" brew "tig"
brew "tldr" brew "tldr"
brew "tree" brew "tree"
brew "watch" brew "watch"
brew "wget" brew "wget"
brew "yq"
# JVM # JVM
tap "adoptopenjdk/openjdk" tap "adoptopenjdk/openjdk"

View File

@ -1,3 +1,7 @@
# Fonts
tap "homebrew/cask-fonts"
brew "font-source-code-pro"
# Docker # Docker
cask "docker" cask "docker"
cask "minikube" cask "minikube"

View File

@ -7,11 +7,17 @@ set fish_prompt_pwd_dir_length 0
# Environment variables # Environment variables
set -x EDITOR nvim set -x EDITOR nvim
set -x LANG en_US.UTF-8 set -x LANG en_US.UTF-8
set -x MANPAGER 'nvim +Man!'
set -x JAVA_HOME (/usr/libexec/java_home -v 1.8)
set -x SBT_OPTS '-Dsbt.supershell=false' set -x SBT_OPTS '-Dsbt.supershell=false'
set -x ENHANCD_DISABLE_DOT 1 set -x ENHANCD_DISABLE_DOT 1
if command -q most
set -x MANPAGER most
end
if test -x /usr/libexec/java_home
set -x JAVA_HOME (/usr/libexec/java_home -v 1.8)
end
# FZF (https://github.com/junegunn/fzf) # FZF (https://github.com/junegunn/fzf)
set -x FZF_DEFAULT_OPTS "--height=40% --layout=reverse --multi" set -x FZF_DEFAULT_OPTS "--height=40% --layout=reverse --multi"
set -x FZF_DEFAULT_COMMAND "fd --type=file" set -x FZF_DEFAULT_COMMAND "fd --type=file"
@ -25,7 +31,7 @@ set -x FZF_ALT_C_OPTS "--preview 'tree -C {} | head -200'"
set -g __fish_git_prompt_showdirtystate 1 set -g __fish_git_prompt_showdirtystate 1
set -g __fish_git_prompt_showstashstate 1 set -g __fish_git_prompt_showstashstate 1
set -g __fish_git_prompt_showuntrackedfiles 1 set -g __fish_git_prompt_showuntrackedfiles 1
set -g __fish_git_prompt_showupstream 'informative' set -g __fish_git_prompt_showupstream informative
set -g __fish_git_prompt_char_upstream_ahead '↑' set -g __fish_git_prompt_char_upstream_ahead '↑'
set -g __fish_git_prompt_char_upstream_behind '↓' set -g __fish_git_prompt_char_upstream_behind '↓'
set -g __fish_git_prompt_char_upstream_prefix ' ' set -g __fish_git_prompt_char_upstream_prefix ' '
@ -67,3 +73,8 @@ if not functions -q fisher
echo "Installing fish-shell packages..." echo "Installing fish-shell packages..."
fish -c fisher fish -c fisher
end end
# Homebrew package manager
if test -x /home/linuxbrew/.linuxbrew/bin/brew
eval (/home/linuxbrew/.linuxbrew/bin/brew shellenv)
end

View File

@ -1,7 +1,7 @@
function battery function battery
# Only works on Mac # Only works on Mac
if test (uname -s) != Darwin if test (uname -s) != Darwin
echo "Unsupported OS: "(uname -s) echo "Unsupported kernel: "(uname -s)
return 1 return 1
end end

View File

@ -3,6 +3,6 @@ function dns_flush
case Darwin case Darwin
sudo killall -HUP mDNSResponder sudo killall -HUP mDNSResponder
case '*' case '*'
echo "Unsupported OS: "(uname -s) echo "Unsupported kernel: "(uname -s)
end end
end end

View File

@ -0,0 +1,11 @@
function fish_right_prompt --description 'Write out the right prompt'
# If we're running via SSH, change the host color
set --local color_host $fish_color_host
if set -q SSH_TTY
set color_host $fish_color_host_remote
end
set_color $color_host
echo -n $hostname
set_color normal
end

View File

@ -1,7 +1,7 @@
function jvm --argument-names __jvm_version function jvm --argument-names __jvm_version
# Only works on Mac # Only works on Mac
if test (uname -s) != Darwin if test (uname -s) != Darwin
echo "Unsupported OS: "(uname -s) echo "Unsupported kernel: "(uname -s)
return 1 return 1
end end
@ -12,7 +12,7 @@ function jvm --argument-names __jvm_version
return 2 return 2
end end
set --local __jvm_homedir (/usr/libexec/java_home -v $__jvm_version) set --local __jvm_homedir (/usr/libexec/java_home --version $__jvm_version)
if test $status -eq 0 if test $status -eq 0
echo "Setting JAVA_HOME to $__jvm_homedir" echo "Setting JAVA_HOME to $__jvm_homedir"

View File

@ -4,7 +4,7 @@ function motd --description "Message of the day!"
if contains -- '--chuck-norris' $argv if contains -- '--chuck-norris' $argv
set daily_msg (curl -s 'https://api.chucknorris.io/jokes/random' | jq --raw-output '.value') set daily_msg (curl -s 'https://api.chucknorris.io/jokes/random' | jq --raw-output '.value')
else else
set daily_msg (fortune) set daily_msg (fortune -a)
end end
cowsay $daily_msg cowsay $daily_msg

View File

@ -7,7 +7,7 @@ function video_compress --argument-names srcfile
echo "Error: not a regular file: $srcfile" echo "Error: not a regular file: $srcfile"
return 2 return 2
end end
if not command --search --quiet HandBrakeCLI if not command -q HandBrakeCLI
echo "Error: HandBrakeCLI is required" echo "Error: HandBrakeCLI is required"
return 3 return 3
end end

View File

@ -6,16 +6,12 @@ if [ -x "$(command -v brew)" ]; then
exit 0 exit 0
fi fi
# Install Homebrew by OS # Install Homebrew
case "$(uname -s)" in case "$(uname -s)" in
Darwin) Darwin|Linux)
echo "Mac OS" /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
;;
Linux)
echo "Linux"
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install)"
;; ;;
*) *)
echo "Unsupported OS: $(uname -s)" echo "Unsupported kernel: $(uname -s)"
;;
esac esac

View File

@ -2,11 +2,25 @@
DOTFILES="$HOME/dotfiles" DOTFILES="$HOME/dotfiles"
backup_existing() {
if [ -e "$1" ]; then
if [ ! -L "$1" ]; then
mv -v "$1" "$1.backup"
fi
fi
}
# Create required directories before making links # Create required directories before making links
mkdir -p "$HOME/.config" mkdir -p "$HOME/.config"
# Backup configs that are not already symlinked
backup_existing "$HOME/.bashrc"
backup_existing "$HOME/.config/fish"
backup_existing "$HOME/.config/nvim"
backup_existing "$HOME/.config/git"
# Create symlinks, forcing updates # Create symlinks, forcing updates
ln -Fsv "$DOTFILES/bash/.bashrc" "$HOME/.bashrc" # Bash does not support XDG config ln -fsv "$DOTFILES/bash/.bashrc" "$HOME/.bashrc" # Bash does not support XDG config
ln -Fsv "$DOTFILES/fish" "$HOME/.config" ln -fsv "$DOTFILES/fish" "$HOME/.config"
ln -Fsv "$DOTFILES/nvim" "$HOME/.config" ln -fsv "$DOTFILES/nvim" "$HOME/.config"
ln -Fsv "$DOTFILES/git" "$HOME/.config" ln -fsv "$DOTFILES/git" "$HOME/.config"

View File

@ -11,11 +11,12 @@ if [ ! -f "$VIM_PLUG_DST" ]; then
fi fi
# Add Homebrew-managed shells to system list # Add Homebrew-managed shells to system list
grep -q /usr/local/bin/bash /etc/shells || echo /usr/local/bin/bash | sudo tee -a /etc/shells BREW_PREFIX=`brew --prefix`
grep -q /usr/local/bin/fish /etc/shells || echo /usr/local/bin/fish | sudo tee -a /etc/shells grep -q "$BREW_PREFIX/bin/bash" /etc/shells || echo "$BREW_PREFIX/bin/bash" | sudo tee -a /etc/shells
grep -q "$BREW_PREFIX/bin/fish" /etc/shells || echo "$BREW_PREFIX/bin/fish" | sudo tee -a /etc/shells
# Make fish the default shell # Make fish the default shell
sudo chsh -s /usr/local/bin/fish `whoami` sudo chsh -s "$BREW_PREFIX/bin/fish" `whoami`
# Install symlinks # Install symlinks
"$DOTFILES/install-symlinks.sh" "$DOTFILES/install-symlinks.sh"