config.elv 1.1 KB

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