Initial commit

This commit is contained in:
Charles Gould 2019-06-22 11:05:10 -04:00
commit b9e9909aa8
16 changed files with 396 additions and 0 deletions

42
.bashrc Normal file
View File

@ -0,0 +1,42 @@
# 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"
export PATH="$PATH:/usr/bin"
export PATH="$PATH:/bin"
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
# Aliases
alias adventure='emacs -batch -l dunnet'
alias afk='pmset displaysleepnow'
alias dnsflush='sudo killall -HUP mDNSResponder'
alias java8="set -gx JAVA_HOME $JAVA_HOME_8"
alias java11="set -gx JAVA_HOME $JAVA_HOME_11"
alias md5sum="md5 -r $argv"
alias vi='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
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\] $ '

32
Brewfile Normal file
View File

@ -0,0 +1,32 @@
# Utilities
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/core"
brew "bash"
brew "bat"
brew "diff-so-fancy"
brew "diskus"
brew "dos2unix"
brew "fd"
brew "fish"
brew "fzf"
brew "git"
brew "htop"
brew "jq"
brew "neovim"
brew "ripgrep"
brew "telnet"
brew "tig"
brew "tldr"
brew "tree"
brew "watch"
brew "wget"
# JVM
tap "adoptopenjdk/openjdk"
cask "adoptopenjdk/openjdk/adoptopenjdk8"
cask "adoptopenjdk/openjdk/adoptopenjdk11"
brew "kotlin"
brew "maven"
brew "sbt"
brew "scala"

19
Brewfile.opt Normal file
View File

@ -0,0 +1,19 @@
# Docker
cask "docker"
cask "minikube"
brew "docker-completion"
brew "kubernetes-cli"
# Protobuf / gRPC
brew "grpc"
brew "grpcurl"
brew "protobuf"
brew "prototool"
# Graphics
brew "handbrake"
brew "imagemagick"
brew "scour"
brew "svg2png"
brew "termtosvg"
brew "triangle"

11
README.md Normal file
View File

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

34
fish/config.fish Normal file
View File

@ -0,0 +1,34 @@
# Disable the default shell greeting
set fish_greeting
# Disable the abbreviated directory format
set fish_prompt_pwd_dir_length 0
# Set global variables
set -x EDITOR nvim
set -x LANG en_US.UTF-8
set -x MANPAGER 'nvim +Man!'
# Java environment
set JAVA_HOME_8 (/usr/libexec/java_home -v 1.8)
set JAVA_HOME_11 (/usr/libexec/java_home -v 11)
set -x JAVA_HOME $JAVA_HOME_8
# Path
set --erase PATH
test -d $HOME/bin ; and set -x PATH $HOME/bin
test -d /usr/local/bin ; and set -x PATH $PATH /usr/local/bin
test -d /usr/bin ; and set -x PATH $PATH /usr/bin
test -d /bin ; and set -x PATH $PATH /bin
test -d /usr/local/sbin ; and set -x PATH $PATH /usr/local/sbin
test -d /usr/sbin ; and set -x PATH $PATH /usr/sbin
test -d /sbin ; and set -x PATH $PATH /sbin
# Aliases
alias adventure='emacs -batch -l dunnet'
alias afk='pmset displaysleepnow'
alias dnsflush='sudo killall -HUP mDNSResponder'
alias java8="set -gx JAVA_HOME $JAVA_HOME_8"
alias java11="set -gx JAVA_HOME $JAVA_HOME_11"
alias md5sum="md5 -r $argv"
alias vi='nvim'

34
fish/fish_variables Normal file
View File

@ -0,0 +1,34 @@
# This file contains fish universal variable definitions.
# VERSION: 3.0
SETUVAR __fish_init_2_39_8:\x1d
SETUVAR __fish_init_2_3_0:\x1d
SETUVAR __fish_init_3_x:\x1d
SETUVAR fish_color_autosuggestion:969896
SETUVAR fish_color_cancel:\x2dr
SETUVAR fish_color_command:c397d8
SETUVAR fish_color_comment:e7c547
SETUVAR fish_color_cwd:yellow
SETUVAR fish_color_cwd_root:red
SETUVAR fish_color_end:c397d8
SETUVAR fish_color_error:d54e53
SETUVAR fish_color_escape:00a6b2
SETUVAR fish_color_history_current:\x2d\x2dbold
SETUVAR fish_color_host:normal
SETUVAR fish_color_match:\x2d\x2dbackground\x3dbrblue
SETUVAR fish_color_normal:normal
SETUVAR fish_color_operator:00a6b2
SETUVAR fish_color_param:7aa6da
SETUVAR fish_color_quote:b9ca4a
SETUVAR fish_color_redirection:70c0b1
SETUVAR fish_color_search_match:bryellow\x1e\x2d\x2dbackground\x3dbrblack
SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack
SETUVAR fish_color_status:red
SETUVAR fish_color_user:brgreen
SETUVAR fish_color_valid_path:\x2d\x2dunderline
SETUVAR fish_greeting:\x1d
SETUVAR fish_key_bindings:fish_default_key_bindings
SETUVAR fish_pager_color_completion:normal
SETUVAR fish_pager_color_description:B3A06D\x1eyellow
SETUVAR fish_pager_color_prefix:white\x1e\x2d\x2dbold\x1e\x2d\x2dunderline
SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan
SETUVAR pure_version:2\x2e1\x2e5

View File

@ -0,0 +1,22 @@
function compress_video --argument-names srcfile
if test -z "$srcfile"
echo "Error: missing argument"
return 1
end
if not test -f "$srcfile"
echo "Error: not a regular file: $srcfile"
return 2
end
if not command --search --quiet HandBrakeCLI
echo "Error: HandBrakeCLI is required"
return 3
end
set --local dstdir (dirname $srcfile)/Compressed
set --local dstfile (dirname $srcfile)/Compressed/(basename $srcfile)
set --local preset 'Vimeo YouTube HQ 720p60'
mkdir -p $dstdir
HandBrakeCLI --preset $preset --input $srcfile --output $dstfile
end

View File

@ -0,0 +1,23 @@
function fish_prompt --description 'Write out the prompt'
# Save status code for previous command
set -l last_status $status
# Print working directory
set_color $fish_color_cwd
echo -n (prompt_pwd)
set_color normal
# Print Git information
fish_prompt_git_settings
printf '%s ' (__fish_git_prompt)
# Print status code for previous command, if nonzero
if not test $last_status -eq 0
set_color $fish_color_error
echo -n "[$last_status] "
set_color normal
end
# Print the final character (§)
echo -n "§ "
end

View File

@ -0,0 +1,38 @@
function fish_prompt_git_settings --description 'Configure the git prompt'
# Toggles
#if not set -q __fish_git_prompt_showcolorhints
# set -g __fish_git_prompt_showcolorhints 1
#end
if not set -q __fish_git_prompt_showdirtystate
set -g __fish_git_prompt_showdirtystate 1
end
if not set -q __fish_git_prompt_showstashstate
set -g __fish_git_prompt_showstashstate 1
end
if not set -q __fish_git_prompt_showuntrackedfiles
set -g __fish_git_prompt_showuntrackedfiles 1
end
if not set -q __fish_git_prompt_showupstream
set -g __fish_git_prompt_showupstream "none"
end
# Colors
if not set -q __fish_git_prompt_color_branch
set -g __fish_git_prompt_color_branch cyan
end
if not set -q __fish_git_prompt_color_dirtystate
set -g __fish_git_prompt_color_dirtystate cyan
end
if not set -q __fish_git_prompt_color_invalidstate
set -g __fish_git_prompt_color_invalidstate red
end
if not set -q __fish_git_prompt_color_stagedstate
set -g __fish_git_prompt_color_stagedstate cyan
end
if not set -q __fish_git_prompt_color_stashstate
set -g __fish_git_prompt_color_stashstate cyan
end
if not set -q __fish_git_prompt_color_untrackedfiles
set -g __fish_git_prompt_color_untrackedfiles cyan
end
end

5
fish/functions/hr.fish Normal file
View File

@ -0,0 +1,5 @@
function hr --description "Draw horizontal rule"
set --local char '─'
printf "%.s$char" (seq $COLUMNS)
echo
end

6
fish/functions/motd.fish Normal file
View File

@ -0,0 +1,6 @@
function motd
if not command --search --quiet fortune ; echo "Error: function requires fortune" ; return 1 ; end
if not command --search --quiet cowsay ; echo "Error: function requires cowsay" ; return 2 ; end
if not command --search --quiet lolcat ; echo "Error: function requires lolcat" ; return 3 ; end
fortune | cowsay | lolcat
end

View File

@ -0,0 +1,7 @@
function portlistener --argument-names port
if test -n "$port"
lsof -n -i :$port | grep LISTEN
else
lsof -n -i | grep LISTEN
end
end

56
git/config Normal file
View File

@ -0,0 +1,56 @@
[user]
name = Charles Gould
email = cgould@protonmail.com
[core]
autocrlf = input
editor = nvim
pager = diff-so-fancy | less --tabs=4 -RFX
[alias]
aliases = config --get-regexp alias
br = branch
co = checkout
df = diff
dc = diff --cached
dch = diff --cached HEAD~
lol = log --oneline --max-count=10 --decorate=no
ss = status --short
st = status --long
cp = cherry-pick
f = fetch --all --prune
pl = pull
ps = push
pu = push --set-upstream
pf = push --force
cm = commit -m
cv = commit -v
ca = commit --amend
can = commit --amend --no-edit
cand = commit --amend --no-edit --date=now
rbi = rebase --interactive
rh = reset HEAD
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow
frag = magenta bold
commit = yellow bold
old = red bold
new = green bold
whitespace = red reverse
[color "diff-highlight"]
oldNormal = red bold
oldHighlight = red bold 52
newNormal = green bold
newHighlight = green bold 22
[color "status"]
added = yellow
changed = green
untracked = cyan
[push]
default = current
[log]
date = human

12
install-symlinks.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
DOTFILES="$HOME/.dotfiles"
# Create required directories before making links
mkdir -p "$HOME/.config"
# Create symlinks, forcing updates
ln -Fsv "$DOTFILES/.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"

21
install.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
DOTFILES="$HOME/.dotfiles"
# Install plugin manager for Neovim, if it doesn't exist
VIM_PLUG_SRC="https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
VIM_PLUG_DST="$HOME/.local/share/nvim/site/autoload/plug.vim"
if [ ! -f "$VIM_PLUG_DST" ]; then
echo "Downloading plug.vim ..."
curl -fLo "$VIM_PLUG_DST" --create-dirs "$VIM_PLUG_SRC"
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
# Make fish the default shell
chsh -s /usr/local/bin/fish
# Install symlinks
"$DOTFILES/install-symlinks.sh"

34
nvim/init.vim Normal file
View File

@ -0,0 +1,34 @@
" use Vim mode instead of pure Vi, must be the first instruction
" wrapped in conditional to avoid side effects when already set
if &compatible
set nocompatible
endif
" configure plugins using vim-plug
" https://github.com/junegunn/vim-plug
call plug#begin('~/.cache/nvim/plugged')
Plug 'https://github.com/farmergreg/vim-lastplace' " intelligently reopen files at last edit position
Plug 'https://github.com/ntpeters/vim-better-whitespace' " highlights trailing whitespace, :StripWhitespace to remove
Plug 'https://github.com/tpope/vim-sensible' " defaults everyone can agree on
Plug 'https://github.com/vim-airline/vim-airline' " fancy statusline
call plug#end()
" display settings
set nonumber norelativenumber " show hybrid line numbers at startup
noremap <F2> :set number! relativenumber!<CR> " toggle line numbers
" write settings
set confirm " confirm :q in case of unsaved changes
" tab/space settings
set expandtab
set shiftwidth=2
set softtabstop=2
" clipboard settings
set clipboard=unnamedplus " enable copy/paste/yank to and from Vim/Neovim
" paste settings (in Neovim, use plain insert mode)
if !has('nvim')
set pastetoggle=<F3>
endif