linux - Shell scripts for Meld Nautilus context menu -


beyond compare provides "select compare" , "compare selected" using 2 nautilus scripts (stored in /home/user/.gnome2/nautilus-scripts).

script 1: select compare

#!/bin/sh quoted=$(echo "$nautilus_script_selected_file_paths" | awk 'begin { fs = "\n" } { printf "\"%s\" ", $1 }' | sed -e s#\"\"##) echo "$quoted" > $home/.beyondcompare/nautilus 

script 2: compare selected

#!/bin/sh arg2=$(cat $home/.beyondcompare/nautilus) arg1=$(echo "$nautilus_script_selected_file_paths" | awk 'begin { fs = "\n" } { printf "\"%s\" ", $1 }' | sed -e s#\"\"##) bcompare $arg1 $arg2 

i trying similar scripts meld, not working.

i not familiar shell scripts. can me understand this:

quoted=$(echo "$nautilus_script_selected_file_paths" | awk 'begin { fs = "\n" } { printf "\"%s\" ", $1 }' | sed -e s#\"\"##) 

so can adapt meld.

the quoted=$( ...) assigns whatever output there variable named quoted, , can used later in script $quoted or ${quoted} or "${quoted}" or "$quoted"

the '|' char called 'pipe' in unix/linux , connects output of preceding command feed following command.

so take script apart 1 piece @ time , see does,

quoted=$( # execute below first echo "$nautilus_script_selected_file_paths" # add on piped program see how data gets transformed | awk 'begin { fs = "\n" } { printf "\"%s\" ", $1 }'  # add | sed -e s#\"\"## # capturing of output var 'quoted' final step of code )  # **cannot** copy paste whole block of code , expect work ;-) 

i don't know supposed in $nautilus_script_selected_file_paths, hard show here. and, variable not defined in of code specify here, may blank line when echo value. prepared research on how value set , correct values.

also notice code 'prefixed' #!/bin/sh. if /bin/sh command substitution quoted=$(....) not work , should generate error message. persumably system using bash /bin/sh. can eliminate possible confusion in future (when changing system /bin/sh = bourne shell), changing 'shebang' #! /bin/bash.

i hope helps.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -