~kaction/config

ref: 627f3b188e76d83ce38f35fa91556bb0a366d500 config/universe/selectors/default.nix -rw-r--r-- 1.1 KiB
627f3b18 — Dmitry Bogatov universe/selectors: add selector for git branch 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{ fzy, git, git-bug, substituteAll, execline, busybox, runCommandLocal
, writeScript }:
let
  bug = writeScript "bug-selector" ''
    #!${execline}/bin/execlineb -WS0
    pipeline { ${git-bug}/bin/git-bug ls $@ }
    pipeline { ${fzy}/bin/fzy }
    ${busybox}/bin/cut -d " " -f1
  '';
  commit = writeScript "commit-selector" ''
    #!${execline}/bin/execlineb -WS0
    pipeline {
      ${git}/bin/git
        log --date=short
            --format="%h %cd %s"
            --since="last month" $@
    } pipeline { ${fzy}/bin/fzy }
    ${busybox}/bin/cut -d " " -f1
  '';
  file = writeScript "file-selector" ''
    #!${execline}/bin/execlineb -WS0
    pipeline { ${git}/bin/git ls-files $@ }
    ${fzy}/bin/fzy
  '';
  branch = writeScript "branch-selector" ''
    #!${execline}/bin/execlineb -WS0
    pipeline { git for-each-ref refs/heads/ --format=%(refname:short) }
    ${fzy}/bin/fzy
  '';
in runCommandLocal "selectors" { } ''
  mkdir -p $out/bin
  ln -sf ${bug} $out/bin/fzy-bug
  ln -sf ${commit} $out/bin/fzy-commit
  ln -sf ${file} $out/bin/fzy-file
  ln -sf ${branch} $out/bin/fzy-branch
''