From 402e42f58487687433f8e84e9abdad545ba1938b Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Wed, 12 Feb 2020 09:46:01 -0600 Subject: [PATCH 1/7] WIP --- apps/git/config | 34 +++++++++---------- apps/gpg/agent.conf | 1 - apps/shell/fish/aliases.fish | 4 +-- .../arch-linux/provisioning/2-essentials.bash | 1 + bin/nvimdiff | 2 ++ bin/vim-multi-diff-builder | 22 ++++++++++++ env/laptop/bin/workdock | 1 + env/laptop/x/docked.resources | 2 +- env/laptop/x/resources | 6 +++- 9 files changed, 50 insertions(+), 23 deletions(-) create mode 100755 bin/nvimdiff create mode 100755 bin/vim-multi-diff-builder diff --git a/apps/git/config b/apps/git/config index 6cffd0c..9130934 100644 --- a/apps/git/config +++ b/apps/git/config @@ -14,17 +14,19 @@ [core] editor = nvim - pager = diff-so-fancy | less --tabs=2 -RFX [http "https://gopkg.in"] followRedirects = true [diff] - tool = nvimdiff + tool = cat [difftool] prompt = false +[multidiff] + tool = nvimdiff -f + [alias] d = difftool s = status @@ -48,12 +50,22 @@ prompt = false [mergetool "nvimdiff"] - cmd = nvim -d $BASE $LOCAL $REMOTE $MERGED -c '$wincmd w' -c 'wincmd J' + cmd = nvimdiff $BASE $LOCAL $REMOTE $MERGED -c '$wincmd w' -c '$wincmd J' + +[mergetool "cat"] + cmd = cat $BASE $LOCAL $REMOTE $MERGED + +[mergetool "echo"] + cmd = echo $BASE $LOCAL $REMOTE $MERGED + +[mergetool "vimmultidiff"] + cmd = vim-multi-diff-builder $BASE $LOCAL $REMOTE $MERGED [pager] branch = false # remove ansi codes, pad each file's diff with newlines, show as diff, remove top padding - diff = vimpager -c 'silent %sm/\\e[^mK]*[mK]//g' -c 'silent %s/^diff/\\r\\rdiff/' -c 'silent set ft=diff' -c 'silent execute \"normal gg2dd\"' + # diff = vimpager -c 'silent %sm/\\e[^mK]*[mK]//g' -c 'silent %s/^diff/\\r\\rdiff/' -c 'silent set ft=diff' -c 'silent execute \"normal gg2dd\"' + diff = less [url "git@github.com:postmates"] insteadOf = https://github.com/postmates @@ -63,17 +75,3 @@ [gpg] program = gpg2 -[color] - ui = true -[color "diff-highlight"] - oldNormal = red bold - oldHighlight = red bold 52 - newNormal = green bold - newHighlight = green bold 22 -[color "diff"] - meta = 11 - frag = magenta bold - commit = yellow bold - old = red bold - new = green bold - whitespace = red reverse diff --git a/apps/gpg/agent.conf b/apps/gpg/agent.conf index aefe8af..5ac350f 100644 --- a/apps/gpg/agent.conf +++ b/apps/gpg/agent.conf @@ -1,3 +1,2 @@ -pinentry-program /usr/bin/pinentry-curses max-cache-ttl 60480000 default-cache-ttl 60480000 diff --git a/apps/shell/fish/aliases.fish b/apps/shell/fish/aliases.fish index 120fe91..805f318 100755 --- a/apps/shell/fish/aliases.fish +++ b/apps/shell/fish/aliases.fish @@ -110,8 +110,8 @@ function g end end alias gs "git status" -alias gd "git diff" -alias gds "git diff --staged" +alias gd "git d" +alias gds "gd --staged" # alias gdv "git dv" # TODO: what is this? alias gpl "git pull" alias gp "git push" diff --git a/bin/lib/arch-linux/provisioning/2-essentials.bash b/bin/lib/arch-linux/provisioning/2-essentials.bash index aa9b7c4..15a58bf 100755 --- a/bin/lib/arch-linux/provisioning/2-essentials.bash +++ b/bin/lib/arch-linux/provisioning/2-essentials.bash @@ -55,6 +55,7 @@ pacaur --needed -S \ swaks `# SMTP CLI` \ time `# GNU time` \ fortune-mod fortune-mod-archlinux `# Fortune` \ + diff-so-fancy `# Fancy Diffs` \ --noconfirm --noedit # install rxvt-unicode script for resizing font on-the-fly diff --git a/bin/nvimdiff b/bin/nvimdiff new file mode 100755 index 0000000..9650db8 --- /dev/null +++ b/bin/nvimdiff @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +nvim -d "$@" diff --git a/bin/vim-multi-diff-builder b/bin/vim-multi-diff-builder new file mode 100755 index 0000000..746437e --- /dev/null +++ b/bin/vim-multi-diff-builder @@ -0,0 +1,22 @@ +#!/usr/bin/env sh + +td="$(mktemp -p "$pdir" -d "tmp_vim_git_multi_diff.XXXXXXXX")" +trap "rm -rf \"$td\"" EXIT + +files="$(git diff --name-only "$@")" + +for f in $files; do + d="$(dirname "$td/$f")" + rfn="$(basename "$f")" + fn="$rfn._@HEAD" + cfn="$rfn._@DISK" + mkdir -p "$d" + git --no-pager show HEAD:"$f" > "$d/$fn" 2>/dev/null || \ + echo "" > "$d/$fn" + cp "$f" "$d/$cfn" + nvim -d "$d/$fn" "$d/$cfn" + exit 3 +done + +ls -R "$td" +rm -rf "$td" diff --git a/env/laptop/bin/workdock b/env/laptop/bin/workdock index f448e54..112cfef 100755 --- a/env/laptop/bin/workdock +++ b/env/laptop/bin/workdock @@ -2,6 +2,7 @@ autorandr --change xrandr --output eDP1 --scale-from 1600x900 --filter nearest --mode 3200x1800 +"${DOTFILES_PATH}/apps/de/x/loadresources" xrdb -merge "$ENV_PATH/x/docked.resources" "${DOTFILES_PATH}/apps/de/bspwm/rc" restartbar diff --git a/env/laptop/x/docked.resources b/env/laptop/x/docked.resources index 743f1b4..fe0ad9b 100755 --- a/env/laptop/x/docked.resources +++ b/env/laptop/x/docked.resources @@ -3,5 +3,5 @@ dpi: 92 *dpi: 92 Xft.dpi: 92 -polybar.display_monitor: DP1 +polybar.display_monitor: DP1-1-8 polybar.height: 40 diff --git a/env/laptop/x/resources b/env/laptop/x/resources index fd23b1c..db5172a 100755 --- a/env/laptop/x/resources +++ b/env/laptop/x/resources @@ -1,4 +1,7 @@ +#define mono_font iosevka-lyte #define bar_font_size 12 +#define icon_font Font Awesome 5 Free Solid +#define icon_font_size 12 *.font: xft:Iosevka Nerd Font Mono:pixelsize=12,xft:Noto Emoji,xft:Font Awesome 5 Free:pixelsize=14,xft:FreeSans:pixelsize=14 *.boldFont: xft:Iosevka Nerd Font Mono:style=bold:pixelsize=12,xft:Font Awesome 5 Free:pixelsize=14,xft:FreeSans:pixelsize=14 @@ -13,4 +16,5 @@ Xft.dpi: 190 polybar.height: 70 polybar.display_monitor: eDP1 -polybar.primary_font: iosevka-lyte:pixelsize=bar_font_size;1 +polybar.primary_font: mono_font:pixelsize=bar_font_size;1 +polybar.secondary_font: icon_font:style=Regular:pixelsize=icon_font_size;1 From b8188de527212abb90eb0939a07977001b00d7e1 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Wed, 12 Feb 2020 09:49:29 -0600 Subject: [PATCH 2/7] Fix wm/x startup --- apps/de/bspwm/config | 4 ++-- apps/de/bspwm/rc | 11 +++++------ apps/de/polybar/config | 36 ++++++++++++++++++++++++------------ apps/de/polybar/run | 2 +- apps/de/x/profile | 0 apps/de/x/resources | 6 +++--- bin/lib/colors/xresources | 2 +- env/desktop/x/resources | 6 +++++- 8 files changed, 41 insertions(+), 26 deletions(-) mode change 100644 => 100755 apps/de/x/profile diff --git a/apps/de/bspwm/config b/apps/de/bspwm/config index 97b1d89..6ead26d 100755 --- a/apps/de/bspwm/config +++ b/apps/de/bspwm/config @@ -8,7 +8,7 @@ MONITOR_COUNT=$(<<< "$BSPWM_MONITORS" wc -w | awk '{ printf $1 }') PER_MONITOR=$((NUM_DESKTOPS / MONITOR_COUNT)) DESKTOPS=$(seq "$NUM_DESKTOPS") -[ $REVERSE_MONITOR_DESKTOPS -eq 1 ] && BSPWM_MONITORS=$(<<< "$BSPWM_MONITORS" tac) +[ "$REVERSE_MONITOR_DESKTOPS" -eq 1 ] && BSPWM_MONITORS=$(<<< "$BSPWM_MONITORS" tac) bspc config normal_border_color "$(xrq bspwm.normal_border_color)" bspc config focused_border_color "$(xrq bspwm.focused_border_color)" @@ -36,7 +36,7 @@ for mon in $BSPWM_MONITORS; do i=$((max + 1)) done -if [ $REVERSE_DESKTOP_ORDERING -eq 1 ]; then +if [ "$REVERSE_DESKTOP_ORDERING" -eq 1 ]; then prev_mon= for mon in ${BSPWM_MONITORS}; do if [ ! -z $prev_mon ]; then diff --git a/apps/de/bspwm/rc b/apps/de/bspwm/rc index a5767a4..f4398fb 100755 --- a/apps/de/bspwm/rc +++ b/apps/de/bspwm/rc @@ -1,18 +1,17 @@ #!/usr/bin/env sh +. "$DOTFILES_PATH/apps/de/x/profile" + BAR_COMMAND="startbar" BSPWM_STATE_FILE="$HOME/.bspwm_state" -if [ -e "$BSPWM_STATE" ] ; then - bspc wm -l "$BSPWM_STATE" - rm "$BSPWM_STATE" -fi +[ -e "$BSPWM_STATE" ] && bspc wm -l "$BSPWM_STATE" && rm "$BSPWM_STATE" . "$DOTFILES_PATH/apps/de/bspwm/config" [ -f "$HOME/.fehbg" ] && "$HOME/.fehbg" & -[ "$(xrq bspwm.start_compton)" = "true" ] && has_command compton && compton & -[ "$(xrq bspwm.start_bar)" = "true" ] && has_command "${BAR_COMMAND}" && "${BAR_COMMAND}" & +[ "$(xrq bspwm.start_compton)" -eq 1 ] && has_command compton && compton & +[ "$(xrq bspwm.start_bar)" -eq 1 ] && has_command "${BAR_COMMAND}" && "${BAR_COMMAND}" & has_command urxvtd && urxvtd & has_command dunst && dunst & has_command sxhkd && sxhkd -m -1 & diff --git a/apps/de/polybar/config b/apps/de/polybar/config index 3f1c973..9d6ee2a 100644 --- a/apps/de/polybar/config +++ b/apps/de/polybar/config @@ -102,20 +102,32 @@ format-mounted-prefix-foreground = ${colors.icon} ; ########################### ; [module/bspwm] -ws-icon-0 = 1; -ws-icon-1 = 2; -ws-icon-2 = 3; -ws-icon-3 = 4; -ws-icon-4 = 5; -ws-icon-5 = 6; -ws-icon-6 = 7; -ws-icon-7 = 8; -ws-icon-8 = 9; -ws-icon-9 = 10; -ws-icon-default = ♟ - +; ws-icon-0 = 1; +; ws-icon-1 = 2; +; ws-icon-2 = 3; +; ws-icon-3 = 4; +; ws-icon-4 = 5; +; ws-icon-5 = 6; +; ws-icon-6 = 7; +; ws-icon-7 = 8; +; ws-icon-8 = 9; +; ws-icon-9 = 10; +; ws-icon-default = ♟ ; misc icon:  +ws-icon-0 = 1;1 +ws-icon-1 = 2;2 +ws-icon-2 = 3;3 +ws-icon-3 = 4;4 +ws-icon-4 = 5;5 +ws-icon-5 = 6;6 +ws-icon-6 = 7;7 +ws-icon-7 = 8;8 +ws-icon-8 = 9;9 +ws-icon-9 = 10;0 +ws-icon-default = - +; misc icon: - + label-focused-font = 2 label-occupied-font = 2 label-urgent-font = 2 diff --git a/apps/de/polybar/run b/apps/de/polybar/run index 78140fa..f4f753d 100755 --- a/apps/de/polybar/run +++ b/apps/de/polybar/run @@ -12,7 +12,7 @@ bar_monitor="$(xrq polybar.display_monitor)" # TODO: if bspwm is the active window manager if has_command bspc; then - if [ ! "$(xrq polybar.bottom_of_display)" = "true" ]; then + if [ ! "$(xrq polybar.bottom_of_display)" -eq 1 ]; then bspc config -m "${bar_monitor}" top_padding "$eheight" bspc config -m "${bar_monitor}" bottom_padding "0" else diff --git a/apps/de/x/profile b/apps/de/x/profile old mode 100644 new mode 100755 diff --git a/apps/de/x/resources b/apps/de/x/resources index 4240c8b..3e631f2 100755 --- a/apps/de/x/resources +++ b/apps/de/x/resources @@ -71,14 +71,14 @@ bspwm.num_desktops: 10 bspwm.reverse_desktop_ordering: 0 bspwm.reverse_monitor_desktops: 0 bspwm.split_ratio: 0.5 -bspwm.start_compton: false -bspwm.start_bar: true +bspwm.start_compton: 0 +bspwm.start_bar: 1 ! polybar polybar.primary_font: mono_font:pixelsize=bar_font_size;1 polybar.secondary_font: icon_font:style=Regular:pixelsize=icon_font_size;1 polybar.display_monitor: HDMI-1 -polybar.bottom_of_display: true +polybar.bottom_of_display: 1 polybar.margin: window_margin polybar.storage_volume: / polybar.ethernet_interface: eth0 diff --git a/bin/lib/colors/xresources b/bin/lib/colors/xresources index 8ea3328..c524547 100644 --- a/bin/lib/colors/xresources +++ b/bin/lib/colors/xresources @@ -48,5 +48,5 @@ rofi.color-urgent: base00,base05,base00,base0D,base00 bspwm.normal_border_color: base00 bspwm.focused_border_color: base0D -bspwm.active_border_color: base0D +bspwm.active_border_color: base00 bspwm.presel_feedback_color: base0D diff --git a/env/desktop/x/resources b/env/desktop/x/resources index 758ffac..e6dce21 100755 --- a/env/desktop/x/resources +++ b/env/desktop/x/resources @@ -1,2 +1,6 @@ -bspwm.reverse_desktop_ordering: 1 +#define bar_font_size 12 +# TODO: this needs fixing +polybar.primary_font: Iosevka Term:pixelsize=bar_font_size;1 +bspwm.reverse_desktop_ordering: 0 +bspwm.reverse_monitor_desktops: 1 polybar.display_monitor: DisplayPort-0 From 88284235da6ee4cd61f441806a4deb77a4632639 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Wed, 12 Feb 2020 11:13:46 -0600 Subject: [PATCH 3/7] Suepr vim diff viewer! --- apps/de/bspwm/config | 6 +++--- apps/git/config | 17 ++--------------- apps/neovim/plugins.vim | 2 +- apps/shell/fish/aliases.fish | 3 ++- bin/vdiff | 34 ++++++++++++++++++++++++++++++++++ bin/vim-multi-diff-builder | 22 ---------------------- bin/vimpager | 1 + 7 files changed, 43 insertions(+), 42 deletions(-) create mode 100755 bin/vdiff delete mode 100755 bin/vim-multi-diff-builder diff --git a/apps/de/bspwm/config b/apps/de/bspwm/config index 6ead26d..bb94ef4 100755 --- a/apps/de/bspwm/config +++ b/apps/de/bspwm/config @@ -4,11 +4,11 @@ NUM_DESKTOPS="$(xrq bspwm.num_desktops)" REVERSE_DESKTOP_ORDERING="$(xrq bspwm.reverse_desktop_ordering)" REVERSE_MONITOR_DESKTOPS="$(xrq bspwm.reverse_monitor_desktops)" BSPWM_MONITORS=$(bspc query -M) -MONITOR_COUNT=$(<<< "$BSPWM_MONITORS" wc -w | awk '{ printf $1 }') +MONITOR_COUNT=$(echo "$BSPWM_MONITORS" | wc -w | awk '{ printf $1 }') PER_MONITOR=$((NUM_DESKTOPS / MONITOR_COUNT)) DESKTOPS=$(seq "$NUM_DESKTOPS") -[ "$REVERSE_MONITOR_DESKTOPS" -eq 1 ] && BSPWM_MONITORS=$(<<< "$BSPWM_MONITORS" tac) +[ "$REVERSE_MONITOR_DESKTOPS" -eq 1 ] && BSPWM_MONITORS=$(echo "$BSPWM_MONITORS" | tac) bspc config normal_border_color "$(xrq bspwm.normal_border_color)" bspc config focused_border_color "$(xrq bspwm.focused_border_color)" @@ -28,7 +28,7 @@ bspc rule -a "*" split_dir=right i=1 for mon in $BSPWM_MONITORS; do max=$((i + PER_MONITOR - 1)) - screens= + screens="" for j in $(seq $i $max); do screens="${screens}${j} " done diff --git a/apps/git/config b/apps/git/config index 9130934..7678bf7 100644 --- a/apps/git/config +++ b/apps/git/config @@ -19,14 +19,11 @@ followRedirects = true [diff] - tool = cat + tool = nvimdiff [difftool] prompt = false -[multidiff] - tool = nvimdiff -f - [alias] d = difftool s = status @@ -52,20 +49,10 @@ [mergetool "nvimdiff"] cmd = nvimdiff $BASE $LOCAL $REMOTE $MERGED -c '$wincmd w' -c '$wincmd J' -[mergetool "cat"] - cmd = cat $BASE $LOCAL $REMOTE $MERGED - -[mergetool "echo"] - cmd = echo $BASE $LOCAL $REMOTE $MERGED - -[mergetool "vimmultidiff"] - cmd = vim-multi-diff-builder $BASE $LOCAL $REMOTE $MERGED - [pager] branch = false # remove ansi codes, pad each file's diff with newlines, show as diff, remove top padding - # diff = vimpager -c 'silent %sm/\\e[^mK]*[mK]//g' -c 'silent %s/^diff/\\r\\rdiff/' -c 'silent set ft=diff' -c 'silent execute \"normal gg2dd\"' - diff = less + diff = vimpager -c 'silent %sm/\\e[^mK]*[mK]//g' -c 'silent %s/^diff/\\r\\rdiff/' -c 'silent set ft=diff' -c 'silent execute \"normal gg2dd\"' [url "git@github.com:postmates"] insteadOf = https://github.com/postmates diff --git a/apps/neovim/plugins.vim b/apps/neovim/plugins.vim index 187ffa8..f15beb4 100644 --- a/apps/neovim/plugins.vim +++ b/apps/neovim/plugins.vim @@ -43,7 +43,7 @@ let g:polyglot_disabled = ['cue', 'cuesheet'] " let g:fzf_layout = { 'window': 'enew' } " check if we're using vim as the manpage viewer before loading session plugins -if exists('asmanviewer') +if exists('asmanviewer') || exists('nosession') let g:prosession_dir = '/dev/null' else Plug 'tpope/vim-obsession' " session ease-of-use diff --git a/apps/shell/fish/aliases.fish b/apps/shell/fish/aliases.fish index 805f318..85cce3f 100755 --- a/apps/shell/fish/aliases.fish +++ b/apps/shell/fish/aliases.fish @@ -110,7 +110,7 @@ function g end end alias gs "git status" -alias gd "git d" +alias gd "git diff" alias gds "gd --staged" # alias gdv "git dv" # TODO: what is this? alias gpl "git pull" @@ -156,6 +156,7 @@ alias wifi "sudo nmtui" alias year 'cal (date +%Y)' alias y year alias pa pulsemixer +alias vd vdiff # games aliases # this sometimes fixes steam dynamic library issues? diff --git a/bin/vdiff b/bin/vdiff new file mode 100755 index 0000000..91f9ef3 --- /dev/null +++ b/bin/vdiff @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +repo_root="$(git rev-parse --show-toplevel)" +pushd "$repo_root" &> /dev/null || ( echo "Repo doesn't exist!"; exit 2 ) +td="$(mktemp -p "$pdir" -d "vdiff.XXXXXXXX")" +trap "rm -rf \"$td\"" EXIT +files="$(git diff --name-only "$@")" + +args=() +vcmd="" +for f in $files; do + d="$(dirname "$td/$f")" + rfn="$(basename "$f")" + fn="$rfn._@HEAD" + cfn="$rfn" + + mkdir -p "$d" + git --no-pager show HEAD:"$f" > "$d/$fn" 2>/dev/null || \ + echo "" > "$d/$fn" + cp "$f" "$d/$cfn" 2>/dev/null || echo "" > "$d/$cfn" + + if [ -z "$args" ]; then + args+=($d/$fn -c) + vcmd="vert diffsplit $d/$cfn" + else + vcmd="$vcmd | tabnew | e $d/$fn | vert diffsplit $d/$cfn" + fi +done + +remaps="nnoremap k :tabnext | nnoremap j :tabprev" +nvim "${args[@]}" "$vcmd | tabnext | $remaps" + +rm -rf "$td" +popd &> /dev/null || ( echo "Could not return to original directory" && exit 4 ) diff --git a/bin/vim-multi-diff-builder b/bin/vim-multi-diff-builder deleted file mode 100755 index 746437e..0000000 --- a/bin/vim-multi-diff-builder +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env sh - -td="$(mktemp -p "$pdir" -d "tmp_vim_git_multi_diff.XXXXXXXX")" -trap "rm -rf \"$td\"" EXIT - -files="$(git diff --name-only "$@")" - -for f in $files; do - d="$(dirname "$td/$f")" - rfn="$(basename "$f")" - fn="$rfn._@HEAD" - cfn="$rfn._@DISK" - mkdir -p "$d" - git --no-pager show HEAD:"$f" > "$d/$fn" 2>/dev/null || \ - echo "" > "$d/$fn" - cp "$f" "$d/$cfn" - nvim -d "$d/$fn" "$d/$cfn" - exit 3 -done - -ls -R "$td" -rm -rf "$td" diff --git a/bin/vimpager b/bin/vimpager index f7af268..106fd04 100755 --- a/bin/vimpager +++ b/bin/vimpager @@ -1,6 +1,7 @@ #!/usr/bin/env sh nvim \ + -c 'let nosession=1' \ -c 'silent setlocal nobuflisted buftype=nofile bufhidden=wipe noswapfile' \ "$@" \ - From d8126dc9e642ecae4c7c2969f8f1f0a533459d3f Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Wed, 12 Feb 2020 11:24:16 -0600 Subject: [PATCH 4/7] Cleaner dir changes --- bin/vdiff | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/vdiff b/bin/vdiff index 91f9ef3..ea269a0 100755 --- a/bin/vdiff +++ b/bin/vdiff @@ -1,7 +1,10 @@ #!/usr/bin/env bash repo_root="$(git rev-parse --show-toplevel)" -pushd "$repo_root" &> /dev/null || ( echo "Repo doesn't exist!"; exit 2 ) +if ! pushd "$repo_root" &> /dev/null; then + echo "Repo doesn't exist!" + exit 2 +fi td="$(mktemp -p "$pdir" -d "vdiff.XXXXXXXX")" trap "rm -rf \"$td\"" EXIT files="$(git diff --name-only "$@")" @@ -30,5 +33,7 @@ done remaps="nnoremap k :tabnext | nnoremap j :tabprev" nvim "${args[@]}" "$vcmd | tabnext | $remaps" -rm -rf "$td" -popd &> /dev/null || ( echo "Could not return to original directory" && exit 4 ) +if ! popd &> /dev/null; then + echo "Could not return to original directory" + exit 4 +fi From 3f00303e975c86ff1ed222ea3252e304bf287b6c Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Wed, 12 Feb 2020 11:26:32 -0600 Subject: [PATCH 5/7] Cleanup --- bin/archive.moon | 5 ----- 1 file changed, 5 deletions(-) delete mode 100755 bin/archive.moon diff --git a/bin/archive.moon b/bin/archive.moon deleted file mode 100755 index c8a7a57..0000000 --- a/bin/archive.moon +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env moon - -archive_name = "#{string.gsub arg[1], "(.*/)(.*)", "%2"}.tar.zstd" -os.execute "tar --zstd -cvf '#{archive_name}' '#{table.concat arg, "' '"}'" -print "Archive created at: #{archive_name}" From 7fa86968e15430c3de1fa147b0c8a8eac9546724 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Thu, 13 Feb 2020 11:14:03 -0600 Subject: [PATCH 6/7] Pipeline stuff --- apps/neovim/init.vim | 8 +++++--- bin/cdp | 2 +- bin/fsw | 24 ++++++++++++++++------- bin/fswi | 2 +- bin/pipeline | 45 ++++++++++---------------------------------- 5 files changed, 34 insertions(+), 47 deletions(-) diff --git a/apps/neovim/init.vim b/apps/neovim/init.vim index e2280bc..685036b 100644 --- a/apps/neovim/init.vim +++ b/apps/neovim/init.vim @@ -1,11 +1,13 @@ +scriptencoding utf-8 +set fileencoding=utf8 + let $vimdir = $HOME.'/.vim' if has('nvim') let $vimdir = $XDG_CONFIG_HOME.'/nvim' endif -" load a per-environment file if one exists -if filereadable("$ENV_PATH/vim") - source "$ENV_PATH/vim" +if filereadable($ENV_PATH."/vim") + source $ENV_PATH."/vim" endif call plug#begin($vimdir.'/bundle') diff --git a/bin/cdp b/bin/cdp index d8b12a7..dd354d0 100755 --- a/bin/cdp +++ b/bin/cdp @@ -1,4 +1,4 @@ #!/usr/bin/env bash # TODO: needs fixing...? -[ -f "$HOME/.fzf.bash" ] && source "$HOME/.fzf.bash" && $(__fzf_cd__) +cd "$(dirname "$(fzf)")" diff --git a/bin/fsw b/bin/fsw index 08331cd..56898aa 100755 --- a/bin/fsw +++ b/bin/fsw @@ -4,8 +4,8 @@ _VERSION="0.2.0" function help() { I=" " - cat < [filter] [dirs...] @@ -41,11 +41,17 @@ USAGE } dbg() { - if [[ ! -z ${FSW_DEBUG+x} ]]; then - echo -e "[debug] fsw: $@" + if [[ -n ${FSW_DEBUG+x} ]]; then + echo -e "[debug] fsw: $*" fi } +contains_element () { + local e match="$1"; shift + for e; do [[ "$e" == "$match" ]] && return 0; done + return 1 +} + if [[ $1 = '-h' ]] || [[ $1 = '--help' ]] || [[ -z $1 ]]; then help exit 0 @@ -64,16 +70,20 @@ if [[ -e $FILTER ]]; then echo "It looks like your filter is an actual file. I'll just watch that for you." DIRS=("${FILTER}") fi -while [[ ! -z $1 ]] && $(realpath $1) &> /dev/null; do +while [[ -n $1 ]] && realpath "$1" &> /dev/null; do dbg "Directory: ${1}" DIRS+=("$1"); shift done -inotifywait -m -e "${FSW_EVENTS}" -r "${DIRS[@]}" 2>&1 \ +inotifywait -m -e "${FSW_EVENTS},delete,delete_self" -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 contains_element "$dir" "${DIRS[@]}" && [[ $events =~ "delete" ]]; then + echo "One of the watched directories (\"$dir\") was deleted. Exiting..." + exit 75 + fi if [[ "$dir $events" = "Watches established." ]]; then echo "Ready." - dbg "Directory: ${DIRS[@]}" + dbg "Directory: ${DIRS[*]}" else export FSW_FILENAME="$filename" export FSW_DIR="$dir" diff --git a/bin/fswi b/bin/fswi index 9eb7a8c..fc53f8b 100755 --- a/bin/fswi +++ b/bin/fswi @@ -1,4 +1,4 @@ #!/usr/bin/env bash eval "${1}" -fsw "$@" +exec fsw "$@" diff --git a/bin/pipeline b/bin/pipeline index 70d978e..1908407 100755 --- a/bin/pipeline +++ b/bin/pipeline @@ -8,7 +8,7 @@ if [ -n "${1+x}" ]; then mkdir -p "$pdir" if [ -z ${1+x} ]; then td="$(mktemp -p "$pdir" -d "tmp_pipeline.XXXXXXXX")" - cleanup_trap="rm -rf \"$td\"" + trap "rm -rf '$td'" EXIT else td="$pdir/$1"; shift mkdir -p "$td" @@ -17,48 +17,23 @@ if [ -n "${1+x}" ]; then else td="$(mktemp --tmpdir -d pipeline.XXXXXXXX)" transform="$td/transform" - cleanup_trap="rm -rf \"$td\"" + trap "rm -rf '$td'" EXIT fi [ ! -e "$transform" ] && \ - printf "#!/usr/bin/env bash\n# for %s\n\nbase64" "${td}" > "$transform" + printf "#!/usr/bin/env bash\n# you must save this buffer manually\n# for %s\n +base64" "${td}" > "$transform" -in="$td/in" -[ -n "${1+x}" ] && in="${1}" && shift -out="$td/out" -[ -n "${1+x}" ] && out="${1}" && shift +in="$td/in"; [ -n "${1+x}" ] && in="${1}" && shift +out="$td/out"; [ -n "${1+x}" ] && out="${1}" && shift # TODO: if no logging, log="/dev/null" log="$td/log" - -chmod +x "$transform" -echo "Hello World" > "$in" touch "$log" -fswi \ - "bash -c 'cd \"$td\" && < \"$in\" \"$transform\" | tee \"$out\"'" \ - 'in$|transform$' \ - "$td" "$pdir" > "$log" 2>&1 & +chmod +x "$transform" -watcher="$!" +# TODO: saved inputs? +echo "Hello World" > "$in" -if [ -z "${cleanup_trap+x}" ]; then - trap "kill \"$watcher\"" EXIT -else - trap "${cleanup_trap}; kill \"$watcher\"" EXIT -fi - -job="$(echo "let g:pipeline_job_id = jobstart(['inotifywait', '-m', '-e', 'close_write', '${out}'], {'detach':1,'on_stdout':{j,d,e->execute('checktime')}})" | tr "'" '"')" - -echo $job >> "$log" - -# this will only autosave (and therefore autoreload) for the out buffer (since -# it was opened last) - autosaving (and therefore autorunning) is potentially -# very scary -nvim -V9"$td/vimlog" \ - -o "$in" "$transform" "$out" \ - --cmd "$job" \ - --cmd 'set updatetime=250' \ - --cmd 'autocmd CursorHold,CursorHoldI silent write' \ - --cmd 'autocmd VimLeave call jobstop(g:pipeline_job_id)' \ - --cmd "$job" +env PIPELINE_IN="$id" PIPELINE_TRANSFORM="$transform" PIPELINE_OUT="$out" nvim --cmd "source $DOTFILES_PATH/apps/neovim/scripts/pipeline.vim" From f2e91b1398c512a13bac83c2f34b07b4813b8fd9 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Thu, 13 Feb 2020 11:14:25 -0600 Subject: [PATCH 7/7] Add vim script --- apps/neovim/.gitignore | 1 + apps/neovim/scripts/pipeline.vim | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 apps/neovim/scripts/pipeline.vim diff --git a/apps/neovim/.gitignore b/apps/neovim/.gitignore index c3702eb..df6ea30 100644 --- a/apps/neovim/.gitignore +++ b/apps/neovim/.gitignore @@ -1,4 +1,5 @@ /* +!/scripts/ !/ftplugin/ !/.gitignore !/init.vim diff --git a/apps/neovim/scripts/pipeline.vim b/apps/neovim/scripts/pipeline.vim new file mode 100644 index 0000000..c6af3cd --- /dev/null +++ b/apps/neovim/scripts/pipeline.vim @@ -0,0 +1,20 @@ +edit $PIPELINE_IN +split $PIPELINE_TRANSFORM +split $PIPELINE_OUT + +let s:refresh_output = {j, d, e -> execute('checktime')} +let s:refresh_output_job = {'spec': ['inotifywait', '-m', '-e', 'close_write,delete', $PIPELINE_OUT], 'opts': {'detach': 1, 'on_stdout': s:refresh_output}} +let s:refresh_output_job_id = jobstart(s:refresh_output_job['spec'], s:refresh_output_job['opts']) + +function s:RunPipeline() + execute "!".g:pipeline_transform +endfunction + +let s:refresh_output_job_id = jobstart(s:refresh_output_job['spec'], s:refresh_output_job['opts']) + +set updatetime=250 +" only autosave the input buffer +autocmd CursorHold,CursorHoldI silent write +autocmd FileWritePost silent call s:RunPipeline() +autocmd VimLeavePre call jobstop(s:refresh_output_job_id) +autocmd VimLeavePre call jobstop(s:run_pipeline_job_id)