xdg-wrappers: add mbsync, make wrappers use next-in-path
The new next-in-path utility function finds the next entry for the wrapped name in PATH after the called script, instead of hardcoding the usual location for a system install.
This commit is contained in:
		
							parent
							
								
									761b7700ab
								
							
						
					
					
						commit
						e43c38c529
					
				
					 4 changed files with 19 additions and 0 deletions
				
			
		
							
								
								
									
										12
									
								
								lib/next-in-path.zsh
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								lib/next-in-path.zsh
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,12 @@ | ||||||
|  | # find next entry in PATH for wrapper scripts | ||||||
|  | # Usage: next-in-path <program name> <current $0> | ||||||
|  | next-in-path() { | ||||||
|  | 	entries=( $(which -a $1) ) | ||||||
|  | 	index=${entries[(ie)$2]}  | ||||||
|  | 	if [[ $index -le ${#entries} ]]; then | ||||||
|  | 		# found $0, use next entry | ||||||
|  | 		echo $entries[$((index + 1))] | ||||||
|  | 	else | ||||||
|  | 		echo $entries[1] | ||||||
|  | 	fi | ||||||
|  | } | ||||||
							
								
								
									
										0
									
								
								lib/term-wrapper-alacritty
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								lib/term-wrapper-alacritty
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
								
								
									
										3
									
								
								xdg-wrappers/mbsync
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										3
									
								
								xdg-wrappers/mbsync
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,3 @@ | ||||||
|  | #!/bin/zsh | ||||||
|  | source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh | ||||||
|  | $(next-in-path mbsync $0) -c ${XDG_CONFIG_HOME:-$HOME/.config}/mbsyncrc $@ | ||||||
							
								
								
									
										4
									
								
								xdg-wrappers/rg
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										4
									
								
								xdg-wrappers/rg
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,4 @@ | ||||||
|  | #!/bin/zsh | ||||||
|  | source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh | ||||||
|  | export RIPGREP_CONFIG_PATH=${XDG_CONFIG_HOME:-$HOME/.config}/ripgreprc | ||||||
|  | $(next-in-path rg $0) $@ | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alexander Gehrke
						Alexander Gehrke