Preliminary rewrite of OS detection
This commit is contained in:
		
							parent
							
								
									e78aaa41f9
								
							
						
					
					
						commit
						f5b5ebccc7
					
				@ -515,19 +515,38 @@ If RELEASE-FILE is nil, use '/etc/os-release'."
 | 
				
			|||||||
(defun eshell-info-banner--get-os-information ()
 | 
					(defun eshell-info-banner--get-os-information ()
 | 
				
			||||||
  "Get operating system identifying information."
 | 
					  "Get operating system identifying information."
 | 
				
			||||||
  (let ((prefix (if eshell-info-banner-tramp-aware (file-remote-p default-directory) "")))
 | 
					  (let ((prefix (if eshell-info-banner-tramp-aware (file-remote-p default-directory) "")))
 | 
				
			||||||
    (cond
 | 
					 | 
				
			||||||
     ;; Linux
 | 
					 | 
				
			||||||
     ((executable-find "hostnamectl" eshell-info-banner-tramp-aware)
 | 
					 | 
				
			||||||
      (eshell-info-banner--get-os-information-from-hostnamectl))
 | 
					 | 
				
			||||||
     ((executable-find "lsb_release" eshell-info-banner-tramp-aware)
 | 
					 | 
				
			||||||
      (eshell-info-banner--get-os-information-from-lsb-release))
 | 
					 | 
				
			||||||
     ((file-exists-p (concat prefix "/etc/os-release"))
 | 
					 | 
				
			||||||
      (eshell-info-banner--get-os-information-from-release-file))
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
     ;; Windows
 | 
					    (pcase system-type
 | 
				
			||||||
     ((executable-find "reg")
 | 
					      ((or 'ms-dos 'windows-nt 'cygwin)
 | 
				
			||||||
      (eshell-info-banner--get-os-information-from-registry))
 | 
					       (let ((os (eshell-info-banner--get-os-information-from-registry)))
 | 
				
			||||||
     (t "Unknown"))))
 | 
					         (save-match-data
 | 
				
			||||||
 | 
					           (string-match "\\([^()]+\\) *(\\([^()]+\\))" os)
 | 
				
			||||||
 | 
					           `(,(s-trim (substring-no-properties os
 | 
				
			||||||
 | 
					                                               (match-beginning 1)
 | 
				
			||||||
 | 
					                                               (match-end 1)))
 | 
				
			||||||
 | 
					             .
 | 
				
			||||||
 | 
					             ,(substring-no-properties os
 | 
				
			||||||
 | 
					                                       (match-beginning 2)
 | 
				
			||||||
 | 
					                                       (match-end 2))))))
 | 
				
			||||||
 | 
					      ((or 'gnu 'gnu/linux 'gnu/kfreebsd 'darwin)
 | 
				
			||||||
 | 
					       `(,(cond
 | 
				
			||||||
 | 
					           ((executable-find "hostnamectl" eshell-info-banner-tramp-aware)
 | 
				
			||||||
 | 
					            (eshell-info-banner--get-os-information-from-hostnamectl))
 | 
				
			||||||
 | 
					           ((executable-find "lsb_release" eshell-info-banner-tramp-aware)
 | 
				
			||||||
 | 
					            (eshell-info-banner--get-os-information-from-lsb-release))
 | 
				
			||||||
 | 
					           ((file-exists-p (concat prefix "/etc/os-release"))
 | 
				
			||||||
 | 
					            (eshell-info-banner--get-os-information-from-release-file))
 | 
				
			||||||
 | 
					           ((executable-find "shepherd")
 | 
				
			||||||
 | 
					            (let ((distro (car (s-lines (shell-command-to-string "guix -V")))))
 | 
				
			||||||
 | 
					              (save-match-data
 | 
				
			||||||
 | 
					                (string-match "\\([0-9\\.]+\\)" distro)
 | 
				
			||||||
 | 
					                (concat "Guix System "
 | 
				
			||||||
 | 
					                        (substring-no-properties distro
 | 
				
			||||||
 | 
					                                                 (match-beginning 1)
 | 
				
			||||||
 | 
					                                                 (match-end 1))))))
 | 
				
			||||||
 | 
					           (t "Unknown"))
 | 
				
			||||||
 | 
					         .
 | 
				
			||||||
 | 
					         ,(s-trim (shell-command-to-string "uname -rs")))))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 | 
					;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 | 
				
			||||||
@ -538,12 +557,13 @@ If RELEASE-FILE is nil, use '/etc/os-release'."
 | 
				
			|||||||
(defun eshell-info-banner ()
 | 
					(defun eshell-info-banner ()
 | 
				
			||||||
  "Banner for Eshell displaying system information."
 | 
					  "Banner for Eshell displaying system information."
 | 
				
			||||||
  (let* ((default-directory (if eshell-info-banner-tramp-aware default-directory "~"))
 | 
					  (let* ((default-directory (if eshell-info-banner-tramp-aware default-directory "~"))
 | 
				
			||||||
         (os            (eshell-info-banner--get-os-information))
 | 
					         (system-info   (eshell-info-banner--get-os-information))
 | 
				
			||||||
 | 
					         (os            (car system-info))
 | 
				
			||||||
 | 
					         (kernel        (cdr system-info))
 | 
				
			||||||
         (hostname      (if  eshell-info-banner-tramp-aware
 | 
					         (hostname      (if  eshell-info-banner-tramp-aware
 | 
				
			||||||
                            (or (file-remote-p default-directory 'host) (system-name))
 | 
					                            (or (file-remote-p default-directory 'host) (system-name))
 | 
				
			||||||
                          (system-name)))
 | 
					                          (system-name)))
 | 
				
			||||||
         (uptime        (eshell-info-banner--get-uptime))
 | 
					         (uptime        (eshell-info-banner--get-uptime))
 | 
				
			||||||
         (kernel        (s-trim (shell-command-to-string "uname -sr")))
 | 
					 | 
				
			||||||
         (partitions    (eshell-info-banner--get-mounted-partitions))
 | 
					         (partitions    (eshell-info-banner--get-mounted-partitions))
 | 
				
			||||||
         (left-padding  (eshell-info-banner--get-longest-path partitions))
 | 
					         (left-padding  (eshell-info-banner--get-longest-path partitions))
 | 
				
			||||||
         (left-text     (max (length os)
 | 
					         (left-text     (max (length os)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user