mirror of
				https://github.com/sammy-ette/Hilbish
				synced 2025-08-10 02:52:03 +00:00 
			
		
		
		
	Compare commits
	
		
			No commits in common. "4fcd310048d49ec1532325cc349650d165317f41" and "caff604d953064c4678b0fbcdc18b808ff52cd43" have entirely different histories.
		
	
	
		
			4fcd310048
			...
			caff604d95
		
	
		
| @ -12,9 +12,6 @@ | |||||||
| - `hilbish.notification` signal when a message/notification is sent | - `hilbish.notification` signal when a message/notification is sent | ||||||
| - `notifyJobFinish` opt to send a notification when background jobs are | - `notifyJobFinish` opt to send a notification when background jobs are | ||||||
| completed. | completed. | ||||||
| - Allow numbered arg substitutions in aliases. |  | ||||||
|   - Example: `hilbish.alias('hello', 'echo %1 says hello')` allows the user to run `hello hilbish` |  | ||||||
|   which will output `hilbish says hello`. |  | ||||||
| 
 | 
 | ||||||
| [#219]: https://github.com/Rosettea/Hilbish/issues/219 | [#219]: https://github.com/Rosettea/Hilbish/issues/219 | ||||||
| ### Fixed | ### Fixed | ||||||
|  | |||||||
							
								
								
									
										22
									
								
								aliases.go
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								aliases.go
									
									
									
									
									
								
							| @ -1,8 +1,6 @@ | |||||||
| package main | package main | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"regexp" |  | ||||||
| 	"strconv" |  | ||||||
| 	"strings" | 	"strings" | ||||||
| 	"sync" | 	"sync" | ||||||
| 
 | 
 | ||||||
| @ -48,27 +46,9 @@ func (a *aliasModule) Resolve(cmdstr string) string { | |||||||
| 	a.mu.RLock() | 	a.mu.RLock() | ||||||
| 	defer a.mu.RUnlock() | 	defer a.mu.RUnlock() | ||||||
| 
 | 
 | ||||||
| 	arg, _ := regexp.Compile(`[\\]?%\d+`) | 	args := strings.Split(cmdstr, " ") | ||||||
| 
 |  | ||||||
| 	args, _ := splitInput(cmdstr) |  | ||||||
| 	for a.aliases[args[0]] != "" { | 	for a.aliases[args[0]] != "" { | ||||||
| 		alias := a.aliases[args[0]] | 		alias := a.aliases[args[0]] | ||||||
| 		alias = arg.ReplaceAllStringFunc(alias, func(a string) string { |  | ||||||
| 			idx, _ := strconv.Atoi(a[1:]) |  | ||||||
| 			if strings.HasPrefix(a, "\\") || idx == 0 { |  | ||||||
| 				return strings.TrimPrefix(a, "\\") |  | ||||||
| 			} |  | ||||||
| 
 |  | ||||||
| 			if idx + 1 > len(args) { |  | ||||||
| 				return a |  | ||||||
| 			} |  | ||||||
| 			val := args[idx] |  | ||||||
| 			args = cut(args, idx) |  | ||||||
| 			cmdstr = strings.Join(args, " ") |  | ||||||
| 
 |  | ||||||
| 			return val |  | ||||||
| 		}) |  | ||||||
| 		 |  | ||||||
| 		cmdstr = alias + strings.TrimPrefix(cmdstr, args[0]) | 		cmdstr = alias + strings.TrimPrefix(cmdstr, args[0]) | ||||||
| 		cmdArgs, _ := splitInput(cmdstr) | 		cmdArgs, _ := splitInput(cmdstr) | ||||||
| 		args = cmdArgs | 		args = cmdArgs | ||||||
|  | |||||||
							
								
								
									
										6
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								main.go
									
									
									
									
									
								
							| @ -289,7 +289,7 @@ func removeDupes(slice []string) []string { | |||||||
| 
 | 
 | ||||||
| func contains(s []string, e string) bool { | func contains(s []string, e string) bool { | ||||||
| 	for _, a := range s { | 	for _, a := range s { | ||||||
| 		if strings.ToLower(a) == strings.ToLower(e) { | 		if a == e { | ||||||
| 			return true | 			return true | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @ -324,7 +324,3 @@ func getVersion() string { | |||||||
| 
 | 
 | ||||||
| 	return v.String() | 	return v.String() | ||||||
| } | } | ||||||
| 
 |  | ||||||
| func cut(slice []string, idx int) []string { |  | ||||||
| 	return append(slice[:idx], slice[idx + 1:]...) |  | ||||||
| } |  | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user