diff --git a/README.md b/README.md index 25afac7..6dec855 100644 --- a/README.md +++ b/README.md @@ -7,5 +7,5 @@ My personal configuration files. 1. Clone this repository into `~/dotfiles` 2. Install [Homebrew](https://brew.sh/): `./install-brew.sh` 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` diff --git a/bash/.bashrc b/bash/.bashrc index 168fdb2..c5cd457 100644 --- a/bash/.bashrc +++ b/bash/.bashrc @@ -1,8 +1,3 @@ -# Set global variables -export EDITOR=nvim -export LANG='en_US.UTF-8' -export MANPAGER='nvim +Man!' - # Path export PATH="$HOME/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:/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 match the previous history entry # Remove from history all previous lines matching the current line @@ -35,10 +14,3 @@ export HISTCONTROL=ignoreboth:erasedups # Completions [ -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\] $ ' diff --git a/brew/.gitignore b/brew/.gitignore new file mode 100644 index 0000000..55acb54 --- /dev/null +++ b/brew/.gitignore @@ -0,0 +1 @@ +Brewfile.lock.json diff --git a/brew/Brewfile b/brew/Brewfile index c5dbfa6..1bd8528 100644 --- a/brew/Brewfile +++ b/brew/Brewfile @@ -4,23 +4,29 @@ tap "homebrew/cask" tap "homebrew/core" brew "bash" brew "bat" +brew "cowsay" brew "diff-so-fancy" brew "diskus" brew "dos2unix" brew "fd" brew "fish" +brew "fortune" brew "fzf" +brew "gawk" brew "git" brew "htop" brew "jq" +brew "most" brew "neovim" +brew "pup" +brew "python" brew "ripgrep" -brew "telnet" brew "tig" brew "tldr" brew "tree" brew "watch" brew "wget" +brew "yq" # JVM tap "adoptopenjdk/openjdk" diff --git a/brew/Brewfile.opt b/brew/opt/Brewfile similarity index 81% rename from brew/Brewfile.opt rename to brew/opt/Brewfile index e44782c..29f8d1b 100644 --- a/brew/Brewfile.opt +++ b/brew/opt/Brewfile @@ -1,3 +1,7 @@ +# Fonts +tap "homebrew/cask-fonts" +brew "font-source-code-pro" + # Docker cask "docker" cask "minikube" diff --git a/fish/config.fish b/fish/config.fish index 5e47d05..fbdb74f 100644 --- a/fish/config.fish +++ b/fish/config.fish @@ -7,11 +7,17 @@ set fish_prompt_pwd_dir_length 0 # Environment variables set -x EDITOR nvim 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 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) set -x FZF_DEFAULT_OPTS "--height=40% --layout=reverse --multi" 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_showstashstate 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_behind '↓' set -g __fish_git_prompt_char_upstream_prefix ' ' @@ -67,3 +73,8 @@ if not functions -q fisher echo "Installing fish-shell packages..." fish -c fisher end + +# Homebrew package manager +if test -x /home/linuxbrew/.linuxbrew/bin/brew + eval (/home/linuxbrew/.linuxbrew/bin/brew shellenv) +end diff --git a/fish/functions/battery.fish b/fish/functions/battery.fish index 8bf1f4d..f40e896 100644 --- a/fish/functions/battery.fish +++ b/fish/functions/battery.fish @@ -1,7 +1,7 @@ function battery # Only works on Mac if test (uname -s) != Darwin - echo "Unsupported OS: "(uname -s) + echo "Unsupported kernel: "(uname -s) return 1 end diff --git a/fish/functions/dns_flush.fish b/fish/functions/dns_flush.fish index 8a1f1c6..94247e2 100644 --- a/fish/functions/dns_flush.fish +++ b/fish/functions/dns_flush.fish @@ -3,6 +3,6 @@ function dns_flush case Darwin sudo killall -HUP mDNSResponder case '*' - echo "Unsupported OS: "(uname -s) + echo "Unsupported kernel: "(uname -s) end end diff --git a/fish/functions/fish_right_prompt.fish b/fish/functions/fish_right_prompt.fish new file mode 100644 index 0000000..f1e1f23 --- /dev/null +++ b/fish/functions/fish_right_prompt.fish @@ -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 diff --git a/fish/functions/jvm.fish b/fish/functions/jvm.fish index c09a47f..e07c5af 100644 --- a/fish/functions/jvm.fish +++ b/fish/functions/jvm.fish @@ -1,7 +1,7 @@ function jvm --argument-names __jvm_version # Only works on Mac if test (uname -s) != Darwin - echo "Unsupported OS: "(uname -s) + echo "Unsupported kernel: "(uname -s) return 1 end @@ -12,7 +12,7 @@ function jvm --argument-names __jvm_version return 2 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 echo "Setting JAVA_HOME to $__jvm_homedir" diff --git a/fish/functions/motd.fish b/fish/functions/motd.fish index 1f6c45d..3f9dd57 100644 --- a/fish/functions/motd.fish +++ b/fish/functions/motd.fish @@ -4,7 +4,7 @@ function motd --description "Message of the day!" if contains -- '--chuck-norris' $argv set daily_msg (curl -s 'https://api.chucknorris.io/jokes/random' | jq --raw-output '.value') else - set daily_msg (fortune) + set daily_msg (fortune -a) end cowsay $daily_msg diff --git a/fish/functions/video_compress.fish b/fish/functions/video_compress.fish index 0690104..2f5be74 100644 --- a/fish/functions/video_compress.fish +++ b/fish/functions/video_compress.fish @@ -7,7 +7,7 @@ function video_compress --argument-names srcfile echo "Error: not a regular file: $srcfile" return 2 end - if not command --search --quiet HandBrakeCLI + if not command -q HandBrakeCLI echo "Error: HandBrakeCLI is required" return 3 end diff --git a/install-brew.sh b/install-brew.sh index 460d730..6211984 100755 --- a/install-brew.sh +++ b/install-brew.sh @@ -6,16 +6,12 @@ if [ -x "$(command -v brew)" ]; then exit 0 fi -# Install Homebrew by OS +# Install Homebrew case "$(uname -s)" in - Darwin) - echo "Mac OS" - 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)" + Darwin|Linux) + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" ;; *) - echo "Unsupported OS: $(uname -s)" + echo "Unsupported kernel: $(uname -s)" + ;; esac diff --git a/install-symlinks.sh b/install-symlinks.sh index 70461fb..428341e 100755 --- a/install-symlinks.sh +++ b/install-symlinks.sh @@ -2,11 +2,25 @@ 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 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 -ln -Fsv "$DOTFILES/bash/.bashrc" "$HOME/.bashrc" # Bash does not support XDG config -ln -Fsv "$DOTFILES/fish" "$HOME/.config" -ln -Fsv "$DOTFILES/nvim" "$HOME/.config" -ln -Fsv "$DOTFILES/git" "$HOME/.config" +ln -fsv "$DOTFILES/bash/.bashrc" "$HOME/.bashrc" # Bash does not support XDG config +ln -fsv "$DOTFILES/fish" "$HOME/.config" +ln -fsv "$DOTFILES/nvim" "$HOME/.config" +ln -fsv "$DOTFILES/git" "$HOME/.config" diff --git a/install.sh b/install.sh index 7260b99..51cb25c 100755 --- a/install.sh +++ b/install.sh @@ -11,11 +11,12 @@ if [ ! -f "$VIM_PLUG_DST" ]; then fi # 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 -grep -q /usr/local/bin/fish /etc/shells || echo /usr/local/bin/fish | sudo tee -a /etc/shells +BREW_PREFIX=`brew --prefix` +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 -sudo chsh -s /usr/local/bin/fish `whoami` +sudo chsh -s "$BREW_PREFIX/bin/fish" `whoami` # Install symlinks "$DOTFILES/install-symlinks.sh"