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) | ||||
| # Move to the directory of the selected file | ||||
| # Open the selected file with vi | ||||
| v() { | ||||
| function v() { | ||||
| 	local files | ||||
| 	local dir | ||||
| 	local file | ||||
|  | @ -2213,7 +2213,8 @@ v() { | |||
| 	if [[ -n "${files}" ]] | ||||
| 	then | ||||
| 		dir=$(dirname "${files}") | ||||
| 		cd -- "${dir}" | ||||
| 		### Change directory only if not already in the expected dir | ||||
| 		test $(realpath "${dir}") != $(realpath .) && cd -- "${dir}" | ||||
| 		file=$(basename "${files}") | ||||
| 		vi -- "${file}" | ||||
| 	fi | ||||
|  | @ -2246,7 +2247,8 @@ pdf() { | |||
| 	if [[ -n $files ]] | ||||
| 	then | ||||
| 		dir=$(dirname "${files}") | ||||
| 		cd -- "${dir}" | ||||
| 		### Change directory only if not already in the expected dir | ||||
| 		test $(realpath "${dir}") != $(realpath .) && cd -- "${dir}" | ||||
| 		file=$(basename "${files}") | ||||
| 		"${PDF_VIEWER}" -- "${file}" | ||||
| 	fi | ||||
|  | @ -2357,7 +2359,8 @@ odt() { | |||
| 	if [[ -n $files ]] | ||||
| 	then | ||||
| 		dir=$(dirname "${files}") | ||||
| 		cd -- "${dir}" | ||||
| 		### Change directory only if not already in the expected dir | ||||
| 		test $(realpath "${dir}") != $(realpath .) && cd -- "${dir}" | ||||
| 		file=$(basename "${files}") | ||||
| 		command libreoffice --writer "${file}" & | ||||
| 	fi | ||||
|  | @ -2387,7 +2390,8 @@ ods() { | |||
| 	if [[ -n $files ]] | ||||
| 	then | ||||
| 		dir=$(dirname "${files}") | ||||
| 		cd -- "${dir}" | ||||
| 		### Change directory only if not already in the expected dir | ||||
| 		test $(realpath "${dir}") != $(realpath .) && cd -- "${dir}" | ||||
| 		file=$(basename "${files}") | ||||
| 		command libreoffice --calc "${file}" & | ||||
| 	fi | ||||
|  | @ -2417,7 +2421,8 @@ odp() { | |||
| 	if [[ -n $files ]] | ||||
| 	then | ||||
| 		dir=$(dirname "${files}") | ||||
| 		cd -- "${dir}" | ||||
| 		### Change directory only if not already in the expected dir | ||||
| 		test $(realpath "${dir}") != $(realpath .) && cd -- "${dir}" | ||||
| 		file=$(basename "${files}") | ||||
| 		command libreoffice --impress "${file}" & | ||||
| 	fi | ||||
|  | @ -2448,7 +2453,8 @@ fopen() { | |||
| 	if [[ -n $files ]] | ||||
| 	then | ||||
| 		dir=$(dirname "${files}") | ||||
| 		cd -- "${dir}" | ||||
| 		### Change directory only if not already in the expected dir | ||||
| 		test $(realpath "${dir}") != $(realpath .) && cd -- "${dir}" | ||||
| 		file=$(basename "${files}") | ||||
| 		command xdg-open "${file}" & | ||||
| 	fi | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue