duplikat dari
				https://github.com/quitesimpleorg/hs9001.git
				synced 2025-10-31 22:09:30 +01:00 
			
		
		
		
	Replace previous PROMPT_COMMAND in bashrc with more convenient option
This commit is contained in:
		| @@ -34,9 +34,7 @@ apk add hs9001 | |||||||
| Add this to .bashrc | Add this to .bashrc | ||||||
|  |  | ||||||
| ``` | ``` | ||||||
| if [ -n "$PS1" ] ; then | eval "$(hs9001 bash-enable)" | ||||||
|     PROMPT_COMMAND='hs9001 add -ret $? "$(history 1)"' |  | ||||||
| fi |  | ||||||
| ``` | ``` | ||||||
| By default, every system user gets his own database. You can override this by setting the environment variable | By default, every system user gets his own database. You can override this by setting the environment variable | ||||||
| for all users that should write to your unified database. | for all users that should write to your unified database. | ||||||
|   | |||||||
							
								
								
									
										12
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								main.go
									
									
									
									
									
								
							| @@ -234,7 +234,7 @@ func exists(path string) (bool, error) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func printUsage() { | func printUsage() { | ||||||
| 	fmt.Fprintf(os.Stderr, "Usage:   ./hs9001 <add/search/import/nolog>\n") | 	fmt.Fprintf(os.Stderr, "Usage:   ./hs9001 <add/search/import/nolog/bash-enable>\n") | ||||||
| } | } | ||||||
|  |  | ||||||
| func main() { | func main() { | ||||||
| @@ -266,8 +266,14 @@ func main() { | |||||||
| 	migrateDatabase(conn, fetchDBVersion(conn)) | 	migrateDatabase(conn, fetchDBVersion(conn)) | ||||||
|  |  | ||||||
| 	switch cmd { | 	switch cmd { | ||||||
| 	case "nolog": | 	case "bash-enable": | ||||||
| 		fmt.Printf("Run this command to disable logging for the current shell:\n\tunset PROMPT_COMMAND\n") | 		fmt.Printf(` | ||||||
|  | 			if [ -n "$PS1" ] ; then | ||||||
|  | 				PROMPT_COMMAND='hs9001 add -ret $? "$(history 1)"' | ||||||
|  | 			fi | ||||||
|  | 		`) | ||||||
|  | 	case "bash-disable": | ||||||
|  | 		fmt.Printf("unset PROMPT_COMMAND\n") | ||||||
| 	case "add": | 	case "add": | ||||||
| 		var ret int | 		var ret int | ||||||
| 		addCmd.IntVar(&ret, "ret", 0, "Return value of the command to add") | 		addCmd.IntVar(&ret, "ret", 0, "Return value of the command to add") | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 lawl
					lawl