From f18dc112f39df297e8a31c12fcdcd6d5c6ee8a5f Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 29 Jan 2019 01:28:36 +0100 Subject: tv rxvt_unicode: finish running selection --- tv/5pkgs/override/default.nix | 6 ++++ tv/5pkgs/override/rxvt_unicode/default.nix | 6 ++++ .../rxvt_unicode/finish-running-selection.patch | 41 ++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 tv/5pkgs/override/default.nix create mode 100644 tv/5pkgs/override/rxvt_unicode/default.nix create mode 100644 tv/5pkgs/override/rxvt_unicode/finish-running-selection.patch diff --git a/tv/5pkgs/override/default.nix b/tv/5pkgs/override/default.nix new file mode 100644 index 0000000..cd7c564 --- /dev/null +++ b/tv/5pkgs/override/default.nix @@ -0,0 +1,6 @@ +with import ; +self: super: { + rxvt_unicode = self.callPackage ./rxvt_unicode { + rxvt_unicode = super.rxvt_unicode; + }; +} diff --git a/tv/5pkgs/override/rxvt_unicode/default.nix b/tv/5pkgs/override/rxvt_unicode/default.nix new file mode 100644 index 0000000..858a46b --- /dev/null +++ b/tv/5pkgs/override/rxvt_unicode/default.nix @@ -0,0 +1,6 @@ +{ rxvt_unicode }: +rxvt_unicode.overrideAttrs (old: { + patches = old.patches ++ [ + ./finish-running-selection.patch + ]; +}) diff --git a/tv/5pkgs/override/rxvt_unicode/finish-running-selection.patch b/tv/5pkgs/override/rxvt_unicode/finish-running-selection.patch new file mode 100644 index 0000000..a342ccf --- /dev/null +++ b/tv/5pkgs/override/rxvt_unicode/finish-running-selection.patch @@ -0,0 +1,41 @@ +diff --git a/src/rxvttoolkit.h b/src/rxvttoolkit.h +index 56c9a3f..429055d 100644 +--- a/src/rxvttoolkit.h ++++ b/src/rxvttoolkit.h +@@ -384,6 +384,7 @@ struct rxvt_selection + { + rxvt_selection (rxvt_display *disp, int selnum, Time tm, Window win, Atom prop, rxvt_term *term); + void run (); ++ void finish (char *data = 0, unsigned int len = 0); + ~rxvt_selection (); + + rxvt_term *term; // terminal to paste to, may be 0 +@@ -404,7 +405,6 @@ private: + void timer_cb (ev::timer &w, int revents); ev::timer timer_ev; + void x_cb (XEvent &xev); xevent_watcher x_ev; + +- void finish (char *data = 0, unsigned int len = 0); + void stop (); + bool request (Atom target, int selnum); + void handle_selection (Window win, Atom prop, bool delete_prop); +diff --git a/src/screen.C b/src/screen.C +index 9eb375a..77e7109 100644 +--- a/src/screen.C ++++ b/src/screen.C +@@ -2736,11 +2736,11 @@ rxvt_term::paste (char *data, unsigned int len) NOTHROW + void + rxvt_term::selection_request (Time tm, int selnum) NOTHROW + { +- if (!selection_req) +- { +- selection_req = new rxvt_selection (display, selnum, tm, vt, xa[XA_VT_SELECTION], this); +- selection_req->run (); +- } ++ if (selection_req) ++ selection_req->finish (); ++ ++ selection_req = new rxvt_selection (display, selnum, tm, vt, xa[XA_VT_SELECTION], this); ++ selection_req->run (); + } + + /* ------------------------------------------------------------------------- */ -- cgit v1.2.3 From 62ed6167067c845810a4ccf73d0f7f4dcd5056a6 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 31 Jan 2019 11:15:58 +0100 Subject: tv rxvt_unicode: fetch patch --- tv/5pkgs/override/default.nix | 2 +- tv/5pkgs/override/rxvt_unicode.nix | 9 +++++ tv/5pkgs/override/rxvt_unicode/default.nix | 6 ---- .../rxvt_unicode/finish-running-selection.patch | 41 ---------------------- 4 files changed, 10 insertions(+), 48 deletions(-) create mode 100644 tv/5pkgs/override/rxvt_unicode.nix delete mode 100644 tv/5pkgs/override/rxvt_unicode/default.nix delete mode 100644 tv/5pkgs/override/rxvt_unicode/finish-running-selection.patch diff --git a/tv/5pkgs/override/default.nix b/tv/5pkgs/override/default.nix index cd7c564..99c1b3e 100644 --- a/tv/5pkgs/override/default.nix +++ b/tv/5pkgs/override/default.nix @@ -1,6 +1,6 @@ with import ; self: super: { - rxvt_unicode = self.callPackage ./rxvt_unicode { + rxvt_unicode = self.callPackage ./rxvt_unicode.nix { rxvt_unicode = super.rxvt_unicode; }; } diff --git a/tv/5pkgs/override/rxvt_unicode.nix b/tv/5pkgs/override/rxvt_unicode.nix new file mode 100644 index 0000000..da657fb --- /dev/null +++ b/tv/5pkgs/override/rxvt_unicode.nix @@ -0,0 +1,9 @@ +{ fetchurl, rxvt_unicode }: +rxvt_unicode.overrideAttrs (old: { + patches = old.patches ++ [ + (fetchurl { + url = https://cgit.krebsco.de/rxvt-unicode/patch/?id=15f3f94; + sha256 = "12vldwsds27c9l15ffc6svk9mj17jhypcz736pvpmpqbsymlkz2p"; + }) + ]; +}) diff --git a/tv/5pkgs/override/rxvt_unicode/default.nix b/tv/5pkgs/override/rxvt_unicode/default.nix deleted file mode 100644 index 858a46b..0000000 --- a/tv/5pkgs/override/rxvt_unicode/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ rxvt_unicode }: -rxvt_unicode.overrideAttrs (old: { - patches = old.patches ++ [ - ./finish-running-selection.patch - ]; -}) diff --git a/tv/5pkgs/override/rxvt_unicode/finish-running-selection.patch b/tv/5pkgs/override/rxvt_unicode/finish-running-selection.patch deleted file mode 100644 index a342ccf..0000000 --- a/tv/5pkgs/override/rxvt_unicode/finish-running-selection.patch +++ /dev/null @@ -1,41 +0,0 @@ -diff --git a/src/rxvttoolkit.h b/src/rxvttoolkit.h -index 56c9a3f..429055d 100644 ---- a/src/rxvttoolkit.h -+++ b/src/rxvttoolkit.h -@@ -384,6 +384,7 @@ struct rxvt_selection - { - rxvt_selection (rxvt_display *disp, int selnum, Time tm, Window win, Atom prop, rxvt_term *term); - void run (); -+ void finish (char *data = 0, unsigned int len = 0); - ~rxvt_selection (); - - rxvt_term *term; // terminal to paste to, may be 0 -@@ -404,7 +405,6 @@ private: - void timer_cb (ev::timer &w, int revents); ev::timer timer_ev; - void x_cb (XEvent &xev); xevent_watcher x_ev; - -- void finish (char *data = 0, unsigned int len = 0); - void stop (); - bool request (Atom target, int selnum); - void handle_selection (Window win, Atom prop, bool delete_prop); -diff --git a/src/screen.C b/src/screen.C -index 9eb375a..77e7109 100644 ---- a/src/screen.C -+++ b/src/screen.C -@@ -2736,11 +2736,11 @@ rxvt_term::paste (char *data, unsigned int len) NOTHROW - void - rxvt_term::selection_request (Time tm, int selnum) NOTHROW - { -- if (!selection_req) -- { -- selection_req = new rxvt_selection (display, selnum, tm, vt, xa[XA_VT_SELECTION], this); -- selection_req->run (); -- } -+ if (selection_req) -+ selection_req->finish (); -+ -+ selection_req = new rxvt_selection (display, selnum, tm, vt, xa[XA_VT_SELECTION], this); -+ selection_req->run (); - } - - /* ------------------------------------------------------------------------- */ -- cgit v1.2.3 From 710a19d29afa5ef0c5eee4d02f54251aa714e6e2 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 2 Feb 2019 20:14:29 +0100 Subject: tv vim-syntax-nix-nested: add writer{Ext,Name} --- tv/2configs/vim.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix index 3794628..9f78d6e 100644 --- a/tv/2configs/vim.nix +++ b/tv/2configs/vim.nix @@ -250,6 +250,9 @@ let { def = k: ''${k}[ \t\r\n]*=''; writer = k: ''write${k}[^ \t\r\n]*[ \t\r\n]*\("[^"]*"\|[a-z]\+\)''; + writerExt = k: writerName ''[^"]*\.${k}''; + writerName = k: ''write[^ \t\r\n]*[ \t\r\n]*"${k}"''; + in { c = {}; cabal = {}; @@ -257,7 +260,7 @@ let { haskell = {}; jq.extraStart = alts [ (writer "Jq") - ''write[^ \t\r\n]*[ \t\r\n]*"[^"]*\.jq"'' + (writerExt "jq") ]; javascript.extraStart = ''/\* js \*/''; lua = {}; @@ -287,8 +290,10 @@ let { (writer (alts (map capitalize shells))) ]; yaml = {}; - vim.extraStart = - ''write[^ \t\r\n]*[ \t\r\n]*"\(\([^"]*\.\)\?vimrc\|[^"]*\.vim\)"''; + vim.extraStart = alts [ + (writerExt "vim") + (writerName ''\([^"]*\.\)\?vimrc'') + ]; xdefaults = {}; }))} -- cgit v1.2.3 From b1d6781af067876dbd7b88b4b038f048d3e8e3f5 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 2 Feb 2019 20:20:44 +0100 Subject: tv vim-syntax-nix-nested: detect .vim".text --- tv/2configs/vim.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix index 9f78d6e..7e37ef3 100644 --- a/tv/2configs/vim.nix +++ b/tv/2configs/vim.nix @@ -130,14 +130,14 @@ let { ''; }))) ((rtp: rtp // { inherit rtp; }) (pkgs.write "vim-syntax-nix-nested" { - "/syntax/haskell.vim".text = /* vim */ '' + "/syntax/haskell.vim".text = '' syn region String start=+\[[[:alnum:]]*|+ end=+|]+ hi link ConId Identifier hi link VarId Identifier hi link hsDelimiter Delimiter ''; - "/syntax/nix.vim".text = /* vim */ '' + "/syntax/nix.vim".text = '' "" Quit when a (custom) syntax file was already loaded "if exists("b:current_syntax") " finish @@ -291,6 +291,7 @@ let { ]; yaml = {}; vim.extraStart = alts [ + (def ''"[^"]*\.vim"\.text'') (writerExt "vim") (writerName ''\([^"]*\.\)\?vimrc'') ]; @@ -334,7 +335,7 @@ let { set isk=@,48-57,_,192-255,-,' ''; - "/syntax/sed.vim".text = /* vim */ '' + "/syntax/sed.vim".text = '' syn region sedBranch \ matchgroup=sedFunction start="T" \ matchgroup=sedSemicolon end=";\|$" -- cgit v1.2.3 From a6ea667132925a98a3b1fa613a33c6e23cf35701 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 2 Feb 2019 20:24:11 +0100 Subject: tv vim haskell: isk+=' --- tv/2configs/vim.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix index 7e37ef3..fe14828 100644 --- a/tv/2configs/vim.nix +++ b/tv/2configs/vim.nix @@ -129,6 +129,19 @@ let { command! -n=0 -bar ShowSyntax :call ShowSyntax() ''; }))) + ((rtp: rtp // { inherit rtp; }) (pkgs.write "vim-tv" { + # + # Haskell + # + "/ftplugin/haskell.vim".text = '' + if exists("g:vim_tv_ftplugin_haskell_loaded") + finish + endif + let g:vim_tv_ftplugin_haskell_loaded = 1 + + setlocal iskeyword+=' + ''; + })) ((rtp: rtp // { inherit rtp; }) (pkgs.write "vim-syntax-nix-nested" { "/syntax/haskell.vim".text = '' syn region String start=+\[[[:alnum:]]*|+ end=+|]+ -- cgit v1.2.3 From 898d5a1e0f631492799359b5c09fae90cecaa8c9 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 2 Feb 2019 21:21:48 +0100 Subject: tv vim: add TODO ft --- tv/2configs/vim.nix | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix index fe14828..de843a3 100644 --- a/tv/2configs/vim.nix +++ b/tv/2configs/vim.nix @@ -141,6 +141,43 @@ let { setlocal iskeyword+=' ''; + # + # TODO + # + "/ftdetect/todo.vim".text = '' + au BufRead,BufNewFile TODO set ft=todo + ''; + "/ftplugin/todo.vim".text = '' + setlocal foldmethod=syntax + ''; + "/syntax/todo.vim".text = '' + syn match Comment /#.*/ + + syn match todoDate /^[1-9]\S*/ + \ nextgroup=todoSummary + + syn region todoSummary + \ contained + \ contains=todoTag + \ start="." end="$\n" + \ nextgroup=todoBlock + + syn match todoTag /\[[a-z]\+\]/hs=s+1,he=e-1 + \ contained + + syn region todoBlock + \ contained + \ contains=Comment + \ fold + \ start="^[^1-9]" end="^[1-9]"re=s-1,he=s-1,me=s-1 + + syn sync minlines=1000 + + hi todoDate ctermfg=255 + hi todoSummary ctermfg=229 + hi todoBlock ctermfg=248 + hi todoTag ctermfg=217 + ''; })) ((rtp: rtp // { inherit rtp; }) (pkgs.write "vim-syntax-nix-nested" { "/syntax/haskell.vim".text = '' -- cgit v1.2.3 From 0002230b16131264fa86b599acbf40cd305a2c82 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 2 Feb 2019 23:15:16 +0100 Subject: tv vim todo: allow A-Z in tags --- tv/2configs/vim.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix index de843a3..575a3bc 100644 --- a/tv/2configs/vim.nix +++ b/tv/2configs/vim.nix @@ -162,7 +162,7 @@ let { \ start="." end="$\n" \ nextgroup=todoBlock - syn match todoTag /\[[a-z]\+\]/hs=s+1,he=e-1 + syn match todoTag /\[[A-Za-z]\+\]/hs=s+1,he=e-1 \ contained syn region todoBlock -- cgit v1.2.3 From ba6aa9a871850e1d613a2a510f45d3249aee4405 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 3 Feb 2019 13:39:30 +0100 Subject: tv vim todo: form feed ends a block --- tv/2configs/vim.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix index 575a3bc..9942ff6 100644 --- a/tv/2configs/vim.nix +++ b/tv/2configs/vim.nix @@ -169,7 +169,7 @@ let { \ contained \ contains=Comment \ fold - \ start="^[^1-9]" end="^[1-9]"re=s-1,he=s-1,me=s-1 + \ start="^[^1-9]" end="^[1-9 ]"re=s-1,he=s-1,me=s-1 syn sync minlines=1000 -- cgit v1.2.3 From e95c91edb81f1043247817f733de91ad751efaf9 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 5 Feb 2019 11:00:10 +0100 Subject: tv bash-fzf-history: init --- tv/5pkgs/simple/bash-fzf-history.nix | 91 ++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 tv/5pkgs/simple/bash-fzf-history.nix diff --git a/tv/5pkgs/simple/bash-fzf-history.nix b/tv/5pkgs/simple/bash-fzf-history.nix new file mode 100644 index 0000000..e9a21b9 --- /dev/null +++ b/tv/5pkgs/simple/bash-fzf-history.nix @@ -0,0 +1,91 @@ +with import ; +{ pkgs + +, edit-key ? "ctrl-e" +, exec-key ? "enter" +, edit-mark ? "${mark-prefix}${edit-key}" +, exec-mark ? "${mark-prefix}${exec-key}" +, edit-command ? "\"\"" +, exec-command ? "accept-line" +, mark-prefix ? " #FZFKEY:" +, finish-keyseq ? "\\C-x\\C-p" +, rebind-keyseq ? "\\C-x\\C-o" + +, start-keyseq ? "\\C-f" +, load-keyseq ? start-keyseq +}: let + script = pkgs.writeBash "bash-fzf-history.sh" '' + if ! command -v fzf >/dev/null; then + # Alternatively rewrite ${pkgs.fzf}/share/fzf/* to use absolute paths. + fzf() { + ${pkgs.fzf}/bin/fzf "$@" + } + fi + + . ${pkgs.fzf}/share/fzf/key-bindings.bash + . ${pkgs.fzf}/share/fzf/completion.bash + + FZF_DEFAULT_OPTS='${toString [ + /* sh */ "--height=40%" + /* sh */ "--inline-info" + /* sh */ "--min-height=4" + /* sh */ "--reverse" + ]}' + + __fzf_history__() ( + result=$( + HISTTIMEFORMAT= history | + FZF_DEFAULT_OPTS="${toString [ + /* sh */ "--tac" + /* sh */ "--sync" + /* sh */ "-n2..,.." + /* sh */ "--tiebreak=index" + /* sh */ "--bind=ctrl-r:toggle-sort" + /* sh */ "--expect=${edit-key},${exec-key}" + /* sh */ "$FZF_DEFAULT_OPTS" + /* sh */ "+m" + ]}" \ + ${pkgs.fzf}/bin/fzf + ) + if test -n "$result"; then + shopt -s extglob + + key=''${result%%$'\n'*} + line=''${result##*([^0-9])} + index=''${line%%[^0-9]*} + command=''${line##*([0-9 ])} + + echo "$command${mark-prefix}$key" + else + # Ensure no empty new line gets produced when fzf was aborted. + echo '${edit-mark}' + fi + ) + + __fzf_rebind_finish_keyseq__() { + local suffix= + case $READLINE_LINE in + *'${edit-mark}') + suffix='${edit-mark}' + bind '"${finish-keyseq}": ${edit-command}' + ;; + *'${exec-mark}') + suffix='${exec-mark}' + bind '"${finish-keyseq}": ${exec-command}' + ;; + esac + READLINE_LINE=${"\${READLINE_LINE:0:-\${#suffix}}"} + } + bind -x '"${rebind-keyseq}": __fzf_rebind_finish_keyseq__' + + bind '"\C-r": reverse-search-history' + bind '"${start-keyseq}": " \C-e\C-u\C-y\ey\C-u`__fzf_history__`\e\C-e\er\e^${rebind-keyseq}${finish-keyseq}"' + + echo '# fzf key bindings loaded:' >&2 + bind -s | ${pkgs.gnugrep}/bin/grep __fzf_ >&2 + ''; +in + script // + rec { + bind = /* sh */ ''bind -x '"${load-keyseq}": . ${script}' ''; + } -- cgit v1.2.3 From cbfe1d373c2086c8f6f6584860782e3666bdedeb Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 5 Feb 2019 11:00:57 +0100 Subject: tv bash: use fzf-history --- tv/2configs/bash/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tv/2configs/bash/default.nix b/tv/2configs/bash/default.nix index d767393..86e5598 100644 --- a/tv/2configs/bash/default.nix +++ b/tv/2configs/bash/default.nix @@ -27,6 +27,8 @@ with import ; export NIX_PATH="stockholm=$HOME/stockholm:$NIX_PATH" ;; esac + + ${pkgs.bash-fzf-history.bind} ''; promptInit = /* sh */ '' case $UID in -- cgit v1.2.3 From b4558157292b1019cf50218105c388a629f86d13 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 5 Feb 2019 11:06:17 +0100 Subject: tv bash: add timestamps to histfile --- tv/2configs/bash/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/tv/2configs/bash/default.nix b/tv/2configs/bash/default.nix index 86e5598..42914e0 100644 --- a/tv/2configs/bash/default.nix +++ b/tv/2configs/bash/default.nix @@ -8,6 +8,7 @@ with import ; HISTCONTROL='erasedups:ignorespace' HISTSIZE=65536 HISTFILESIZE=$HISTSIZE + HISTTIMEFORMAT= shopt -s checkhash shopt -s histappend histreedit histverify -- cgit v1.2.3 From ab496ae3fe25bc80ba4be2bfd6eb2a0292f3f8ca Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 5 Feb 2019 11:53:31 +0100 Subject: tv bash-fzf-history: use array instead of extglob --- tv/5pkgs/simple/bash-fzf-history.nix | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tv/5pkgs/simple/bash-fzf-history.nix b/tv/5pkgs/simple/bash-fzf-history.nix index e9a21b9..8b3fe9e 100644 --- a/tv/5pkgs/simple/bash-fzf-history.nix +++ b/tv/5pkgs/simple/bash-fzf-history.nix @@ -33,7 +33,8 @@ with import ; ]}' __fzf_history__() ( - result=$( + IFS=$'\n' + result=( $( HISTTIMEFORMAT= history | FZF_DEFAULT_OPTS="${toString [ /* sh */ "--tac" @@ -45,15 +46,18 @@ with import ; /* sh */ "$FZF_DEFAULT_OPTS" /* sh */ "+m" ]}" \ - ${pkgs.fzf}/bin/fzf - ) + ${pkgs.fzf}/bin/fzf | + ${pkgs.gnused}/bin/sed ' + /^ *[0-9]/{ + s/^ *// + s/ \+/\n/;# index + } + ' + ) ) if test -n "$result"; then - shopt -s extglob - - key=''${result%%$'\n'*} - line=''${result##*([^0-9])} - index=''${line%%[^0-9]*} - command=''${line##*([0-9 ])} + key=''${result[0]} + index=''${result[1]} + command=''${result[2]} echo "$command${mark-prefix}$key" else -- cgit v1.2.3 From 286b45c606793fe58aae8b728e9bc589747c979a Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 5 Feb 2019 11:54:03 +0100 Subject: tv bash-fzf-history: show timestamp --- tv/5pkgs/simple/bash-fzf-history.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tv/5pkgs/simple/bash-fzf-history.nix b/tv/5pkgs/simple/bash-fzf-history.nix index 8b3fe9e..7b92ea0 100644 --- a/tv/5pkgs/simple/bash-fzf-history.nix +++ b/tv/5pkgs/simple/bash-fzf-history.nix @@ -35,8 +35,9 @@ with import ; __fzf_history__() ( IFS=$'\n' result=( $( - HISTTIMEFORMAT= history | + HISTTIMEFORMAT=$'\e[38;5;244m%Y-%m-%dT%H:%M:%S\e[m ' history | FZF_DEFAULT_OPTS="${toString [ + /* sh */ "--ansi" /* sh */ "--tac" /* sh */ "--sync" /* sh */ "-n2..,.." @@ -51,13 +52,15 @@ with import ; /^ *[0-9]/{ s/^ *// s/ \+/\n/;# index + s/ \+/\n/;# date } ' ) ) if test -n "$result"; then key=''${result[0]} index=''${result[1]} - command=''${result[2]} + date=''${result[2]} + command=''${result[3]} echo "$command${mark-prefix}$key" else -- cgit v1.2.3 From ce1a7ca79aad4eea64c953b8a7f273eac28ab4b2 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 5 Feb 2019 13:11:46 +0100 Subject: tv bash-fzf-history: support unknown timestamps --- tv/5pkgs/simple/bash-fzf-history.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tv/5pkgs/simple/bash-fzf-history.nix b/tv/5pkgs/simple/bash-fzf-history.nix index 7b92ea0..b603ded 100644 --- a/tv/5pkgs/simple/bash-fzf-history.nix +++ b/tv/5pkgs/simple/bash-fzf-history.nix @@ -35,7 +35,12 @@ with import ; __fzf_history__() ( IFS=$'\n' result=( $( + # To add "unknown timestamps" to each line of the history: + # sed -i '/^#[0-9]/{n;b};s/^/#1\n/' "$HISTFILE" HISTTIMEFORMAT=$'\e[38;5;244m%Y-%m-%dT%H:%M:%S\e[m ' history | + ${pkgs.gnused}/bin/sed ' + s/\(\x1b\[[0-9;]*\)244m1970-[0-9T:-]*/\1237m????-??-??T??:??:??/ + ' | FZF_DEFAULT_OPTS="${toString [ /* sh */ "--ansi" /* sh */ "--tac" -- cgit v1.2.3 From 09491876e98768dcc1b50de51917958322421ca0 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 7 Feb 2019 19:04:19 +0100 Subject: tv gitrepos: add flameshot-once --- tv/2configs/gitrepos.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tv/2configs/gitrepos.nix b/tv/2configs/gitrepos.nix index 725ddef..95ab75b 100644 --- a/tv/2configs/gitrepos.nix +++ b/tv/2configs/gitrepos.nix @@ -47,6 +47,9 @@ let { disko = { cgit.desc = "declarative partitioning and formatting tool"; }; + flameshot-once = { + cgit.desc = "flameshot runner that automatically starts/stops the daemon"; + }; fswm = { cgit.desc = "simple full screen window manager"; }; -- cgit v1.2.3 From e7d49bd0b4986703c04e0cfa1ef1841e504e33f0 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 31 Jan 2019 11:15:58 +0100 Subject: tv rxvt_unicode: fetch patch --- tv/5pkgs/override/default.nix | 2 +- tv/5pkgs/override/rxvt_unicode.nix | 9 +++++ tv/5pkgs/override/rxvt_unicode/default.nix | 6 ---- .../rxvt_unicode/finish-running-selection.patch | 41 ---------------------- 4 files changed, 10 insertions(+), 48 deletions(-) create mode 100644 tv/5pkgs/override/rxvt_unicode.nix delete mode 100644 tv/5pkgs/override/rxvt_unicode/default.nix delete mode 100644 tv/5pkgs/override/rxvt_unicode/finish-running-selection.patch diff --git a/tv/5pkgs/override/default.nix b/tv/5pkgs/override/default.nix index cd7c564..99c1b3e 100644 --- a/tv/5pkgs/override/default.nix +++ b/tv/5pkgs/override/default.nix @@ -1,6 +1,6 @@ with import ; self: super: { - rxvt_unicode = self.callPackage ./rxvt_unicode { + rxvt_unicode = self.callPackage ./rxvt_unicode.nix { rxvt_unicode = super.rxvt_unicode; }; } diff --git a/tv/5pkgs/override/rxvt_unicode.nix b/tv/5pkgs/override/rxvt_unicode.nix new file mode 100644 index 0000000..da657fb --- /dev/null +++ b/tv/5pkgs/override/rxvt_unicode.nix @@ -0,0 +1,9 @@ +{ fetchurl, rxvt_unicode }: +rxvt_unicode.overrideAttrs (old: { + patches = old.patches ++ [ + (fetchurl { + url = https://cgit.krebsco.de/rxvt-unicode/patch/?id=15f3f94; + sha256 = "12vldwsds27c9l15ffc6svk9mj17jhypcz736pvpmpqbsymlkz2p"; + }) + ]; +}) diff --git a/tv/5pkgs/override/rxvt_unicode/default.nix b/tv/5pkgs/override/rxvt_unicode/default.nix deleted file mode 100644 index 858a46b..0000000 --- a/tv/5pkgs/override/rxvt_unicode/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ rxvt_unicode }: -rxvt_unicode.overrideAttrs (old: { - patches = old.patches ++ [ - ./finish-running-selection.patch - ]; -}) diff --git a/tv/5pkgs/override/rxvt_unicode/finish-running-selection.patch b/tv/5pkgs/override/rxvt_unicode/finish-running-selection.patch deleted file mode 100644 index a342ccf..0000000 --- a/tv/5pkgs/override/rxvt_unicode/finish-running-selection.patch +++ /dev/null @@ -1,41 +0,0 @@ -diff --git a/src/rxvttoolkit.h b/src/rxvttoolkit.h -index 56c9a3f..429055d 100644 ---- a/src/rxvttoolkit.h -+++ b/src/rxvttoolkit.h -@@ -384,6 +384,7 @@ struct rxvt_selection - { - rxvt_selection (rxvt_display *disp, int selnum, Time tm, Window win, Atom prop, rxvt_term *term); - void run (); -+ void finish (char *data = 0, unsigned int len = 0); - ~rxvt_selection (); - - rxvt_term *term; // terminal to paste to, may be 0 -@@ -404,7 +405,6 @@ private: - void timer_cb (ev::timer &w, int revents); ev::timer timer_ev; - void x_cb (XEvent &xev); xevent_watcher x_ev; - -- void finish (char *data = 0, unsigned int len = 0); - void stop (); - bool request (Atom target, int selnum); - void handle_selection (Window win, Atom prop, bool delete_prop); -diff --git a/src/screen.C b/src/screen.C -index 9eb375a..77e7109 100644 ---- a/src/screen.C -+++ b/src/screen.C -@@ -2736,11 +2736,11 @@ rxvt_term::paste (char *data, unsigned int len) NOTHROW - void - rxvt_term::selection_request (Time tm, int selnum) NOTHROW - { -- if (!selection_req) -- { -- selection_req = new rxvt_selection (display, selnum, tm, vt, xa[XA_VT_SELECTION], this); -- selection_req->run (); -- } -+ if (selection_req) -+ selection_req->finish (); -+ -+ selection_req = new rxvt_selection (display, selnum, tm, vt, xa[XA_VT_SELECTION], this); -+ selection_req->run (); - } - - /* ------------------------------------------------------------------------- */ -- cgit v1.2.3 From eb735b59065becf2cf9a0690254e2f6af998f6dd Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 2 Feb 2019 20:14:29 +0100 Subject: tv vim-syntax-nix-nested: add writer{Ext,Name} --- tv/2configs/vim.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix index 3794628..9f78d6e 100644 --- a/tv/2configs/vim.nix +++ b/tv/2configs/vim.nix @@ -250,6 +250,9 @@ let { def = k: ''${k}[ \t\r\n]*=''; writer = k: ''write${k}[^ \t\r\n]*[ \t\r\n]*\("[^"]*"\|[a-z]\+\)''; + writerExt = k: writerName ''[^"]*\.${k}''; + writerName = k: ''write[^ \t\r\n]*[ \t\r\n]*"${k}"''; + in { c = {}; cabal = {}; @@ -257,7 +260,7 @@ let { haskell = {}; jq.extraStart = alts [ (writer "Jq") - ''write[^ \t\r\n]*[ \t\r\n]*"[^"]*\.jq"'' + (writerExt "jq") ]; javascript.extraStart = ''/\* js \*/''; lua = {}; @@ -287,8 +290,10 @@ let { (writer (alts (map capitalize shells))) ]; yaml = {}; - vim.extraStart = - ''write[^ \t\r\n]*[ \t\r\n]*"\(\([^"]*\.\)\?vimrc\|[^"]*\.vim\)"''; + vim.extraStart = alts [ + (writerExt "vim") + (writerName ''\([^"]*\.\)\?vimrc'') + ]; xdefaults = {}; }))} -- cgit v1.2.3 From 35091bbf91cc997f67aa7289be29a9115337fd99 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 2 Feb 2019 20:20:44 +0100 Subject: tv vim-syntax-nix-nested: detect .vim".text --- tv/2configs/vim.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix index 9f78d6e..7e37ef3 100644 --- a/tv/2configs/vim.nix +++ b/tv/2configs/vim.nix @@ -130,14 +130,14 @@ let { ''; }))) ((rtp: rtp // { inherit rtp; }) (pkgs.write "vim-syntax-nix-nested" { - "/syntax/haskell.vim".text = /* vim */ '' + "/syntax/haskell.vim".text = '' syn region String start=+\[[[:alnum:]]*|+ end=+|]+ hi link ConId Identifier hi link VarId Identifier hi link hsDelimiter Delimiter ''; - "/syntax/nix.vim".text = /* vim */ '' + "/syntax/nix.vim".text = '' "" Quit when a (custom) syntax file was already loaded "if exists("b:current_syntax") " finish @@ -291,6 +291,7 @@ let { ]; yaml = {}; vim.extraStart = alts [ + (def ''"[^"]*\.vim"\.text'') (writerExt "vim") (writerName ''\([^"]*\.\)\?vimrc'') ]; @@ -334,7 +335,7 @@ let { set isk=@,48-57,_,192-255,-,' ''; - "/syntax/sed.vim".text = /* vim */ '' + "/syntax/sed.vim".text = '' syn region sedBranch \ matchgroup=sedFunction start="T" \ matchgroup=sedSemicolon end=";\|$" -- cgit v1.2.3 From 51e88ec80f5a4b4e38029698608124e8ff2cfe70 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 2 Feb 2019 20:24:11 +0100 Subject: tv vim haskell: isk+=' --- tv/2configs/vim.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix index 7e37ef3..fe14828 100644 --- a/tv/2configs/vim.nix +++ b/tv/2configs/vim.nix @@ -129,6 +129,19 @@ let { command! -n=0 -bar ShowSyntax :call ShowSyntax() ''; }))) + ((rtp: rtp // { inherit rtp; }) (pkgs.write "vim-tv" { + # + # Haskell + # + "/ftplugin/haskell.vim".text = '' + if exists("g:vim_tv_ftplugin_haskell_loaded") + finish + endif + let g:vim_tv_ftplugin_haskell_loaded = 1 + + setlocal iskeyword+=' + ''; + })) ((rtp: rtp // { inherit rtp; }) (pkgs.write "vim-syntax-nix-nested" { "/syntax/haskell.vim".text = '' syn region String start=+\[[[:alnum:]]*|+ end=+|]+ -- cgit v1.2.3 From 79321442836ffdc6a3c6b3d0f5f2bf67437458e9 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 2 Feb 2019 21:21:48 +0100 Subject: tv vim: add TODO ft --- tv/2configs/vim.nix | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix index fe14828..de843a3 100644 --- a/tv/2configs/vim.nix +++ b/tv/2configs/vim.nix @@ -141,6 +141,43 @@ let { setlocal iskeyword+=' ''; + # + # TODO + # + "/ftdetect/todo.vim".text = '' + au BufRead,BufNewFile TODO set ft=todo + ''; + "/ftplugin/todo.vim".text = '' + setlocal foldmethod=syntax + ''; + "/syntax/todo.vim".text = '' + syn match Comment /#.*/ + + syn match todoDate /^[1-9]\S*/ + \ nextgroup=todoSummary + + syn region todoSummary + \ contained + \ contains=todoTag + \ start="." end="$\n" + \ nextgroup=todoBlock + + syn match todoTag /\[[a-z]\+\]/hs=s+1,he=e-1 + \ contained + + syn region todoBlock + \ contained + \ contains=Comment + \ fold + \ start="^[^1-9]" end="^[1-9]"re=s-1,he=s-1,me=s-1 + + syn sync minlines=1000 + + hi todoDate ctermfg=255 + hi todoSummary ctermfg=229 + hi todoBlock ctermfg=248 + hi todoTag ctermfg=217 + ''; })) ((rtp: rtp // { inherit rtp; }) (pkgs.write "vim-syntax-nix-nested" { "/syntax/haskell.vim".text = '' -- cgit v1.2.3 From 280a66c3a57b35dbae9e97c45a2a0fef9c1f4e8c Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 2 Feb 2019 23:15:16 +0100 Subject: tv vim todo: allow A-Z in tags --- tv/2configs/vim.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix index de843a3..575a3bc 100644 --- a/tv/2configs/vim.nix +++ b/tv/2configs/vim.nix @@ -162,7 +162,7 @@ let { \ start="." end="$\n" \ nextgroup=todoBlock - syn match todoTag /\[[a-z]\+\]/hs=s+1,he=e-1 + syn match todoTag /\[[A-Za-z]\+\]/hs=s+1,he=e-1 \ contained syn region todoBlock -- cgit v1.2.3 From 244f1551f9863330418dcdfd3a5385b3f6763c2f Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 3 Feb 2019 13:39:30 +0100 Subject: tv vim todo: form feed ends a block --- tv/2configs/vim.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix index 575a3bc..9942ff6 100644 --- a/tv/2configs/vim.nix +++ b/tv/2configs/vim.nix @@ -169,7 +169,7 @@ let { \ contained \ contains=Comment \ fold - \ start="^[^1-9]" end="^[1-9]"re=s-1,he=s-1,me=s-1 + \ start="^[^1-9]" end="^[1-9 ]"re=s-1,he=s-1,me=s-1 syn sync minlines=1000 -- cgit v1.2.3 From 55de6782af681888ba6e521e7b9bd442a5b1a5cb Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 5 Feb 2019 11:00:10 +0100 Subject: tv bash-fzf-history: init --- tv/5pkgs/simple/bash-fzf-history.nix | 91 ++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 tv/5pkgs/simple/bash-fzf-history.nix diff --git a/tv/5pkgs/simple/bash-fzf-history.nix b/tv/5pkgs/simple/bash-fzf-history.nix new file mode 100644 index 0000000..e9a21b9 --- /dev/null +++ b/tv/5pkgs/simple/bash-fzf-history.nix @@ -0,0 +1,91 @@ +with import ; +{ pkgs + +, edit-key ? "ctrl-e" +, exec-key ? "enter" +, edit-mark ? "${mark-prefix}${edit-key}" +, exec-mark ? "${mark-prefix}${exec-key}" +, edit-command ? "\"\"" +, exec-command ? "accept-line" +, mark-prefix ? " #FZFKEY:" +, finish-keyseq ? "\\C-x\\C-p" +, rebind-keyseq ? "\\C-x\\C-o" + +, start-keyseq ? "\\C-f" +, load-keyseq ? start-keyseq +}: let + script = pkgs.writeBash "bash-fzf-history.sh" '' + if ! command -v fzf >/dev/null; then + # Alternatively rewrite ${pkgs.fzf}/share/fzf/* to use absolute paths. + fzf() { + ${pkgs.fzf}/bin/fzf "$@" + } + fi + + . ${pkgs.fzf}/share/fzf/key-bindings.bash + . ${pkgs.fzf}/share/fzf/completion.bash + + FZF_DEFAULT_OPTS='${toString [ + /* sh */ "--height=40%" + /* sh */ "--inline-info" + /* sh */ "--min-height=4" + /* sh */ "--reverse" + ]}' + + __fzf_history__() ( + result=$( + HISTTIMEFORMAT= history | + FZF_DEFAULT_OPTS="${toString [ + /* sh */ "--tac" + /* sh */ "--sync" + /* sh */ "-n2..,.." + /* sh */ "--tiebreak=index" + /* sh */ "--bind=ctrl-r:toggle-sort" + /* sh */ "--expect=${edit-key},${exec-key}" + /* sh */ "$FZF_DEFAULT_OPTS" + /* sh */ "+m" + ]}" \ + ${pkgs.fzf}/bin/fzf + ) + if test -n "$result"; then + shopt -s extglob + + key=''${result%%$'\n'*} + line=''${result##*([^0-9])} + index=''${line%%[^0-9]*} + command=''${line##*([0-9 ])} + + echo "$command${mark-prefix}$key" + else + # Ensure no empty new line gets produced when fzf was aborted. + echo '${edit-mark}' + fi + ) + + __fzf_rebind_finish_keyseq__() { + local suffix= + case $READLINE_LINE in + *'${edit-mark}') + suffix='${edit-mark}' + bind '"${finish-keyseq}": ${edit-command}' + ;; + *'${exec-mark}') + suffix='${exec-mark}' + bind '"${finish-keyseq}": ${exec-command}' + ;; + esac + READLINE_LINE=${"\${READLINE_LINE:0:-\${#suffix}}"} + } + bind -x '"${rebind-keyseq}": __fzf_rebind_finish_keyseq__' + + bind '"\C-r": reverse-search-history' + bind '"${start-keyseq}": " \C-e\C-u\C-y\ey\C-u`__fzf_history__`\e\C-e\er\e^${rebind-keyseq}${finish-keyseq}"' + + echo '# fzf key bindings loaded:' >&2 + bind -s | ${pkgs.gnugrep}/bin/grep __fzf_ >&2 + ''; +in + script // + rec { + bind = /* sh */ ''bind -x '"${load-keyseq}": . ${script}' ''; + } -- cgit v1.2.3 From 7f11da400dab2ce180af799c257dff1ff2996781 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 5 Feb 2019 11:00:57 +0100 Subject: tv bash: use fzf-history --- tv/2configs/bash/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tv/2configs/bash/default.nix b/tv/2configs/bash/default.nix index d767393..86e5598 100644 --- a/tv/2configs/bash/default.nix +++ b/tv/2configs/bash/default.nix @@ -27,6 +27,8 @@ with import ; export NIX_PATH="stockholm=$HOME/stockholm:$NIX_PATH" ;; esac + + ${pkgs.bash-fzf-history.bind} ''; promptInit = /* sh */ '' case $UID in -- cgit v1.2.3 From 483c26af7cb8ae71fc65704a2062ec2ca618a1ac Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 5 Feb 2019 11:06:17 +0100 Subject: tv bash: add timestamps to histfile --- tv/2configs/bash/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/tv/2configs/bash/default.nix b/tv/2configs/bash/default.nix index 86e5598..42914e0 100644 --- a/tv/2configs/bash/default.nix +++ b/tv/2configs/bash/default.nix @@ -8,6 +8,7 @@ with import ; HISTCONTROL='erasedups:ignorespace' HISTSIZE=65536 HISTFILESIZE=$HISTSIZE + HISTTIMEFORMAT= shopt -s checkhash shopt -s histappend histreedit histverify -- cgit v1.2.3 From 710238039b5d326b57cdd1ca3a2606f322cc54a6 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 5 Feb 2019 11:53:31 +0100 Subject: tv bash-fzf-history: use array instead of extglob --- tv/5pkgs/simple/bash-fzf-history.nix | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tv/5pkgs/simple/bash-fzf-history.nix b/tv/5pkgs/simple/bash-fzf-history.nix index e9a21b9..8b3fe9e 100644 --- a/tv/5pkgs/simple/bash-fzf-history.nix +++ b/tv/5pkgs/simple/bash-fzf-history.nix @@ -33,7 +33,8 @@ with import ; ]}' __fzf_history__() ( - result=$( + IFS=$'\n' + result=( $( HISTTIMEFORMAT= history | FZF_DEFAULT_OPTS="${toString [ /* sh */ "--tac" @@ -45,15 +46,18 @@ with import ; /* sh */ "$FZF_DEFAULT_OPTS" /* sh */ "+m" ]}" \ - ${pkgs.fzf}/bin/fzf - ) + ${pkgs.fzf}/bin/fzf | + ${pkgs.gnused}/bin/sed ' + /^ *[0-9]/{ + s/^ *// + s/ \+/\n/;# index + } + ' + ) ) if test -n "$result"; then - shopt -s extglob - - key=''${result%%$'\n'*} - line=''${result##*([^0-9])} - index=''${line%%[^0-9]*} - command=''${line##*([0-9 ])} + key=''${result[0]} + index=''${result[1]} + command=''${result[2]} echo "$command${mark-prefix}$key" else -- cgit v1.2.3 From 14a017e9e1b6784ac59c616821936e736cddad73 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 5 Feb 2019 11:54:03 +0100 Subject: tv bash-fzf-history: show timestamp --- tv/5pkgs/simple/bash-fzf-history.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tv/5pkgs/simple/bash-fzf-history.nix b/tv/5pkgs/simple/bash-fzf-history.nix index 8b3fe9e..7b92ea0 100644 --- a/tv/5pkgs/simple/bash-fzf-history.nix +++ b/tv/5pkgs/simple/bash-fzf-history.nix @@ -35,8 +35,9 @@ with import ; __fzf_history__() ( IFS=$'\n' result=( $( - HISTTIMEFORMAT= history | + HISTTIMEFORMAT=$'\e[38;5;244m%Y-%m-%dT%H:%M:%S\e[m ' history | FZF_DEFAULT_OPTS="${toString [ + /* sh */ "--ansi" /* sh */ "--tac" /* sh */ "--sync" /* sh */ "-n2..,.." @@ -51,13 +52,15 @@ with import ; /^ *[0-9]/{ s/^ *// s/ \+/\n/;# index + s/ \+/\n/;# date } ' ) ) if test -n "$result"; then key=''${result[0]} index=''${result[1]} - command=''${result[2]} + date=''${result[2]} + command=''${result[3]} echo "$command${mark-prefix}$key" else -- cgit v1.2.3 From 4e50762689b334f305189bf60dd3b96029a92d97 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 5 Feb 2019 13:11:46 +0100 Subject: tv bash-fzf-history: support unknown timestamps --- tv/5pkgs/simple/bash-fzf-history.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tv/5pkgs/simple/bash-fzf-history.nix b/tv/5pkgs/simple/bash-fzf-history.nix index 7b92ea0..b603ded 100644 --- a/tv/5pkgs/simple/bash-fzf-history.nix +++ b/tv/5pkgs/simple/bash-fzf-history.nix @@ -35,7 +35,12 @@ with import ; __fzf_history__() ( IFS=$'\n' result=( $( + # To add "unknown timestamps" to each line of the history: + # sed -i '/^#[0-9]/{n;b};s/^/#1\n/' "$HISTFILE" HISTTIMEFORMAT=$'\e[38;5;244m%Y-%m-%dT%H:%M:%S\e[m ' history | + ${pkgs.gnused}/bin/sed ' + s/\(\x1b\[[0-9;]*\)244m1970-[0-9T:-]*/\1237m????-??-??T??:??:??/ + ' | FZF_DEFAULT_OPTS="${toString [ /* sh */ "--ansi" /* sh */ "--tac" -- cgit v1.2.3 From c6ca7ead112fe9aff4658f551d8b47f94608eff8 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 7 Feb 2019 19:04:19 +0100 Subject: tv gitrepos: add flameshot-once --- tv/2configs/gitrepos.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tv/2configs/gitrepos.nix b/tv/2configs/gitrepos.nix index 725ddef..95ab75b 100644 --- a/tv/2configs/gitrepos.nix +++ b/tv/2configs/gitrepos.nix @@ -47,6 +47,9 @@ let { disko = { cgit.desc = "declarative partitioning and formatting tool"; }; + flameshot-once = { + cgit.desc = "flameshot runner that automatically starts/stops the daemon"; + }; fswm = { cgit.desc = "simple full screen window manager"; }; -- cgit v1.2.3 From ed3ada7b3cf1dd06d3cc7410f887e2059efd37cc Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 8 Feb 2019 18:02:29 +0100 Subject: tv xmonad: add dbus --- tv/2configs/xserver/default.nix | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index f68e8e6..051e12e 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -48,10 +48,24 @@ in { systemd.services.xmonad = let xmonad = "${pkgs.haskellPackages.xmonad-tv}/bin/xmonad"; - xmonad-prepare = pkgs.writeDash "xmonad-prepare" '' + xmonad-start = pkgs.writeDash "xmonad-start" '' ${pkgs.coreutils}/bin/mkdir -p "$XMONAD_CACHE_DIR" ${pkgs.coreutils}/bin/mkdir -p "$XMONAD_CONFIG_DIR" ${pkgs.coreutils}/bin/mkdir -p "$XMONAD_DATA_DIR" + + f=$HOME/.dbus/session-bus/$(${pkgs.coreutils}/bin/cat /etc/machine-id)-${ + toString config.services.xserver.display + } + if test -e "$f" && + . "$f" && + ${pkgs.coreutils}/bin/kill -0 "$DBUS_SESSION_BUS_PID" + then + export DBUS_SESSION_BUS_ADDRESS + else + eval "$(${pkgs.dbus.lib}/bin/dbus-launch --sh-syntax)" + fi + + exec ${xmonad} ''; xmonad-ready = pkgs.writeDash "xmonad-ready" '' { @@ -97,8 +111,7 @@ in { "/run/wrappers" # for su ]; serviceConfig = { - ExecStartPre = "@${xmonad-prepare} xmonad-prepare"; - ExecStart = "@${xmonad} xmonad-${currentSystem}"; + ExecStart = "@${xmonad-start} xmonad-${currentSystem}"; ExecStop = "@${xmonad} xmonad-${currentSystem} --shutdown"; SyslogIdentifier = "xmonad"; User = cfg.user.name; -- cgit v1.2.3 From 351eb5bccf7843df95e87eebad16c2e02fa7de7f Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 9 Feb 2019 04:04:23 +0100 Subject: tv xmonad: remove unused language extensions --- tv/5pkgs/haskell/xmonad-tv/src/main.hs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tv/5pkgs/haskell/xmonad-tv/src/main.hs b/tv/5pkgs/haskell/xmonad-tv/src/main.hs index b7d4e9b..e784802 100644 --- a/tv/5pkgs/haskell/xmonad-tv/src/main.hs +++ b/tv/5pkgs/haskell/xmonad-tv/src/main.hs @@ -1,8 +1,4 @@ -{-# LANGUAGE DeriveDataTypeable #-} -- for XS -{-# LANGUAGE FlexibleContexts #-} -- for xmonad' {-# LANGUAGE LambdaCase #-} -{-# LANGUAGE ScopedTypeVariables #-} - module Main (main) where -- cgit v1.2.3 From b5e608263981d994315e194a600d4bb930b9f17c Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 9 Feb 2019 04:05:39 +0100 Subject: tv xmonad: use launch --- tv/5pkgs/haskell/xmonad-tv/src/main.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tv/5pkgs/haskell/xmonad-tv/src/main.hs b/tv/5pkgs/haskell/xmonad-tv/src/main.hs index e784802..c528017 100644 --- a/tv/5pkgs/haskell/xmonad-tv/src/main.hs +++ b/tv/5pkgs/haskell/xmonad-tv/src/main.hs @@ -47,7 +47,7 @@ mainNoArgs = do let width = 1366 workspaces0 <- getWorkspaces0 handleShutdownEvent <- newShutdownEventHandler - xmonad + launch $ withUrgencyHook (SpawnUrgencyHook "echo emit Urgency ") $ def { terminal = Paths.urxvtc -- cgit v1.2.3 From 081af8ac42f6c2cf4e2afefd1ad3853f1eecd853 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 10 Feb 2019 14:22:54 +0100 Subject: tv iptables: add extra{4,6} --- tv/3modules/iptables.nix | 55 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/tv/3modules/iptables.nix b/tv/3modules/iptables.nix index 56861dc..3f1df92 100644 --- a/tv/3modules/iptables.nix +++ b/tv/3modules/iptables.nix @@ -9,6 +9,33 @@ let { config = lib.mkIf cfg.enable imp; }; + extraTypes = { + rules = types.submodule { + options = { + nat.OUTPUT = mkOption { + type = with types; listOf str; + default = []; + }; + nat.PREROUTING = mkOption { + type = with types; listOf str; + default = []; + }; + nat.POSTROUTING = mkOption { + type = with types; listOf str; + default = []; + }; + filter.FORWARD = mkOption { + type = with types; listOf str; + default = []; + }; + filter.INPUT = mkOption { + type = with types; listOf str; + default = []; + }; + }; + }; + }; + api = { enable = mkEnableOption "tv.iptables"; @@ -37,19 +64,19 @@ let { default = []; }; - extra = { - nat.POSTROUTING = mkOption { - type = with types; listOf str; - default = []; - }; - filter.FORWARD = mkOption { - type = with types; listOf str; - default = []; - }; - filter.INPUT = mkOption { - type = with types; listOf str; - default = []; - }; + extra = mkOption { + default = {}; + type = extraTypes.rules; + }; + + extra4 = mkOption { + default = {}; + type = extraTypes.rules; + }; + + extra6 = mkOption { + default = {}; + type = extraTypes.rules; }; }; @@ -112,6 +139,7 @@ let { "-o lo -p tcp -m tcp --dport 11423 -j REDIRECT --to-ports 22" ]} ${formatTable cfg.extra.nat} + ${formatTable cfg."extra${toString iptables-version}".nat} COMMIT *filter :INPUT DROP [0:0] @@ -129,6 +157,7 @@ let { ++ ["-i retiolum -j Retiolum"] )} ${formatTable cfg.extra.filter} + ${formatTable cfg."extra${toString iptables-version}".filter} ${concatMapStringsSep "\n" (rule: "-A Retiolum ${rule}") ([] ++ optional (cfg.accept-echo-request == "retiolum") accept-echo-request ++ map accept-tcp (unique (map toString cfg.input-retiolum-accept-tcp)) -- cgit v1.2.3 From 7fcec61ae6a13cb82ff88706c9205eff9774a8be Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 10 Feb 2019 14:36:31 +0100 Subject: tv iptables extraTypes: add Retiolum --- tv/3modules/iptables.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tv/3modules/iptables.nix b/tv/3modules/iptables.nix index 3f1df92..3974760 100644 --- a/tv/3modules/iptables.nix +++ b/tv/3modules/iptables.nix @@ -32,6 +32,10 @@ let { type = with types; listOf str; default = []; }; + filter.Retiolum = mkOption { + type = with types; listOf str; + default = []; + }; }; }; }; -- cgit v1.2.3 From 2647605a32f36033ea567a2831dbe332978fd95b Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 16 Feb 2019 15:39:17 +0100 Subject: lib.warnOldVersion: init --- lib/default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/default.nix b/lib/default.nix index 347830e..75086f8 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -145,6 +145,11 @@ let in filter (x: x != []) ([acc.chunk] ++ acc.chunks); + warnOldVersion = oldName: newName: + if compareVersions oldName newName != -1 then + trace "Upstream `${oldName}' gets overridden by `${newName}'." newName + else + newName; }; in -- cgit v1.2.3 From bfbeca92fb2c85edd1bbbed34ed3d27f854ed406 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 16 Feb 2019 16:01:03 +0100 Subject: tv bash-fzf-history: use overrideDerivation --- tv/5pkgs/simple/bash-fzf-history.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tv/5pkgs/simple/bash-fzf-history.nix b/tv/5pkgs/simple/bash-fzf-history.nix index b603ded..88a8e9e 100644 --- a/tv/5pkgs/simple/bash-fzf-history.nix +++ b/tv/5pkgs/simple/bash-fzf-history.nix @@ -97,7 +97,6 @@ with import ; bind -s | ${pkgs.gnugrep}/bin/grep __fzf_ >&2 ''; in - script // - rec { + script.overrideAttrs (old: rec { bind = /* sh */ ''bind -x '"${load-keyseq}": . ${script}' ''; - } + }) -- cgit v1.2.3 From fe08236da659ff27eda98c6170fabbf981455c80 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 20 Mar 2015 10:36:12 +0100 Subject: lib.xml: init --- lib/default.nix | 1 + lib/xml.nix | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 lib/xml.nix diff --git a/lib/default.nix b/lib/default.nix index 75086f8..8ba55b5 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -9,6 +9,7 @@ let krops = import ../submodules/krops/lib; shell = import ./shell.nix { inherit lib; }; types = nixpkgs-lib.types // import ./types.nix { inherit lib; }; + xml = import ./xml.nix { inherit lib; }; eq = x: y: x == y; ne = x: y: x != y; diff --git a/lib/xml.nix b/lib/xml.nix new file mode 100644 index 0000000..92f5521 --- /dev/null +++ b/lib/xml.nix @@ -0,0 +1,84 @@ +{ lib }: +with lib; +with builtins; +rec { + + # Use `term` to construct XML. + # + # Examples: + # + # (term "bool" null null) + # (term "cool" null []) + # (term "fool" { hurr = "durr"; } null) + # (term "hool" null [ + # (term "tool" null null) + # ]) + # + # See `render` for how these get transformed into actuall XML documents. + # + term = name: attrs: content: { + inherit name attrs content; + }; + + empty = term null null null; + + # Ref http://www.w3.org/TR/xml/#syntax + # + # Example: + # + # (quote "") #===> <cheez!> + # + quote = let + sub = { + "&" = "&"; + "<" = "<"; + ">" = ">"; + "'" = "'"; + "\"" = """; + }; + in + stringAsChars (c: sub.${c} or c); + + # Turn an XML element to an XML document string. + doc = t: + "${render t}"; + + # Render an XML element to a string. + # + # Rendering `empty` yields the empty string. + # + # Examples: + # + # (term "bool" null null) #===> + # (term "cool" null []) #===> + # (term "fool" { hurr = "durr"; } null) #===> + # (term "hool" null [ + # (term "tool" null null) + # ]) #===> + # + render = let + render-attrs = attrs: + getAttr (typeOf attrs) { + null = ""; + set = concatStrings (mapAttrsToList (n: v: " ${n}=\"${v}\"") attrs); + }; + + render-content = content: + getAttr (typeOf content) { + bool = toJSON content; + int = toJSON content; + list = concatMapStrings render content; + string = content; + }; + in + { name, attrs, content }: + if name == null + then "" + else let + attrs' = render-attrs attrs; + content' = render-content content; + in + if content == null + then "<${name}${attrs'}/>" + else "<${name}${attrs'}>${content'}"; +} -- cgit v1.2.3 From 3a25fe69295e477ea103ab7010e2a43e37191c62 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 20 Mar 2015 10:58:11 +0100 Subject: lib.xml.render-term: quote strings --- lib/xml.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/xml.nix b/lib/xml.nix index 92f5521..1605244 100644 --- a/lib/xml.nix +++ b/lib/xml.nix @@ -68,12 +68,16 @@ rec { bool = toJSON content; int = toJSON content; list = concatMapStrings render content; - string = content; + string = quote content; }; in { name, attrs, content }: + # XXX we're currently encoding too much information with `null`.. if name == null - then "" + then + if content == null + then "" + else content else let attrs' = render-attrs attrs; content' = render-content content; -- cgit v1.2.3 From 14189af488fec6d727b9949eccf0a22cc65ac589 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 16 Feb 2019 18:49:26 +0100 Subject: Revert "brscan4: init at 0.4.4-4" This reverts commit fabbe4fb3eeb883df0d22b6fdf4bc051d527155b. --- tv/5pkgs/default.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tv/5pkgs/default.nix b/tv/5pkgs/default.nix index 605d827..1b29824 100644 --- a/tv/5pkgs/default.nix +++ b/tv/5pkgs/default.nix @@ -13,6 +13,14 @@ foldl' mergeAttrs {} // { + brscan4 = overrideDerivation super.brscan4 (original: rec { + name = "brscan4-0.4.4-4"; + src = super.fetchurl { + url = "http://download.brother.com/welcome/dlf006645/${name}.amd64.deb"; + sha256 = "0xy5px96y1saq9l80vwvfn6anr2q42qlxdhm6ci2a0diwib5q9fd"; + }; + }); + # TODO use XDG_RUNTIME_DIR? cr = self.writeDashBin "cr" '' set -efu -- cgit v1.2.3 From 80ff70bd6ae0f98f3565b9a17b91d6d4d6f03816 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 16 Feb 2019 18:51:59 +0100 Subject: Revert "tv brscan4: init at 0.4.4-4" This reverts commit 36856376baf15af3aefee639df69d2d3a8d23d57. --- tv/5pkgs/default.nix | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tv/5pkgs/default.nix b/tv/5pkgs/default.nix index 1b29824..605d827 100644 --- a/tv/5pkgs/default.nix +++ b/tv/5pkgs/default.nix @@ -13,14 +13,6 @@ foldl' mergeAttrs {} // { - brscan4 = overrideDerivation super.brscan4 (original: rec { - name = "brscan4-0.4.4-4"; - src = super.fetchurl { - url = "http://download.brother.com/welcome/dlf006645/${name}.amd64.deb"; - sha256 = "0xy5px96y1saq9l80vwvfn6anr2q42qlxdhm6ci2a0diwib5q9fd"; - }; - }); - # TODO use XDG_RUNTIME_DIR? cr = self.writeDashBin "cr" '' set -efu -- cgit v1.2.3 From a2ebc2cb456e9ad3ece900ac88be69c250dff073 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 16 Feb 2019 19:18:04 +0100 Subject: lib.types.filename.check: remove unnecessary () --- lib/types.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/types.nix b/lib/types.nix index 17c1688..45c0098 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -539,7 +539,7 @@ rec { # POSIX.1‐2013, 3.278 Portable Filename Character Set filename = mkOptionType { name = "POSIX filename"; - check = test "([0-9A-Za-z._])[0-9A-Za-z._-]*"; + check = test "[0-9A-Za-z._][0-9A-Za-z._-]*"; merge = mergeOneOption; }; -- cgit v1.2.3 From 04b6533c7e4407783118beee22cb4d466a7e049e Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 16 Feb 2019 19:22:24 +0100 Subject: Revert "tv: add deploy alias" This reverts commit 288f895abbf1ada7d5cc3979fe51ac29c3148657. --- tv/2configs/default.nix | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tv/2configs/default.nix b/tv/2configs/default.nix index e18ba31..ac0a6af 100644 --- a/tv/2configs/default.nix +++ b/tv/2configs/default.nix @@ -80,13 +80,6 @@ with import ; ls = "ls -h --color=auto --group-directories-first"; dmesg = "dmesg -L --reltime"; view = "vim -R"; - - deploy = pkgs.writeDash "deploy" '' - set -eu - cd ~/stockholm - export SYSTEM="$1" - exec nix-shell -I stockholm="$PWD" --run 'deploy --system="$SYSTEM"' - ''; }; environment.variables = { -- cgit v1.2.3 From a7234ccaeadbdffcb88bc3ea4dd7b0d7adbbc48d Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 16 Feb 2019 19:29:25 +0100 Subject: tv vim: add todoComment --- tv/2configs/vim.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix index 9942ff6..20e1d65 100644 --- a/tv/2configs/vim.nix +++ b/tv/2configs/vim.nix @@ -151,7 +151,7 @@ let { setlocal foldmethod=syntax ''; "/syntax/todo.vim".text = '' - syn match Comment /#.*/ + syn match todoComment /#.*/ syn match todoDate /^[1-9]\S*/ \ nextgroup=todoSummary @@ -173,6 +173,7 @@ let { syn sync minlines=1000 + hi link todoComment Comment hi todoDate ctermfg=255 hi todoSummary ctermfg=229 hi todoBlock ctermfg=248 -- cgit v1.2.3 From c572737d856f2fd12632c7b2f755dfcaae7dae32 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 16 Feb 2019 19:29:40 +0100 Subject: tv vim: add xmodmap --- tv/2configs/vim.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix index 20e1d65..2dd2e74 100644 --- a/tv/2configs/vim.nix +++ b/tv/2configs/vim.nix @@ -347,6 +347,7 @@ let { (writerName ''\([^"]*\.\)\?vimrc'') ]; xdefaults = {}; + xmodmap = {}; }))} " Clear syntax that interferes with nixINSIDE_DOLLAR_CURLY. @@ -392,6 +393,9 @@ let { \ matchgroup=sedSemicolon end=";\|$" \ contains=sedWhitespace ''; + "/syntax/xmodmap.vim".text = '' + syn match xmodmapComment /^\s*!.*/ + ''; })) ]; -- cgit v1.2.3 From 51f21751e7e627cd8e3e7f3656eb269261d6fd06 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 16 Feb 2019 19:30:37 +0100 Subject: tv vim: map :ShowSyntax --- tv/2configs/vim.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix index 2dd2e74..a45e040 100644 --- a/tv/2configs/vim.nix +++ b/tv/2configs/vim.nix @@ -490,6 +490,8 @@ let { inoremap :tabp inoremap :tabn + noremap :ShowSyntax + " noremap Oa | noremap! Oa noremap Ob | noremap! Ob -- cgit v1.2.3