feat(wpcarro/emacs): Support calling sudo on a remote buffer
While pattern-matching in Elisp is a bit unsightly, it works :) Change-Id: I6766147095823f1a4e233832b0ef21f4c486e023 Reviewed-on: https://cl.tvl.fyi/c/depot/+/5452 Tested-by: BuildkiteCI Reviewed-by: wpcarro <wpcarro@gmail.com> Autosubmit: wpcarro <wpcarro@gmail.com>
This commit is contained in:
		
							parent
							
								
									d843f0bf4c
								
							
						
					
					
						commit
						e48b0cc84f
					
				
					 2 changed files with 14 additions and 6 deletions
				
			
		|  | @ -41,7 +41,9 @@ | ||||||
| ;; enables ControlMaster. | ;; enables ControlMaster. | ||||||
| (setq tramp-use-ssh-controlmaster-options nil) | (setq tramp-use-ssh-controlmaster-options nil) | ||||||
| 
 | 
 | ||||||
| (defcustom ssh-hosts '("wpcarro@wpcarro.dev") | (defcustom ssh-hosts '("wpcarro@wpcarro.dev" | ||||||
|  |                        "foundation" | ||||||
|  |                        "edge") | ||||||
|   "List of hosts to which I commonly connect.") |   "List of hosts to which I commonly connect.") | ||||||
| 
 | 
 | ||||||
| (defun ssh-sudo-buffer () | (defun ssh-sudo-buffer () | ||||||
|  | @ -49,7 +51,10 @@ | ||||||
|   (interactive) |   (interactive) | ||||||
|   (with-current-buffer (current-buffer) |   (with-current-buffer (current-buffer) | ||||||
|     (if (s-starts-with? "/ssh:" buffer-file-name) |     (if (s-starts-with? "/ssh:" buffer-file-name) | ||||||
|         (message "[ssh.el] calling ssh-sudo-buffer for remote files isn't currently supported") |         (pcase (s-split ":" buffer-file-name) | ||||||
|  |           (`(,one ,two ,three) (find-file (format "/ssh:%s|sudo:%s:%s" two two three)))) | ||||||
|  |         (find-file | ||||||
|  |          (s-join ":" (-insert-at 2 "|sudo" (s-split ":" buffer-file-name)))) | ||||||
|       (find-file (format "/sudo::%s" buffer-file-name))))) |       (find-file (format "/sudo::%s" buffer-file-name))))) | ||||||
| 
 | 
 | ||||||
| (defun ssh-cd-home () | (defun ssh-cd-home () | ||||||
|  |  | ||||||
|  | @ -2,7 +2,8 @@ | ||||||
| 
 | 
 | ||||||
| { | { | ||||||
|   imports = |   imports = | ||||||
|     [ (modulesPath + "/installer/scan/not-detected.nix") |     [ | ||||||
|  |       (modulesPath + "/installer/scan/not-detected.nix") | ||||||
|     ]; |     ]; | ||||||
| 
 | 
 | ||||||
|   boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ]; |   boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ]; | ||||||
|  | @ -11,16 +12,18 @@ | ||||||
|   boot.extraModulePackages = [ ]; |   boot.extraModulePackages = [ ]; | ||||||
| 
 | 
 | ||||||
|   fileSystems."/" = |   fileSystems."/" = | ||||||
|     { device = "/dev/disk/by-uuid/60d92789-c44e-4620-885d-1d81d0759f1d"; |     { | ||||||
|  |       device = "/dev/disk/by-uuid/60d92789-c44e-4620-885d-1d81d0759f1d"; | ||||||
|       fsType = "ext4"; |       fsType = "ext4"; | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|   fileSystems."/boot" = |   fileSystems."/boot" = | ||||||
|     { device = "/dev/disk/by-uuid/C62C-9B32"; |     { | ||||||
|  |       device = "/dev/disk/by-uuid/C62C-9B32"; | ||||||
|       fsType = "vfat"; |       fsType = "vfat"; | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|   swapDevices = []; |   swapDevices = [ ]; | ||||||
| 
 | 
 | ||||||
|   hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; |   hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; | ||||||
|   # high-resolution display |   # high-resolution display | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue