Compare commits
	
		
			1 Commits
		
	
	
		
			50c62a4d3f
			...
			shell-inhi
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 4feb5b89e8 | 
@@ -1,30 +1,29 @@
 | 
				
			|||||||
{pkgs, ...}: {
 | 
					{
 | 
				
			||||||
  programs.fish = {
 | 
					  lib,
 | 
				
			||||||
 | 
					  pkgs,
 | 
				
			||||||
 | 
					  userName,
 | 
				
			||||||
 | 
					  ...
 | 
				
			||||||
 | 
					}: {
 | 
				
			||||||
 | 
					  programs = {
 | 
				
			||||||
 | 
					    fish = {
 | 
				
			||||||
      enable = true;
 | 
					      enable = true;
 | 
				
			||||||
    # initExtra = ''
 | 
					 | 
				
			||||||
    #   export PATH="$PATH:$HOME/bin:$HOME/.local/bin:$HOME/go/bin"
 | 
					 | 
				
			||||||
    # '';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      shellAliases = {
 | 
					      shellAliases = {
 | 
				
			||||||
        # ls aliases
 | 
					        # ls aliases
 | 
				
			||||||
        ls = "eza --color";
 | 
					        ls = "eza --color";
 | 
				
			||||||
        la = "eza -l -all --color";
 | 
					        la = "eza -l -all --color";
 | 
				
			||||||
        ll = "eza -l --color";
 | 
					        ll = "eza -l --color";
 | 
				
			||||||
        lt = "eza -l --color --git";
 | 
					        lt = "eza -l --color --git";
 | 
				
			||||||
 | 
					 | 
				
			||||||
        # lazygit alias
 | 
					        # lazygit alias
 | 
				
			||||||
        lg = "lazygit";
 | 
					        lg = "lazygit";
 | 
				
			||||||
 | 
					 | 
				
			||||||
        # cat, less, more alias
 | 
					        # cat, less, more alias
 | 
				
			||||||
        cat = "bat";
 | 
					        cat = "bat";
 | 
				
			||||||
        less = "bat";
 | 
					        less = "bat";
 | 
				
			||||||
        more = "bat";
 | 
					        more = "bat";
 | 
				
			||||||
 | 
					 | 
				
			||||||
        # top alias
 | 
					        # top alias
 | 
				
			||||||
        top = "btm";
 | 
					        top = "btm";
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
 | 
					      functions =
 | 
				
			||||||
    functions = {
 | 
					        {
 | 
				
			||||||
          fish_greeting = {
 | 
					          fish_greeting = {
 | 
				
			||||||
            body = ''
 | 
					            body = ''
 | 
				
			||||||
              set memes \
 | 
					              set memes \
 | 
				
			||||||
@@ -43,19 +42,60 @@
 | 
				
			|||||||
                "Can I get a waffle? Can I please get a waffle?" \
 | 
					                "Can I get a waffle? Can I please get a waffle?" \
 | 
				
			||||||
                "I'm lesbian. I thought you were American." \
 | 
					                "I'm lesbian. I thought you were American." \
 | 
				
			||||||
                "You gotta give 'em that 'hawk tuah' and spit on that thang!" \
 | 
					                "You gotta give 'em that 'hawk tuah' and spit on that thang!" \
 | 
				
			||||||
            "We don't do that here..."
 | 
					                "We don't do that here..." \
 | 
				
			||||||
 | 
					                "What are those?! They are my crocs..." \
 | 
				
			||||||
 | 
					                "It's an avocado... Thanks!" \
 | 
				
			||||||
 | 
					                "I am once again asking for your financial support" \
 | 
				
			||||||
 | 
					                "Is that a weed?" \
 | 
				
			||||||
 | 
					                "No, this is Patrick!" \
 | 
				
			||||||
 | 
					                "Come ride, heroes, ride" \
 | 
				
			||||||
 | 
					                "Away with the tide" \
 | 
				
			||||||
 | 
					                "Concede your mind unto the fiend" \
 | 
				
			||||||
 | 
					                "Darkness come, rend the shield of light" \
 | 
				
			||||||
 | 
					                "The sun is setting, darkness taking over - a date with chaos and you're dressed to the nines" \
 | 
				
			||||||
 | 
					                "Now kneel overdweller, your lord commands, there's no salvation for the sons of man" \
 | 
				
			||||||
 | 
					                "Snap click clank whirr whizz wham boom!" \
 | 
				
			||||||
 | 
					                "Rohs an kyn ala na"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
              set choose_meme (random)"%"(count $memes)
 | 
					              set choose_meme (random)"%"(count $memes)
 | 
				
			||||||
              set choose_meme $memes[(math $choose_meme"+1")]
 | 
					              set choose_meme $memes[(math $choose_meme"+1")]
 | 
				
			||||||
 | 
					 | 
				
			||||||
              printf (set_color F90)"%s\n" $choose_meme
 | 
					              printf (set_color F90)"%s\n" $choose_meme
 | 
				
			||||||
            '';
 | 
					            '';
 | 
				
			||||||
        onEvent = "fish_greeting";
 | 
					            # onEvent = "fish_greeting";
 | 
				
			||||||
          };
 | 
					          };
 | 
				
			||||||
 | 
					        } // (lib.mkIf pkgs.stdenv.isLinux {
 | 
				
			||||||
 | 
					          block = {
 | 
				
			||||||
 | 
					            body = ''
 | 
				
			||||||
 | 
					              echo "Starting systemd-inhibit..."
 | 
				
			||||||
 | 
					              set inhibit_pid_file /tmp/fish_inhibit_pid_(whoami)
 | 
				
			||||||
 | 
					              bash -c 'systemd-inhibit --no-ask-password --what=idle --who="'${userName}'" --why="manual invocation" sh & echo $! > '"$inhibit_pid_file"' && disown'
 | 
				
			||||||
 | 
					              if test -f $inhibit_pid_file
 | 
				
			||||||
 | 
					                set -g INHIBIT_PID (cat $inhibit_pid_file)
 | 
				
			||||||
 | 
					                echo "Inhibit process started with PID: $INHIBIT_PID"
 | 
				
			||||||
 | 
					              else
 | 
				
			||||||
 | 
					                echo "Failed to start inhibit process"
 | 
				
			||||||
 | 
					                return 1
 | 
				
			||||||
 | 
					              end
 | 
				
			||||||
 | 
					            '';
 | 
				
			||||||
          };
 | 
					          };
 | 
				
			||||||
 | 
					          unblock = {
 | 
				
			||||||
 | 
					            body = ''
 | 
				
			||||||
 | 
					              set inhibit_pid_file /tmp/fish_inhibit_pid_(whoami)
 | 
				
			||||||
 | 
					              if test -f $inhibit_pid_file
 | 
				
			||||||
 | 
					                set INHIBIT_PID (cat $inhibit_pid_file)
 | 
				
			||||||
 | 
					                echo "Killing inhibit process: $INHIBIT_PID"
 | 
				
			||||||
 | 
					                kill -SIGTERM $INHIBIT_PID 2>/dev/null; or kill -SIGKILL $INHIBIT_PID 2>/dev/null
 | 
				
			||||||
 | 
					                rm -f $inhibit_pid_file
 | 
				
			||||||
 | 
					                set -e INHIBIT_PID
 | 
				
			||||||
 | 
					                echo "Inhibit process terminated"
 | 
				
			||||||
 | 
					              else
 | 
				
			||||||
 | 
					                echo "No inhibit process file found"
 | 
				
			||||||
 | 
					              end
 | 
				
			||||||
 | 
					            '';
 | 
				
			||||||
          };
 | 
					          };
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
  programs.zsh = {
 | 
					    };
 | 
				
			||||||
 | 
					    zsh = {
 | 
				
			||||||
      enable = true;
 | 
					      enable = true;
 | 
				
			||||||
      initContent = ''
 | 
					      initContent = ''
 | 
				
			||||||
        if [[ -z "$BASH_EXECUTION_STRING" ]]; then
 | 
					        if [[ -z "$BASH_EXECUTION_STRING" ]]; then
 | 
				
			||||||
@@ -68,8 +108,7 @@
 | 
				
			|||||||
        fi
 | 
					        fi
 | 
				
			||||||
      '';
 | 
					      '';
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					    bash = {
 | 
				
			||||||
  programs.bash = {
 | 
					 | 
				
			||||||
      enable = true;
 | 
					      enable = true;
 | 
				
			||||||
      initExtra = ''
 | 
					      initExtra = ''
 | 
				
			||||||
        if [[ -z "$BASH_EXECUTION_STRING" ]]; then
 | 
					        if [[ -z "$BASH_EXECUTION_STRING" ]]; then
 | 
				
			||||||
@@ -82,4 +121,5 @@
 | 
				
			|||||||
        fi
 | 
					        fi
 | 
				
			||||||
      '';
 | 
					      '';
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user