1
0

default.nix 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. { pkgs, ... }:
  2. {
  3. programs.fish = {
  4. enable = true;
  5. interactiveShellInit = ''
  6. set -g fish_greeting ""
  7. source ${./project_cd.fish}
  8. direnv hook fish | source
  9. '';
  10. functions = {
  11. fme = builtins.readFile ./fileme/function.fish;
  12. current_git_branch = ''
  13. git symbolic-ref --quiet --short HEAD 2>/dev/null | read -l branch
  14. and printf '(%s)' $branch
  15. '';
  16. shlvl_prompt = ''
  17. if test "$SHLVL" -gt 1
  18. printf '(%d)' "$SHLVL"
  19. end
  20. '';
  21. jclone = ''
  22. git clone git@github.com:johron/$argv[1]
  23. '';
  24. nix-update = ''
  25. set -l orig_cwd (pwd)
  26. cd ~/nix-dots || return
  27. nix flake update
  28. or begin
  29. cd $orig_cwd
  30. return 1
  31. end
  32. nh os switch
  33. or begin
  34. cd $orig_cwd
  35. return 1
  36. end
  37. flatpak update -y
  38. cd $orig_cwd
  39. '';
  40. fish_prompt = ''
  41. set -g fish_prompt_pwd_dir_length 0
  42. set -l primary_color "brblue"
  43. set -l pwd_color "blue"
  44. switch (prompt_hostname)
  45. case 'straume'
  46. set primary_color "brblue"
  47. set pwd_color "blue"
  48. case 'ono'
  49. set primary_color "cyan"
  50. set pwd_color "brcyan"
  51. case 'moholt'
  52. set primary_color "yellow"
  53. set pwd_color "bryellow"
  54. case '*'
  55. set primary_color "red"
  56. set pwd_color "brred"
  57. end
  58. set_color normal
  59. shlvl_prompt
  60. set_color normal
  61. printf "("
  62. set_color --bold $primary_color
  63. printf "%s" $USER
  64. set_color normal
  65. printf "@"
  66. set_color --bold $primary_color
  67. printf "%s" (prompt_hostname)
  68. set_color normal
  69. printf ":"
  70. set_color --bold $pwd_color
  71. printf "%s" (prompt_pwd)
  72. set_color normal
  73. printf ")"
  74. set_color --bold brgreen
  75. current_git_branch
  76. set_color normal
  77. printf '$ '
  78. '';
  79. };
  80. completions = {
  81. fme = builtins.readFile ./fileme/completions.fish;
  82. };
  83. };
  84. }