fish-functions.nix 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. { pkgs, lib, ... }:
  2. let
  3. _ = lib.getExe;
  4. in
  5. with pkgs;
  6. {
  7. gitignore = "curl -sL https://www.gitignore.io/api/$argv";
  8. fish_greeting = ""; # disable welcome text
  9. bs = ''
  10. pushd ~/Media/nixos
  11. nh os switch .
  12. if test $status -eq 0
  13. notify-send "Rebuild Switch" "Build successful!"
  14. else
  15. notify-send "Rebuild Switch" "Build failed!"
  16. end
  17. popd
  18. '';
  19. bb = ''
  20. pushd ~/Media/nixos
  21. nh os boot .
  22. if test $status -eq 0
  23. notify-send "Rebuild Boot" "Build successful!"
  24. else
  25. notify-send "Rebuild Boot" "Build failed!"
  26. end
  27. popd
  28. '';
  29. hs = ''
  30. pushd ~/Media/nixos
  31. nh home switch .
  32. if test $status -eq 0
  33. notify-send "Home-Manager Switch" "Build successful!"
  34. else
  35. notify-send "Home-Manager Switch" "Build failed!"
  36. end
  37. popd
  38. '';
  39. fe = ''
  40. set selected_file (${lib.getExe' ripgrep "rg"} --files $argv[1] | fzf --preview "${_ bat} -f {}")
  41. if [ -n "$selected_file" ]
  42. echo "$selected_file" | xargs $EDITOR
  43. end
  44. '';
  45. paste = ''
  46. # https://github.com/ptr1337/dotfiles/blob/master/scripts/misc/paste-cachyos
  47. set URL "https://paste.cachyos.org"
  48. set FILEPATH $argv[1]
  49. set FILENAME (basename -- $FILEPATH)
  50. set EXTENSION (string match -r '\.(.*)$' $FILENAME; and echo $argv[1] ; or echo "")
  51. set RESPONSE (curl --data-binary @$FILEPATH --url $URL)
  52. set PASTELINK "$URL$RESPONSE"
  53. if test -z "$EXTENSION"
  54. echo "$PASTELINK"
  55. else
  56. echo "$PASTELINK$EXTENSION"
  57. end
  58. '';
  59. run = "nix run nixpkgs#$argv[1] -- $argv[2..-1]";
  60. "watchLive" =
  61. let
  62. args = "--hwdec=dxva2 --gpu-context=d3d11 --no-keepaspect-window --keep-open=no --force-window=yes --force-seekable=yes --hr-seek=yes --hr-seek-framedrop=yes";
  63. in
  64. ''${_ streamlink} --player ${_ mpv} --twitch-disable-hosting --twitch-low-latency --player-args "${args}" --player-continuous-http --player-no-close --hls-live-edge 2 --stream-segment-threads 2 --retry-open 15 --retry-streams 15 $argv'';
  65. }