Merge remote-tracking branch 'origin/master' into lappy

This commit is contained in:
Daniel Flanagan 2019-11-01 20:29:13 -05:00
commit 2a469bf340
69 changed files with 202 additions and 69 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ colors/gen/tmp
*.tmp
*.secret
/.repositories
/.env/

27
apps/htop/rc Normal file
View File

@ -0,0 +1,27 @@
# Beware! This file is rewritten by htop when settings are changed in the interface.
# The parser is also very primitive, and not human-friendly.
fields=0 48 17 18 38 39 40 2 46 47 49 1
sort_key=46
sort_direction=1
hide_threads=0
hide_kernel_threads=1
hide_userland_threads=1
shadow_other_users=0
show_thread_names=0
show_program_path=0
highlight_base_name=1
highlight_megabytes=1
highlight_threads=1
tree_view=1
header_margin=1
detailed_cpu_time=0
cpu_count_from_zero=0
update_process_names=0
account_guest_in_cpu_meter=0
color_scheme=0
delay=15
left_meters=LeftCPUs2 Memory Swap
left_meter_modes=1 1 1
right_meters=RightCPUs2 Tasks LoadAverage Uptime
right_meter_modes=1 2 2 2
vim_mode=1

View File

@ -108,7 +108,6 @@ Plug 'sheerun/vim-polyglot' " vim plugin loa
Plug 'leafo/moonscript-vim', {'for': ['moon', 'moonscript']} " moonscript language
Plug 'OmniSharp/omnisharp-vim', {'for': ['cs']} " C# language
Plug 'neoclide/coc.nvim', {'branch': 'release'} " language server completion
Plug 'neoclide/coc-json' " coc config ft
Plug 'JakeBecker/elixir-ls', {'for': ['elixir', 'eelixir'], 'do': { -> g:elixirls.compile() }}
Plug 'tpope/vim-dadbod' " databasing in vim
Plug 'lytedev/elm-vim' " elm lang

View File

@ -2,13 +2,18 @@
source "$DOTFILES_PATH/de/bar/bar.bash" --just-vars
LAUNCHER_FONT=$(xrdb -query | sed -ne 's/.*font:\s*xft:\([^: ]*\).*$/\1/p' | head -n 1)
LAUNCHER_FONT_SIZE=$(xrdb -query | sed -ne 's/.*font:\s*xft:.*=\([0-9]*\).*$/\1/p' | head -n 1)
HIGHLIGHT_COLOR=$(xrdb -query | sed -ne 's/.*color4*:\s*\(.*\)$/\1/p' | head -n 1)
HIGHLIGHT_FOREGROUND_COLOR=$(xrdb -query | sed -ne 's/.*background:\s*\(.*\)$/\1/p' | head -n 1)
BACKGROUND_COLOR=$(xrdb -query | sed -ne 's/.*background:\s*\(.*\)$/\1/p' | head -n 1)
FOREGROUND_COLOR=$(xrdb -query | sed -ne 's/.*foreground:\s*\(.*\)$/\1/p' | head -n 1)
GAP=$(xrdb -query | sed -ne 's/.*internalBorder:\s*\(.*\)$/\1/p' | head -n 1)
LAUNCHER_FONT="$BAR_FONT"
LAUNCHER_FONT_SIZE="$BAR_FONT_SIZE"
HIGHLIGHT_COLOR="$(xrq color4)"
HIGHLIGHT_FOREGROUND_COLOR="$(xrq background)"
BACKGROUND_COLOR=$(xrq background)
FOREGROUND_COLOR=$(xrq foreground)
GAP=$(xrq internalBorder)
# load a per-device config last so anything can be overridden
if [ -a "$EDFP/app-launcher" ]; then
source "$EDFP/app-launcher"
fi
rofi \
-combi-modi run,window \

67
bin/fsw Executable file
View File

@ -0,0 +1,67 @@
#!/usr/bin/env bash
_VERSION="0.2.0"
function help() {
I=" "
cat <<USAGE
fsw - run a command when a file is modified
Usage:
${I}fsw <command> [filter] [dirs...]
${I}command - the specified bash command to eval
${I}filter - an optional filename filter
${I}dirs - the directories to watch (defaults to current directory)
Advanced:
${I}Command Variables:
${I}${I}Your commands have runtime access to some variables associated with the
${I}${I}${I}inotifywait event enabling further extensibility:
${I}${I}+ FSW_FILENAME - the name of the file
${I}${I}+ FSW_DIR - the directory containing the file
${I}${I}+ FSW_PATH - the full relative path of the file
${I}${I}+ FSW_FILE_EVENTS - a comma-separated list of the inotify events
${I}Environment:
${I}${I}Some customization options exist using environment variables
${I}${I}${I}due to their uncommon usage.
${I}${I}+ FSW_EVENTS - the list of events to have inotifywait observe
References:
${I}+ Filter works with grep -P
${I}+ See inotifywait(1) for FSW_EVENTS options.
Examples:
${I}fsw 'make' '\.c$'
${I}fsw 'bash \$filename' '\.bash$'
${I}fsw 'mix test --failed' '.exs?$' lib test
${I}FSW_EVENTS=open,access fsw 'espeak "Intruder Alert!"' \\
${I}${I}${I}'.*' /etc/secrets \$HOME/.secrets
USAGE
}
if [[ $1 = '-h' ]] || [[ $1 = '--help' ]] || [[ -z $1 ]]; then
help
exit 0
fi
FSW_EVENTS="${FSW_EVENTS:-close_write}"
SHELL_COMMAND="${1}"; shift
FILTER="${1}"; shift
DIRS=("${1:-.}"); shift
while [[ ! -z $1 ]]; do
DIRS+=("$1"); shift
done
inotifywait -m -e "${FSW_EVENTS}" -r "${DIRS[@]}" 2>&1 \
| grep --line-buffered -v ' Beware: since -r was given, this may take a while!' \
| while read -r dir events filename; do
if [[ "$dir $events" = "Watches established." ]]; then
echo "Ready."
else
export FSW_FILENAME="$filename"
export FSW_DIR="$dir"
export FSW_PATH="$dir$filename"
export FSW_FILE_EVENTS="$events"
<<< "$FSW_PATH" grep -P "$FILTER" > /dev/null 2>&1 && eval "${SHELL_COMMAND}"
fi
done

3
bin/termrec Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
asciinema rec -i 2 --stdin

8
bin/xrq Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
if [[ -z $1 ]]; then
echo "No argument provided. Showing everything..." >&2
xrdb -query
fi
xrdb -query | sed -ne 's/.*'"$1"':\s*\(.*\)$/\1/p' | head -n 1

View File

@ -22,8 +22,9 @@ export BAR_VERTICAL_MARGIN=0
export POS_Y=0
# allow a per-device config to override options
if [ -f "$HOME/.env_bar" ]; then
source "$HOME/.env_bar"
echo "$EDFP"
if [ -f "$EDFP/bar" ]; then
source "$EDFP/bar"
fi
export MONITOR_WIDTH=$(xrandr | grep "^$BAR_MONITOR " | grep -Po ' \d+' | head -n 1)

View File

@ -8,10 +8,11 @@ BSPWM_MONITORS=$(bspc query -M | tac)
MONITOR_COUNT=$(echo "${BSPWM_MONITORS}" | wc -w | awk '{ printf $1 }')
NUM_DESKTOPS=${#DESKTOPS[@]}
PER_MONITOR=$((NUM_DESKTOPS / MONITOR_COUNT))
REVERSE_DESKTOP_ORDERING=0
# allow a per-device config to override options
if [ -f "$HOME/.env_bspwm" ]; then
source "$HOME/.env_bspwm"
if [ -f "$EDFP/bspwm" ]; then
source "$EDFP/bspwm"
fi
bspc config normal_border_color "$(xrdb -query | sed -ne 's/.*background:\s*//p')"
@ -42,7 +43,17 @@ for mon in ${BSPWM_MONITORS}; do
i=$((max + 1))
done
# allow a per-device config to override options
if [ -f "$HOME/.env_bspwm_after" ]; then
source "$HOME/.env_bspwm_after"
if [[ $REVERSE_DESKTOP_ORDERING -eq 1 ]]; then
prev_mon=
for mon in ${BSPWM_MONITORS}; do
if [[ ! -z $prev_mon ]]; then
bspc monitor "$mon" --swap "$prev_mon"
fi
prev_mon="$mon"
done
fi
# allow a per-device config to override options
if [ -f "$EDFP/bspwm-after" ]; then
source "$EDFP/bspwm-after"
fi

View File

@ -180,7 +180,7 @@ super + shift + Return
# spawn the app launcher
super + space
"$DOTFILES_PATH/scripts/bin/app-launcher" -modi run -show run
app-launcher -modi run -show run
# lock the desktop
super + ctrl + shift + l

View File

@ -1,7 +1,5 @@
#!/usr/bin/env bash
echo "xloadresources" >> "$HOME/.xstartup_log"
ENV_TYPE="${1}"
if [[ "$ENV_TYPE" = "auto" ]]; then
@ -10,23 +8,20 @@ if [[ "$ENV_TYPE" = "auto" ]]; then
else
ENV_TYPE=""
fi
echo "xloadresources auto env: $ENV_TYPE" >> "$HOME/.xstartup_log"
fi
if [[ -z "$ENV_TYPE" ]]; then
ENV_TYPE=""
else
ENV_TYPE=".${ENV_TYPE}"
ENV_TYPE="${ENV_TYPE}-"
fi
sysresources="/etc/X11/xinit/.Xresources"
sysmodmap="/etc/X11/xinit/.Xmodmap"
userresources="$HOME/.Xresources"
usercolors="$HOME/.Xresources.colors"
userenv="$HOME/.Xresources${ENV_TYPE}.env"
usermodmap="$HOME/.Xmodmap"
echo "userenv: $userenv" >> "$HOME/.xstartup_log"
usercolors="$DOTFILES_PATH/scripts/colors/xresources"
userenv="$EDFP/x/${ENV_TYPE}resources"
usermodmap="$EDFP/x/modmap"
if [ -f "$sysresources" ]; then
xrdb -merge "$sysresources" >/dev/null 2>&1
@ -45,7 +40,6 @@ if [ -f "$usercolors" ]; then
fi
if [ -f "$userenv" ]; then
echo "Merging env Xresources: $userenv" >> ~/.xstartup_log
xrdb -merge "$userenv" >/dev/null 2>&1
fi

View File

@ -1,7 +0,0 @@
#!/usr/bin/env bash
SHELL_COMMAND="${1}"
shift
inotifywait -q -m -e close_write -r "${@}" | while read -r _ _; do
eval "${SHELL_COMMAND}"
done

View File

@ -1,2 +0,0 @@
*
!.gitignore

39
setup
View File

@ -1,6 +1,10 @@
#!/usr/bin/env bash
# TODO: ascii art header
# TODO: ascii art header since I'm a leet haxx0r
dfp=$(cd "$(dirname "${BASH_SOURCE[0]}" )/" && pwd)
source "${dfp}/scripts/setup_helpers.bash"
edfp="${dfp}/.env"
INTERACTIVE=1
@ -13,9 +17,6 @@ while test $# -gt 0; do
esac
done
dfp=$(cd "$(dirname "${BASH_SOURCE[0]}" )/" && pwd)
source "${dfp}/scripts/setup_helpers.bash"
links=(
# desktop environment files
"$dfp/de/bspwm/bspwmrc" "$XDG_CONFIG_HOME/bspwm/bspwmrc"
@ -66,6 +67,9 @@ links=(
# document viewer
"$dfp/apps/zathura/" "$XDG_CONFIG_HOME/zathura"
# htop
"$dfp/apps/htop/rc" "$XDG_CONFIG_HOME/htop/htoprc"
# terminal emulator
"$dfp/apps/alacritty/" "$XDG_CONFIG_HOME/alacritty"
@ -98,6 +102,33 @@ links=(
"$dfp/shell/user-dirs" "$XDG_CONFIG_HOME/user-dirs.dirs"
)
mkdir -p "$edfp/"
if [[ ! -L "$HOME/.env" ]]; then
ln -s "$edfp/" "$HOME/.env/"
fi
mkdir -p "$edfp/bash.d/"
mkdir -p "$edfp/bin/"
mkdir -p "$edfp/x/"
mkdir -p "$HOME/.bin/"
touches=(
"$edfp/bash"
"$edfp/x/init"
"$edfp/x/profile"
"$edfp/x/resources"
"$edfp/vim"
"$edfp/bspwm"
"$edfp/bar"
"$edfp/app-launcher"
)
for t in "${touches[@]}"; do
touch "$t"
done
chmod 700 -R "$edfp"
chmod 700 -R "$HOME/.bin"
# TODO: pass interactive?
_dotfiles_setup_run_setup "$dfp/.agreed-to-erasing-files.lock" "${links[@]}"

View File

@ -5,6 +5,8 @@
# for making sure they're loaded!
export XDG_CONFIG_HOME="$HOME/.config"
export DOTFILES_PATH="$XDG_CONFIG_HOME/dotfiles"
export ENV_DOTFILES_PATH="$DOTFILES_PATH/.env"
export EDFP="$ENV_DOTFILES_PATH" # shorter alias
NICE_HOME="$HOME"
# TODO: better logic for auto-detecting alternative home directories?
@ -98,8 +100,8 @@ HISTIGNORE='ls:ll:la'
shopt -s cmdhist
# load a per-device config last so anything can be overridden
if [ -a "$HOME/.env_bashrc" ]; then
source "$HOME/.env_bashrc"
if [ -a "$EDFP/bash" ]; then
source "$EDFP/bash"
fi
# we assume the user uses "$HOME" to just store their mess of dotfiles and other

View File

@ -4,9 +4,9 @@ export GOPATH="$HOME/.go"
# PATH=$PATH:$APPENDED_PATH
export PATH=$PATH:"$GOPATH/bin"
export PATH=$PATH:"$DOTFILES_PATH/scripts/bin"
export PATH=$PATH:"$DOTFILES_PATH/scripts/env_bin"
export PATH=$PATH:"$HOME/.env_bin"
export PATH=$PATH:"$DOTFILES_PATH/bin"
export PATH=$PATH:"$EDFP/bin"
export PATH=$PATH:"$HOME/.bin"
export PATH=$PATH:"$HOME/.cargo/bin"
export PATH=$PATH:"$HOME/.yarn/bin"

View File

@ -1,43 +1,36 @@
#!/usr/bin/env bash
COLOR_RESET='\[\e[0m\]'
# TODO: if root, background instead?
PROMPT_SUCCESS_COLOR='\[\e[0;34m\]'
PROMPT_FAILURE_COLOR='\[\e[0;31m\]'
DIR_COLOR='\[\e[0;35m\]'
MAX_PATH_PIECE_CHARS=${BASH_PROMPT_MAX_PATH_PIECE_CHARS:-3}
# prompt rendering functions
preprocess_pwd() {
name="$PWD"
# if we're in the home directory, replace it with tilde
# [[ "$name" =~ ^"$NICE_HOME"(/|$) ]] && name="~${name#$NICE_HOME}"
[[ "$name" == "${NICE_HOME}" ]] && name="~"
# replace all non-basename parts of the PWD with only the first two letters
curdir=$(echo "$PWD" | sed -r 's|.*/(.+)$|\1|g')
name=$(echo "$name" | sed -r 's|/(...)[^/]*|/\1|g' | sed -r 's|(.*/)(.+)$|\1|g')
# if we're just in the home or root directory, don't show any path stuff
[[ "$name" == "/" ]] && curdir=""
[[ "$name" == "~" ]] && curdir=""
# return our transformed PWD
echo "$name$curdir"
p="$PWD"
[[ "$p" == "/" ]] && echo "/" && return 1
[[ "$p" == "${NICE_HOME}" ]] && echo "~" && return 0
# with ellipsis
#echo "$(<<< "$p" cut -c2- | awk '{split($0,p,"/");for(k in p){if(k==length(p)){printf "/%s",p[k]}else{if(length(p[k])>'"$((MAX_PATH_PIECE_CHARS+1))"'){printf "/%.'"$((MAX_PATH_PIECE_CHARS))"'s…",p[k]}else{printf "/%s",p[k]}}}}')"
# without ellipsis
echo "$(<<< "$p" cut -c2- | awk '{split($0,p,"/");for(k in p){if(k==length(p)){printf "/%s",p[k]}else{printf "/%.'"$MAX_PATH_PIECE_CHARS"'s",p[k]}}}')"
}
export -f "preprocess_pwd"
prompt_command_func()
{
# commit history to prevent data loss from edge cases
history -a
RET=$?
# set the color of the user and host based on the result of the previous
# command
if [ $RET -eq 0 ]; then
history -a # commit history to prevent data loss from edge cases
# set the color of user@host based on the result of the previous command
if [[ $RET -eq 0 ]]; then
STATUS_COLOR=$PROMPT_SUCCESS_COLOR
else
STATUS_COLOR=$PROMPT_FAILURE_COLOR
fi;
PS1="$STATUS_COLOR\u@\h$COLOR_RESET $DIR_COLOR$(eval "preprocess_pwd")$COLOR_RESET "
fi
PS1="$STATUS_COLOR\u@\h$COLOR_RESET $DIR_COLOR$(preprocess_pwd)$COLOR_RESET "
}
export -f "prompt_command_func"
export PROMPT_COMMAND="prompt_command_func"

View File

@ -43,7 +43,7 @@ bind-key j switch-client -p
bind-key h switch-client -p
bind-key k switch-client -n
bind-key l switch-client -n
bind s run "tmux new-window 'sh -ci tmuxswitcher'"
bind s run-shell "tmux new-window 'sh -c ~/.config/dotfiles/bin/tmuxswitcher'"
# reset the working directory of the current session
bind-key P attach-session -t . -c '#{pane_current_path}' \; display-message 'Reset session dir to #{pane_current_path}'
@ -57,9 +57,9 @@ set -g status-interval 5
set -g status-right-length 80
set -g status-right "#[fg=colour4]#W#[fg=default]#[bg=default] #H"
set -g status-left-length 200
set -g status-left "#[fg=colour7]#(~/.config/dotfiles/scripts/bin/tmux-session-list #S)"
set -g status-left "#[fg=colour7]#(~/.config/dotfiles/bin/tmux-session-list #S)"
bind-key O run-shell "~/.config/dotfiles/scripts/bin/tmux-save-buffer #S" \; display-message "Saved buffer to ~/<date>.tmux-buffer.log"
bind-key O run-shell "~/.config/dotfiles/bin/tmux-save-buffer #S" \; display-message "Saved buffer to ~/<date>.tmux-buffer.log"
# pane split line colors
set -g pane-active-border-style bg=black,fg=black