default.nix 2.1 KB

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