diff --git a/apps/de/bspwm/config b/apps/de/bspwm/config index 97b1d89..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 @@ -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/apps/git/config b/apps/git/config index 6cffd0c..7678bf7 100644 --- a/apps/git/config +++ b/apps/git/config @@ -14,7 +14,6 @@ [core] editor = nvim - pager = diff-so-fancy | less --tabs=2 -RFX [http "https://gopkg.in"] followRedirects = true @@ -48,7 +47,7 @@ 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' [pager] branch = false @@ -63,17 +62,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/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/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/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/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) diff --git a/apps/shell/fish/aliases.fish b/apps/shell/fish/aliases.fish index 120fe91..85cce3f 100755 --- a/apps/shell/fish/aliases.fish +++ b/apps/shell/fish/aliases.fish @@ -111,7 +111,7 @@ function g end alias gs "git status" alias gd "git diff" -alias gds "git diff --staged" +alias gds "gd --staged" # alias gdv "git dv" # TODO: what is this? alias gpl "git pull" alias gp "git push" @@ -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/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}" 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/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/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/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/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" diff --git a/bin/vdiff b/bin/vdiff new file mode 100755 index 0000000..ea269a0 --- /dev/null +++ b/bin/vdiff @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +repo_root="$(git rev-parse --show-toplevel)" +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 "$@")" + +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" + +if ! popd &> /dev/null; then + echo "Could not return to original directory" + exit 4 +fi 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' \ "$@" \ - 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 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/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