From 1ae7fdd4395adcebd8a2c4a88ed53e5987e0c55b Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Wed, 30 Oct 2019 08:52:55 -0500 Subject: [PATCH 1/9] Tons of cleanup and improve extensibility and consistency --- .gitignore | 1 + apps/neovim/plugins.vim | 1 - {scripts/bin => bin}/N | 0 {scripts/bin => bin}/app-launcher | 19 +++++++---- {scripts/bin => bin}/archupdate | 0 {scripts/bin => bin}/b | 0 {scripts/bin => bin}/bspwm_load_state | 0 {scripts/bin => bin}/bspwm_load_state_canvas | 0 {scripts/bin => bin}/bspwm_load_state_rules | 0 {scripts/bin => bin}/bspwm_save_state | 0 {scripts/bin => bin}/calc | 0 {scripts/bin => bin}/cdp | 0 {scripts/bin => bin}/check_domain | 0 {scripts/bin => bin}/clipshot | 0 {scripts/bin => bin}/countdown | 0 {scripts/bin => bin}/d_mosquitto | 0 {scripts/bin => bin}/d_rabbitmq | 0 {scripts/bin => bin}/disable-laptop-keyboard | 0 {scripts/bin => bin}/editscrot | 0 {scripts/bin => bin}/enable-laptop-keyboard | 0 {scripts/bin => bin}/ezln | 0 {scripts/bin => bin}/fsw | 0 {scripts/bin => bin}/fswi | 0 {scripts/bin => bin}/gcwd | 0 {scripts/bin => bin}/git-authors | 0 {scripts/bin => bin}/grb | 0 {scripts/bin => bin}/keyrepeat | 0 {scripts/bin => bin}/murxvt | 0 {scripts/bin => bin}/n | 0 {scripts/bin => bin}/nd | 0 {scripts/bin => bin}/nf | 0 {scripts/bin => bin}/nsync | 0 {scripts/bin => bin}/pbin | 0 {scripts/bin => bin}/qute | 0 {scripts/bin => bin}/restartbar | 0 {scripts/bin => bin}/s | 0 {scripts/bin => bin}/scn | 0 {scripts/bin => bin}/screenshot | 0 {scripts/bin => bin}/scrup | 0 {scripts/bin => bin}/scwd | 0 {scripts/bin => bin}/setbg | 0 {scripts/bin => bin}/startbar | 0 {scripts/bin => bin}/stopbar | 0 {scripts/bin => bin}/sw | 0 {scripts/bin => bin}/term | 0 {scripts/bin => bin}/tmux-save-buffer | 0 {scripts/bin => bin}/tmux-session-list | 0 {scripts/bin => bin}/tmuxswitcher | 0 {scripts/bin => bin}/undock | 0 {scripts/bin => bin}/upload | 0 {scripts/bin => bin}/vman | 0 {scripts/bin => bin}/wifi-list | 0 {scripts/bin => bin}/workdock | 0 {scripts/bin => bin}/wres1080 | 0 {scripts/bin => bin}/wsteam | 0 bin/xrq | 8 +++++ de/bar/bar.bash | 5 +-- de/bspwm/config | 21 +++++++++--- de/sxhkd/sxhkdrc | 2 +- de/x/loadresources | 14 +++----- scripts/env_bin/.gitignore | 2 -- setup | 36 +++++++++++++++++--- shell/bash/bashrc | 6 ++-- shell/bash/paths | 6 ++-- 64 files changed, 84 insertions(+), 37 deletions(-) rename {scripts/bin => bin}/N (100%) rename {scripts/bin => bin}/app-launcher (55%) rename {scripts/bin => bin}/archupdate (100%) rename {scripts/bin => bin}/b (100%) rename {scripts/bin => bin}/bspwm_load_state (100%) rename {scripts/bin => bin}/bspwm_load_state_canvas (100%) rename {scripts/bin => bin}/bspwm_load_state_rules (100%) rename {scripts/bin => bin}/bspwm_save_state (100%) rename {scripts/bin => bin}/calc (100%) rename {scripts/bin => bin}/cdp (100%) rename {scripts/bin => bin}/check_domain (100%) rename {scripts/bin => bin}/clipshot (100%) rename {scripts/bin => bin}/countdown (100%) rename {scripts/bin => bin}/d_mosquitto (100%) rename {scripts/bin => bin}/d_rabbitmq (100%) rename {scripts/bin => bin}/disable-laptop-keyboard (100%) rename {scripts/bin => bin}/editscrot (100%) rename {scripts/bin => bin}/enable-laptop-keyboard (100%) rename {scripts/bin => bin}/ezln (100%) rename {scripts/bin => bin}/fsw (100%) rename {scripts/bin => bin}/fswi (100%) rename {scripts/bin => bin}/gcwd (100%) rename {scripts/bin => bin}/git-authors (100%) rename {scripts/bin => bin}/grb (100%) rename {scripts/bin => bin}/keyrepeat (100%) rename {scripts/bin => bin}/murxvt (100%) rename {scripts/bin => bin}/n (100%) rename {scripts/bin => bin}/nd (100%) rename {scripts/bin => bin}/nf (100%) rename {scripts/bin => bin}/nsync (100%) rename {scripts/bin => bin}/pbin (100%) rename {scripts/bin => bin}/qute (100%) rename {scripts/bin => bin}/restartbar (100%) rename {scripts/bin => bin}/s (100%) rename {scripts/bin => bin}/scn (100%) rename {scripts/bin => bin}/screenshot (100%) rename {scripts/bin => bin}/scrup (100%) rename {scripts/bin => bin}/scwd (100%) rename {scripts/bin => bin}/setbg (100%) rename {scripts/bin => bin}/startbar (100%) rename {scripts/bin => bin}/stopbar (100%) rename {scripts/bin => bin}/sw (100%) rename {scripts/bin => bin}/term (100%) rename {scripts/bin => bin}/tmux-save-buffer (100%) rename {scripts/bin => bin}/tmux-session-list (100%) rename {scripts/bin => bin}/tmuxswitcher (100%) rename {scripts/bin => bin}/undock (100%) rename {scripts/bin => bin}/upload (100%) rename {scripts/bin => bin}/vman (100%) rename {scripts/bin => bin}/wifi-list (100%) rename {scripts/bin => bin}/workdock (100%) rename {scripts/bin => bin}/wres1080 (100%) rename {scripts/bin => bin}/wsteam (100%) create mode 100755 bin/xrq delete mode 100644 scripts/env_bin/.gitignore diff --git a/.gitignore b/.gitignore index e32d9bb..02979f9 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ colors/gen/tmp *.tmp *.secret /.repositories +/.env/ diff --git a/apps/neovim/plugins.vim b/apps/neovim/plugins.vim index d516611..55d21de 100644 --- a/apps/neovim/plugins.vim +++ b/apps/neovim/plugins.vim @@ -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 diff --git a/scripts/bin/N b/bin/N similarity index 100% rename from scripts/bin/N rename to bin/N diff --git a/scripts/bin/app-launcher b/bin/app-launcher similarity index 55% rename from scripts/bin/app-launcher rename to bin/app-launcher index e626c5e..a089126 100755 --- a/scripts/bin/app-launcher +++ b/bin/app-launcher @@ -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 \ diff --git a/scripts/bin/archupdate b/bin/archupdate similarity index 100% rename from scripts/bin/archupdate rename to bin/archupdate diff --git a/scripts/bin/b b/bin/b similarity index 100% rename from scripts/bin/b rename to bin/b diff --git a/scripts/bin/bspwm_load_state b/bin/bspwm_load_state similarity index 100% rename from scripts/bin/bspwm_load_state rename to bin/bspwm_load_state diff --git a/scripts/bin/bspwm_load_state_canvas b/bin/bspwm_load_state_canvas similarity index 100% rename from scripts/bin/bspwm_load_state_canvas rename to bin/bspwm_load_state_canvas diff --git a/scripts/bin/bspwm_load_state_rules b/bin/bspwm_load_state_rules similarity index 100% rename from scripts/bin/bspwm_load_state_rules rename to bin/bspwm_load_state_rules diff --git a/scripts/bin/bspwm_save_state b/bin/bspwm_save_state similarity index 100% rename from scripts/bin/bspwm_save_state rename to bin/bspwm_save_state diff --git a/scripts/bin/calc b/bin/calc similarity index 100% rename from scripts/bin/calc rename to bin/calc diff --git a/scripts/bin/cdp b/bin/cdp similarity index 100% rename from scripts/bin/cdp rename to bin/cdp diff --git a/scripts/bin/check_domain b/bin/check_domain similarity index 100% rename from scripts/bin/check_domain rename to bin/check_domain diff --git a/scripts/bin/clipshot b/bin/clipshot similarity index 100% rename from scripts/bin/clipshot rename to bin/clipshot diff --git a/scripts/bin/countdown b/bin/countdown similarity index 100% rename from scripts/bin/countdown rename to bin/countdown diff --git a/scripts/bin/d_mosquitto b/bin/d_mosquitto similarity index 100% rename from scripts/bin/d_mosquitto rename to bin/d_mosquitto diff --git a/scripts/bin/d_rabbitmq b/bin/d_rabbitmq similarity index 100% rename from scripts/bin/d_rabbitmq rename to bin/d_rabbitmq diff --git a/scripts/bin/disable-laptop-keyboard b/bin/disable-laptop-keyboard similarity index 100% rename from scripts/bin/disable-laptop-keyboard rename to bin/disable-laptop-keyboard diff --git a/scripts/bin/editscrot b/bin/editscrot similarity index 100% rename from scripts/bin/editscrot rename to bin/editscrot diff --git a/scripts/bin/enable-laptop-keyboard b/bin/enable-laptop-keyboard similarity index 100% rename from scripts/bin/enable-laptop-keyboard rename to bin/enable-laptop-keyboard diff --git a/scripts/bin/ezln b/bin/ezln similarity index 100% rename from scripts/bin/ezln rename to bin/ezln diff --git a/scripts/bin/fsw b/bin/fsw similarity index 100% rename from scripts/bin/fsw rename to bin/fsw diff --git a/scripts/bin/fswi b/bin/fswi similarity index 100% rename from scripts/bin/fswi rename to bin/fswi diff --git a/scripts/bin/gcwd b/bin/gcwd similarity index 100% rename from scripts/bin/gcwd rename to bin/gcwd diff --git a/scripts/bin/git-authors b/bin/git-authors similarity index 100% rename from scripts/bin/git-authors rename to bin/git-authors diff --git a/scripts/bin/grb b/bin/grb similarity index 100% rename from scripts/bin/grb rename to bin/grb diff --git a/scripts/bin/keyrepeat b/bin/keyrepeat similarity index 100% rename from scripts/bin/keyrepeat rename to bin/keyrepeat diff --git a/scripts/bin/murxvt b/bin/murxvt similarity index 100% rename from scripts/bin/murxvt rename to bin/murxvt diff --git a/scripts/bin/n b/bin/n similarity index 100% rename from scripts/bin/n rename to bin/n diff --git a/scripts/bin/nd b/bin/nd similarity index 100% rename from scripts/bin/nd rename to bin/nd diff --git a/scripts/bin/nf b/bin/nf similarity index 100% rename from scripts/bin/nf rename to bin/nf diff --git a/scripts/bin/nsync b/bin/nsync similarity index 100% rename from scripts/bin/nsync rename to bin/nsync diff --git a/scripts/bin/pbin b/bin/pbin similarity index 100% rename from scripts/bin/pbin rename to bin/pbin diff --git a/scripts/bin/qute b/bin/qute similarity index 100% rename from scripts/bin/qute rename to bin/qute diff --git a/scripts/bin/restartbar b/bin/restartbar similarity index 100% rename from scripts/bin/restartbar rename to bin/restartbar diff --git a/scripts/bin/s b/bin/s similarity index 100% rename from scripts/bin/s rename to bin/s diff --git a/scripts/bin/scn b/bin/scn similarity index 100% rename from scripts/bin/scn rename to bin/scn diff --git a/scripts/bin/screenshot b/bin/screenshot similarity index 100% rename from scripts/bin/screenshot rename to bin/screenshot diff --git a/scripts/bin/scrup b/bin/scrup similarity index 100% rename from scripts/bin/scrup rename to bin/scrup diff --git a/scripts/bin/scwd b/bin/scwd similarity index 100% rename from scripts/bin/scwd rename to bin/scwd diff --git a/scripts/bin/setbg b/bin/setbg similarity index 100% rename from scripts/bin/setbg rename to bin/setbg diff --git a/scripts/bin/startbar b/bin/startbar similarity index 100% rename from scripts/bin/startbar rename to bin/startbar diff --git a/scripts/bin/stopbar b/bin/stopbar similarity index 100% rename from scripts/bin/stopbar rename to bin/stopbar diff --git a/scripts/bin/sw b/bin/sw similarity index 100% rename from scripts/bin/sw rename to bin/sw diff --git a/scripts/bin/term b/bin/term similarity index 100% rename from scripts/bin/term rename to bin/term diff --git a/scripts/bin/tmux-save-buffer b/bin/tmux-save-buffer similarity index 100% rename from scripts/bin/tmux-save-buffer rename to bin/tmux-save-buffer diff --git a/scripts/bin/tmux-session-list b/bin/tmux-session-list similarity index 100% rename from scripts/bin/tmux-session-list rename to bin/tmux-session-list diff --git a/scripts/bin/tmuxswitcher b/bin/tmuxswitcher similarity index 100% rename from scripts/bin/tmuxswitcher rename to bin/tmuxswitcher diff --git a/scripts/bin/undock b/bin/undock similarity index 100% rename from scripts/bin/undock rename to bin/undock diff --git a/scripts/bin/upload b/bin/upload similarity index 100% rename from scripts/bin/upload rename to bin/upload diff --git a/scripts/bin/vman b/bin/vman similarity index 100% rename from scripts/bin/vman rename to bin/vman diff --git a/scripts/bin/wifi-list b/bin/wifi-list similarity index 100% rename from scripts/bin/wifi-list rename to bin/wifi-list diff --git a/scripts/bin/workdock b/bin/workdock similarity index 100% rename from scripts/bin/workdock rename to bin/workdock diff --git a/scripts/bin/wres1080 b/bin/wres1080 similarity index 100% rename from scripts/bin/wres1080 rename to bin/wres1080 diff --git a/scripts/bin/wsteam b/bin/wsteam similarity index 100% rename from scripts/bin/wsteam rename to bin/wsteam diff --git a/bin/xrq b/bin/xrq new file mode 100755 index 0000000..fbc3c7b --- /dev/null +++ b/bin/xrq @@ -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 diff --git a/de/bar/bar.bash b/de/bar/bar.bash index b35bbb9..d8f540f 100755 --- a/de/bar/bar.bash +++ b/de/bar/bar.bash @@ -24,8 +24,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 BAR_FONT_DECLARATION="${BAR_FONT}:pixelsize=${BAR_FONT_SIZE};1" diff --git a/de/bspwm/config b/de/bspwm/config index f3d7db8..27a9d34 100755 --- a/de/bspwm/config +++ b/de/bspwm/config @@ -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 diff --git a/de/sxhkd/sxhkdrc b/de/sxhkd/sxhkdrc index e933c38..3390cf1 100755 --- a/de/sxhkd/sxhkdrc +++ b/de/sxhkd/sxhkdrc @@ -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 diff --git a/de/x/loadresources b/de/x/loadresources index effc369..e9f7b1e 100755 --- a/de/x/loadresources +++ b/de/x/loadresources @@ -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 diff --git a/scripts/env_bin/.gitignore b/scripts/env_bin/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/scripts/env_bin/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/setup b/setup index 27fde63..5c1f0b8 100755 --- a/setup +++ b/setup @@ -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" @@ -98,6 +99,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[@]}" diff --git a/shell/bash/bashrc b/shell/bash/bashrc index 6987810..62cc1ab 100644 --- a/shell/bash/bashrc +++ b/shell/bash/bashrc @@ -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 diff --git a/shell/bash/paths b/shell/bash/paths index 379babd..db31b9a 100644 --- a/shell/bash/paths +++ b/shell/bash/paths @@ -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" From b58b2630bf126be6b67f2988154c5de284a3e014 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Wed, 30 Oct 2019 10:08:15 -0500 Subject: [PATCH 2/9] Updates --- bin/fsw | 6 +++++- bin/termrec | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100755 bin/termrec diff --git a/bin/fsw b/bin/fsw index 7bd9f8b..71d177a 100755 --- a/bin/fsw +++ b/bin/fsw @@ -1,7 +1,11 @@ #!/usr/bin/env bash +# Some examples in case you forget: +# Elixir: fsw "mix run" ./**/*.{ex,exs} +# Run bash file on any event (note single quotes): fsw 'bash ${__FSW_FILENAME}' ./**/*.bash + SHELL_COMMAND="${1}" shift -inotifywait -q -m -e close_write -r "${@}" | while read -r _ _; do +inotifywait -q -m -e close_write -r "${@}" | while read -r __FSW_FILENAME __FSW_EVENT; do eval "${SHELL_COMMAND}" done diff --git a/bin/termrec b/bin/termrec new file mode 100755 index 0000000..d4a6e62 --- /dev/null +++ b/bin/termrec @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +asciinema rec -i 2 --stdin From 861c1eff3a807385483f1212b544a82509bb7865 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Wed, 30 Oct 2019 13:25:21 -0500 Subject: [PATCH 3/9] Fix some tmux things from refactor --- shell/tmux/tmux.conf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shell/tmux/tmux.conf b/shell/tmux/tmux.conf index 4e6958b..8f6fb33 100644 --- a/shell/tmux/tmux.conf +++ b/shell/tmux/tmux.conf @@ -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 ~/.tmux-buffer.log" +bind-key O run-shell "~/.config/dotfiles/bin/tmux-save-buffer #S" \; display-message "Saved buffer to ~/.tmux-buffer.log" # pane split line colors set -g pane-active-border-style bg=black,fg=black From 741305fb23eb06b26239fdc99a48f1f4230a0636 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Wed, 30 Oct 2019 17:57:30 -0500 Subject: [PATCH 4/9] WIP --- bin/fsw | 71 ++++++++++++++++++++++++++++++++++++++++++----- shell/bash/prompt | 37 ++++++++++-------------- 2 files changed, 79 insertions(+), 29 deletions(-) diff --git a/bin/fsw b/bin/fsw index 71d177a..3103046 100755 --- a/bin/fsw +++ b/bin/fsw @@ -1,11 +1,68 @@ #!/usr/bin/env bash -# Some examples in case you forget: -# Elixir: fsw "mix run" ./**/*.{ex,exs} -# Run bash file on any event (note single quotes): fsw 'bash ${__FSW_FILENAME}' ./**/*.bash +_VERSION="0.2.0" -SHELL_COMMAND="${1}" -shift -inotifywait -q -m -e close_write -r "${@}" | while read -r __FSW_FILENAME __FSW_EVENT; do - eval "${SHELL_COMMAND}" +function help() { + I=" " + cat < [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 + eval "${SHELL_COMMAND}" + fi done diff --git a/shell/bash/prompt b/shell/bash/prompt index 6123afe..45bb9f5 100644 --- a/shell/bash/prompt +++ b/shell/bash/prompt @@ -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=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(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){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" From 867b81c919dff77a0baba587265b8fed82075264 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Thu, 31 Oct 2019 10:46:24 -0500 Subject: [PATCH 5/9] Add htop config --- apps/htop/rc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 apps/htop/rc diff --git a/apps/htop/rc b/apps/htop/rc new file mode 100644 index 0000000..fa4ada4 --- /dev/null +++ b/apps/htop/rc @@ -0,0 +1,26 @@ +# 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=1 +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 From 39e60072bb88408a945776adda9ed5fb3e178547 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Thu, 31 Oct 2019 10:46:50 -0500 Subject: [PATCH 6/9] Add htop config to setup script --- setup | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup b/setup index 5c1f0b8..52c4326 100755 --- a/setup +++ b/setup @@ -67,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" From af4be9aa3a0880af2256303509bf5521f626f8cf Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Thu, 31 Oct 2019 10:47:04 -0500 Subject: [PATCH 7/9] Finish fsw script changes --- bin/fsw | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/fsw b/bin/fsw index 3103046..73eb43d 100755 --- a/bin/fsw +++ b/bin/fsw @@ -62,7 +62,6 @@ inotifywait -m -e "${FSW_EVENTS}" -r "${DIRS[@]}" 2>&1 \ export FSW_DIR="$dir" export FSW_PATH="$dir$filename" export FSW_FILE_EVENTS="$events" - <<< "$FSW_PATH" grep -P - eval "${SHELL_COMMAND}" + <<< "$FSW_PATH" grep -P "$FILTER" > /dev/null 2>&1 && eval "${SHELL_COMMAND}" fi done From 4fcf5120625b79c96673e3a8b7103b4326687854 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Thu, 31 Oct 2019 12:35:22 -0500 Subject: [PATCH 8/9] Fix bash prompt so last path part is not shortened --- shell/bash/prompt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shell/bash/prompt b/shell/bash/prompt index 45bb9f5..3290750 100644 --- a/shell/bash/prompt +++ b/shell/bash/prompt @@ -6,7 +6,7 @@ PROMPT_SUCCESS_COLOR='\[\e[0;34m\]' PROMPT_FAILURE_COLOR='\[\e[0;31m\]' DIR_COLOR='\[\e[0;35m\]' -MAX_PATH_PIECE_CHARS=3 +MAX_PATH_PIECE_CHARS=${BASH_PROMPT_MAX_PATH_PIECE_CHARS:-3} # prompt rendering functions preprocess_pwd() { @@ -14,9 +14,9 @@ preprocess_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(length(p[k])>'"$((MAX_PATH_PIECE_CHARS+1))"'){printf "/%.'"$((MAX_PATH_PIECE_CHARS))"'s…",p[k]}else{printf "/%s",p[k]}}}')" + #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){printf "/%.'"$MAX_PATH_PIECE_CHARS"'s",p[k]}}')" + 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" From 3fceda1125e2f7c4184dd5b95e73afb9377a02e8 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Thu, 31 Oct 2019 12:35:28 -0500 Subject: [PATCH 9/9] Add vim_mode to htop and hide process path For info on htop vim_mode, see https://github.com/hishamhm/htop/pull/959 --- apps/htop/rc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/htop/rc b/apps/htop/rc index fa4ada4..73e2ece 100644 --- a/apps/htop/rc +++ b/apps/htop/rc @@ -8,7 +8,7 @@ hide_kernel_threads=1 hide_userland_threads=1 shadow_other_users=0 show_thread_names=0 -show_program_path=1 +show_program_path=0 highlight_base_name=1 highlight_megabytes=1 highlight_threads=1 @@ -24,3 +24,4 @@ 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