1
0

config.elv 1.2 KB

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