config.elv 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. use str
  2. use prompt
  3. use nix-shell
  4. use direlv
  5. edit:add-var ls~ { |@a|
  6. e:ls --color=auto --group-directories-first -F --quoting-style literal $@a
  7. }
  8. if (has-external yadm) {
  9. set-env YADM_OVERRIDE_REPO ~/.dotfiles
  10. } else {
  11. edit:add-var yadm~ { |@a| git --git-dir=~/.dotfiles/ --work-tree=~ $@a }
  12. }
  13. if (has-external delta) {
  14. set-env GIT_PAGER delta
  15. }
  16. # some additional bindings
  17. use readline-binding
  18. set edit:completion:binding[Ctrl-W] = $edit:close-mode~
  19. set edit:completion:binding[Tab] = $edit:completion:accept~
  20. var max-len = 30
  21. # print time if command takes longer than 5 seconds
  22. set edit:after-command = [{|m|
  23. if (> $m[duration] 5) {
  24. var cmd = $m[src][code]
  25. var len = (count $cmd)
  26. if (> $len $max-len) {
  27. set cmd = $cmd[..$max-len]…
  28. }
  29. printf "%s took %.3fs\n" $cmd $m[duration]
  30. }
  31. }]
  32. eval (carapace _carapace|slurp)
  33. # import local.elv if present, for example, from ~/.config/elvish/lib/local.elv
  34. try {
  35. use local
  36. } catch e {
  37. if (not (str:contains (to-string $e[reason]) "no such module")) {
  38. fail $e
  39. }
  40. }