config.elv 1.2 KB

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