Change to dir only if not already in the dir
This commit is contained in:
		
							parent
							
								
									e18e6efdbc
								
							
						
					
					
						commit
						c39e41bc7f
					
				
							
								
								
									
										20
									
								
								zshrc
								
								
								
								
							
							
						
						
									
										20
									
								
								zshrc
								
								
								
								
							|  | @ -2194,7 +2194,7 @@ cf() { | ||||||
| # Display the 50 first lines of the selected file with bat (batcat) | # Display the 50 first lines of the selected file with bat (batcat) | ||||||
| # Move to the directory of the selected file | # Move to the directory of the selected file | ||||||
| # Open the selected file with vi | # Open the selected file with vi | ||||||
| v() { | function v() { | ||||||
| 	local files | 	local files | ||||||
| 	local dir | 	local dir | ||||||
| 	local file | 	local file | ||||||
|  | @ -2213,7 +2213,8 @@ v() { | ||||||
| 	if [[ -n "${files}" ]] | 	if [[ -n "${files}" ]] | ||||||
| 	then | 	then | ||||||
| 		dir=$(dirname "${files}") | 		dir=$(dirname "${files}") | ||||||
| 		cd -- "${dir}" | 		### Change directory only if not already in the expected dir | ||||||
|  | 		test $(realpath "${dir}") != $(realpath .) && cd -- "${dir}" | ||||||
| 		file=$(basename "${files}") | 		file=$(basename "${files}") | ||||||
| 		vi -- "${file}" | 		vi -- "${file}" | ||||||
| 	fi | 	fi | ||||||
|  | @ -2246,7 +2247,8 @@ pdf() { | ||||||
| 	if [[ -n $files ]] | 	if [[ -n $files ]] | ||||||
| 	then | 	then | ||||||
| 		dir=$(dirname "${files}") | 		dir=$(dirname "${files}") | ||||||
| 		cd -- "${dir}" | 		### Change directory only if not already in the expected dir | ||||||
|  | 		test $(realpath "${dir}") != $(realpath .) && cd -- "${dir}" | ||||||
| 		file=$(basename "${files}") | 		file=$(basename "${files}") | ||||||
| 		"${PDF_VIEWER}" -- "${file}" | 		"${PDF_VIEWER}" -- "${file}" | ||||||
| 	fi | 	fi | ||||||
|  | @ -2357,7 +2359,8 @@ odt() { | ||||||
| 	if [[ -n $files ]] | 	if [[ -n $files ]] | ||||||
| 	then | 	then | ||||||
| 		dir=$(dirname "${files}") | 		dir=$(dirname "${files}") | ||||||
| 		cd -- "${dir}" | 		### Change directory only if not already in the expected dir | ||||||
|  | 		test $(realpath "${dir}") != $(realpath .) && cd -- "${dir}" | ||||||
| 		file=$(basename "${files}") | 		file=$(basename "${files}") | ||||||
| 		command libreoffice --writer "${file}" & | 		command libreoffice --writer "${file}" & | ||||||
| 	fi | 	fi | ||||||
|  | @ -2387,7 +2390,8 @@ ods() { | ||||||
| 	if [[ -n $files ]] | 	if [[ -n $files ]] | ||||||
| 	then | 	then | ||||||
| 		dir=$(dirname "${files}") | 		dir=$(dirname "${files}") | ||||||
| 		cd -- "${dir}" | 		### Change directory only if not already in the expected dir | ||||||
|  | 		test $(realpath "${dir}") != $(realpath .) && cd -- "${dir}" | ||||||
| 		file=$(basename "${files}") | 		file=$(basename "${files}") | ||||||
| 		command libreoffice --calc "${file}" & | 		command libreoffice --calc "${file}" & | ||||||
| 	fi | 	fi | ||||||
|  | @ -2417,7 +2421,8 @@ odp() { | ||||||
| 	if [[ -n $files ]] | 	if [[ -n $files ]] | ||||||
| 	then | 	then | ||||||
| 		dir=$(dirname "${files}") | 		dir=$(dirname "${files}") | ||||||
| 		cd -- "${dir}" | 		### Change directory only if not already in the expected dir | ||||||
|  | 		test $(realpath "${dir}") != $(realpath .) && cd -- "${dir}" | ||||||
| 		file=$(basename "${files}") | 		file=$(basename "${files}") | ||||||
| 		command libreoffice --impress "${file}" & | 		command libreoffice --impress "${file}" & | ||||||
| 	fi | 	fi | ||||||
|  | @ -2448,7 +2453,8 @@ fopen() { | ||||||
| 	if [[ -n $files ]] | 	if [[ -n $files ]] | ||||||
| 	then | 	then | ||||||
| 		dir=$(dirname "${files}") | 		dir=$(dirname "${files}") | ||||||
| 		cd -- "${dir}" | 		### Change directory only if not already in the expected dir | ||||||
|  | 		test $(realpath "${dir}") != $(realpath .) && cd -- "${dir}" | ||||||
| 		file=$(basename "${files}") | 		file=$(basename "${files}") | ||||||
| 		command xdg-open "${file}" & | 		command xdg-open "${file}" & | ||||||
| 	fi | 	fi | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue