config.elv 1.0 KB

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