如何在 Meld 中选择 2 个文件进行比较?

如何在 Meld 中选择 2 个文件进行比较?

我可以将两个文件拖到 Meld GUI 中。我还可以点击文件比较(见截图),然后选择文件,将其与无文件进行比较,然后选择第二个文件。这似乎有点绕圈子。我想比较两个文件,最好是在多选文件选择器 GUI 中。

显示文件选择器的屏幕截图

更好的方法是右键单击 Nautilus 中的一个或两个文件来运行 Meld。

这两种情况都可能吗?

答案1

就我个人而言,我总是meld从终端运行,因此我在那里给出了两个文件名:

meld fileA fileB

使用 GUI,您只需选择两个文件。我不明白为什么您需要“将其与无进行比较”。您只需选择第一个文件,然后选择第二个文件:

在此处输入图片描述

答案2

如果您想使用meldNautilus 比较两个文件,您可以编写一些脚本,这些脚本可以通过文件或文件夹上的右键菜单激活。Nautilus 脚本的脚本语言可能是 bash、python、perl 或 ruby​​,仅列举一些示例。在此答案中,我将展示基于 bash 的解决方案。

首先要用终端命令创建脚本文件夹:

mkdir -p ~/.local/share/nautilus/scripts

所有脚本都将进入此文件夹。脚本进入文件夹后,将不会显示在右键单击上下文菜单中,除非您使用终端命令使其可执行:

chmod +x <script_name>

一旦您至少有一个可执行脚本,它就会出现在上下文菜单中的“脚本”下,如下所示(该图像只是从 StackExchange 帖子中获取的参考,目前我无法访问我自己的 Ubuntu 来获取更“个人”的屏幕截图)。

右键上下文菜单中的 nautilus 脚本示例

现在,您可以将以下两个文件添加到该文件夹​​中,我将它们命名为Meld (select first item)Meld (select second item)。我没有放.sh只是出于美观的原因(扩展名出现在上下文菜单中,我不喜欢它):每个文件开头都有 shebang 行,这足以让系统了解如何执行它们。

文件内容Meld (select first item)

#!/bin/bash
#-------------------------------------------------------------------------------
# Script:  Meld (select first item)
# Author:  Lorenz Keel (AskUbuntu)
# Purpose: Define left-side compare operand for meld
# Note:    Don't forget to run: chmod +x <script_name>
#------------------------------------------------------------------------------

# Exit values
STATUS_OK=0
STATUS_ERROR=1

# Check meld package installation
if [ -n "$(command -v meld)" ]; then
  # Create temp file
  TMP_FILE="/tmp/nautilus-compare.txt"
  # Check if the Nautilus environment variable is empty
  if [ -z "${NAUTILUS_SCRIPT_SELECTED_FILE_PATHS}" ]; then
    # If it's blank, exit with notification of error
    exit "${STATUS_ERROR}"
  else
    # Remove the previous version of the temporary file
    if [ -f "${TMP_FILE}" ]; then
      rm -rf "${TMP_FILE}"
    fi
    # Put quotes around every full path
    while read -r FULL_PATH; do
      echo "'${FULL_PATH}'" | tee "${TMP_FILE}"
    done < <(echo "${NAUTILUS_SCRIPT_SELECTED_FILE_PATHS::-1}")
  fi
else
  # Get the name of the current icon theme
  ICON_THEME="$(gsettings get org.gnome.desktop.interface icon-theme | tr -d "'")"
  # Set the value of the notification icon
  if [ -f "/usr/share/icons/${ICON_THEME}/scalable/status/dialog-error-symbolic.svg" ]; then
    NOTIFY_ICON="/usr/share/icons/${ICON_THEME}/scalable/status/dialog-error-symbolic.svg"
  else
    NOTIFY_ICON="error"
  fi
  # Specifies the timeout in seconds after which the dialog is closed
  NOTIFY_TIMEOUT=5000
  TEXT_ERROR="Installare meld per usare questo script"
  notify-send -t "${NOTIFY_TIMEOUT}" -i "${NOTIFY_ICON}" "${TEXT_ERROR}"
fi

# Exit with notification of success
exit "${STATUS_OK}"

上述文件尚未触发meld,而只是创建一个临时文件,其中包含在 Nautilus 中按下上下文Meld (select first item)菜单中的项目时选择的文件列表。所选文件从NAUTILUS_SCRIPT_SELECTED_FILE_PATHS用于此特定目的的特殊变量中读取。脚本的其余部分会在出现错误时触发带有 Ubuntu 顶部栏中相应图标的通知。

文件内容Meld (select first item)

#!/bin/bash
#-------------------------------------------------------------------------------
# Script:  Meld (select second item)
# Author:  Lorenz Keel (AskUbuntu)
# Purpose: Define right-side compare operand for meld
# Note:    Don't forget to run: chmod +x <script_name>
#------------------------------------------------------------------------------

# Exit values
STATUS_OK=0
STATUS_ERROR=1

# Check meld package installation
if [ -n "$(command -v meld)" ]; then
  # Temp file location
  TMP_FILE="/tmp/nautilus-compare.txt"
  # Check if the Nautilus environment variable is empty
  if [ -z "${NAUTILUS_SCRIPT_SELECTED_FILE_PATHS}" ]; then
    # If it's blank, exit with notification of error
    exit "${STATUS_ERROR}"
  else
    if [ -f "${TMP_FILE}" ]; then
      # Put quotes around every full path
      while read -r FULL_PATH; do
        echo "'${FULL_PATH}'" | tee -a "${TMP_FILE}"
      done < <(echo "${NAUTILUS_SCRIPT_SELECTED_FILE_PATHS::-1}")
    else
      # Temp file is absent, left item has not been selected
      exit "${STATUS_ERROR}"
    fi
  fi
  # Open meld
  tail -2 "${TMP_FILE}" | xargs meld &
  # Wait before deleting the temp file
  sleep 1s && rm -rf "${TMP_FILE}"
else
  # Get the name of the current icon theme
  ICON_THEME="$(gsettings get org.gnome.desktop.interface icon-theme | tr -d "'")"
  # Set the value of the notification icon
  if [ -f "/usr/share/icons/${ICON_THEME}/scalable/status/dialog-error-symbolic.svg" ]; then
    NOTIFY_ICON="/usr/share/icons/${ICON_THEME}/scalable/status/dialog-error-symbolic.svg"
  else
    NOTIFY_ICON="error"
  fi
  # Specifies the timeout in seconds after which the dialog is closed
  NOTIFY_TIMEOUT=5000
  TEXT_ERROR="Installare meld per usare questo script"
  notify-send -t "${NOTIFY_TIMEOUT}" -i "${NOTIFY_ICON}" "${TEXT_ERROR}"
fi

# Exit with notification of success
exit "${STATUS_OK}"

第二个脚本用比较的第二项填充临时文件,然后运行 ​​meld。

您可以使用您喜欢的文本编辑器创建这些文件,例如nano(从终端)或geditgnome-text-editor(如果您更喜欢 GUI)。重要的是将它们保存在我在本答案开头提到的文件夹中,并启用对它们的执行权限。

这些脚本是我自己编写的,供个人使用,我的最少调试表明它们可以完成我要求它们执行的简单任务,我知道它们可能还可以得到很大的改进。

答案3

下面是一个dash用于自动比较 [ 文件夹/文件 / office/pdf 文档 / 档案 ] 的脚本(该脚本Meld默认使用 - 进行比较;...:\\...对于.html/ .htm/.pdf文件,它还会比较其中包含的 URL( ):

#!/bin/dash
## Supported shells: dash, bash, zsh, ksh

PrintDesktopFile () {
    cat<<EOF
[Desktop Entry]
Name=File Comparer
Comment=Compares [ folders/files / office/pdf documents / archives ] using Meld
TryExec=$terminal_emulator
Exec=$terminal_emulator_plus_launch_flag "$current_shell_full_path" "$current_script_path" OPEN_WITH_MENU %U
Terminal=$1
Type=Application
Icon=utilities-terminal
Categories=Utility;
MimeType=inode/directory;text/plain;application/x-tar;application/x-gtar;application/x-compressed-tar;application/x-bzip-compressed-tar;application/x-tar-bz2;application/x-bzip2;application/zip;application/x-7z-compressed;application/x-rar-compressed;application/vnd.openxmlformats-officedocument.wordprocessingml.document;application/vnd.openxmlformats-officedocument.presentationml.presentation;application/vnd.openxmlformats-officedocument.presentationml.slideshow;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;application/vnd.oasis.opendocument.text;application/vnd.oasis.opendocument.spreadsheet;application/vnd.oasis.opendocument.presentation;application/pdf;application/x-xz;application/x-gzip
EOF
}

GetTerminalEmulatorPlusLaunchFlagLinux () {
    
    terminal_emulator_raw="$(ps -o comm= -p "$(($(ps -o ppid= -p "$(($(ps -o sid= -p "$$")))")))")"
    if [ ! "${terminal_emulator_raw#*"tmux"*}" = "$terminal_emulator_raw" ]; then
        terminal_emulator_raw="$(ps -o comm= -p "$(($(ps -o ppid= -p "$(($(ps -o sid= -p "$(tmux display-message -p "#{client_pid}")")))")))")"
    fi
    terminal_emulator="${terminal_emulator_raw%"-"}"
    
    if [ "$terminal_emulator" = "gnome-console" ] || [ "$terminal_emulator" = "gnome-terminal" ]; then
        terminal_emulator_plus_launch_flag="\"$terminal_emulator\" --"
    elif [ "$terminal_emulator" = "lxterminal" ] || [ "$terminal_emulator" = "qterminal" ]; then
        #For LXDE and LXQt for example: the shell can be called directly (no terminal emulator needed):
        terminal_emulator_plus_launch_flag=""
    else
        terminal_emulator_plus_launch_flag="\"$terminal_emulator\" -e"
    fi
}

PrintJustInTitle () {
    printf "\033]0;$1\007">"$print_to_screen"
}

CheckFilesFoldersToCompare () {
    if [ -z "$files_folders_to_compare" ]; then
        printf '%s\n' "Please add files/folders to the comparison queue first!"
        exit_code=1
    else
        error="false"
        IFS='
'
        for file in $(cat "$stored_file_paths_file_path"); do
            if [ ! -e "$file" ] || [ ! -r "$file" ]; then
                printf '%s\n' "ERROR: input file/folder: \"$file\" does not exist or is not readable!"
                error="true"
            fi
        done
        unset IFS
        if [ "$error" = "true" ]; then
            printf '\n%s\n\n' "Please: Try to readd files and compare them afterwards..."
            exit_code=1
        fi
    fi
}

GetOSType () {
    if [ -n "$1" ]; then
        case "$(uname -s)" in
        *"Linux"* )
            eval $1="Linux"
            ;;
        *"Darwin"* | *"BSD"* )
            eval $1="BSD-based"
            ;;
        * )
            eval $1="Other"
            ;;
        esac
    else
        printf '%s\n' 'ERROR: GetOSType: Expected 1 parameter!'>&2
        {
        printf '%s\n' 'Press Enter to exit...';
        RestoreSettings; read temp;
        }>"$print_to_screen"
    fi
}

GetCurrentShell () {
    if [ -n "$BASH_VERSION" ]; then current_shell_name="bash";
    elif [ -n "$ZSH_VERSION" ]; then current_shell_name="zsh";
    elif [ -n "$KSH_VERSION" ]; then current_shell_name="ksh";
    elif [ "$PS1" = '$ ' ]; then current_shell_name="dash";
    else current_shell_name="dash"; #default shell
    fi
    current_shell_full_path="$(which "$current_shell_name")"
    
    eval $1=\"\$current_shell_name\"
    eval $2=\"\$current_shell_full_path\"
}

ExtractFirstAndLastPathComponent () {
    eval current_path="\"\$$1\""
    
    first_path_component=""
    last_path_component=""
    
    if [ -n "$current_path" ]; then
        #Remove trailing '/' characters:
        while [ ! "${current_path%"/"}" = "$current_path" ]; do
            current_path="${current_path%"/"}"
        done
        
        if [ -z "$current_path" ]; then
            eval current_path=\"\$$1\"
        fi
        
        last_path_component="${current_path##*"/"}"
        first_path_component="${current_path%"$last_path_component"}"
    fi
    
    eval $2="\"\$first_path_component\""
    eval $3="\"\$last_path_component\""
}

ExtractFileIfArchive () {
    eval fileEFIA=\"\$$1\"
    
    if [ -z "$first_time" ]; then cat '/dev/null'>"$stored_file_paths_file_path"; first_time="defined"; fi
    
    case "$fileEFIA" in
        *'.zip' | *'.odt' | *'.ods' | *'.odp' | *'.docx' | *.'xlsx' | *'.pptx' | *'.ppsx' | \
        *'.7z' | *'.rar' | *'.pdf' | *'.htm' | *'.html' | \
        *'.tar.'* | *'.bz2' | *'.xz' | *'.gz' | *'.tgz' | *'.tar' | \
         '/dev/null' )
            error="false"
            case "$fileEFIA" in
                *'.pdf' )
                    CheckUtilitiesAndBuildMessage --warning pdftotext pdftohtml
                    if [ "$warning" = "true" ]; then ShowMessageDialog message; fi
                ;;
            esac
            if [ "$error" = "false" ]; then
                ExtractArchive fileEFIA fileEFIA_extracted
                output1="$(printf '%s' "$fileEFIA_extracted"|sed "s/'/$Q\"\$Q\"$Q/g")"
                printf "'%s' " "$output1"
            fi
        ;;
        * )
            output1="$(printf '%s' "$fileEFIA"|sed "s/'/$Q\"\$Q\"$Q/g")"
            printf "'%s' " "$output1"
            fileEFIA_extracted="$fileEFIA"
        ;;
    esac
    
    printf '%s\n' "$fileEFIA_extracted">>"$stored_file_paths_file_path"
}

ExtractArchive () {
    eval current_archive_path="\"\$$1\""
    
    if [ "$current_archive_path" = '/dev/null' ]; then
        {
        cd "$output_dir" || error="true"
        mkdir "null"; cd "null" || error="true"
        full_current_archive_extract_to_path="$output_dir/null"
        cat /dev/null>"$full_current_archive_extract_to_path""/""temp.links.txt" || error="true"
        } 2>/dev/null
        if [ "$error" = "true" ]; then printf '%s\n' "ERROR: Could not create/access <output> directory structure!">&2; { printf '%s\n' "Press Enter to exit..."; RestoreSettings; read temp; kill $$; }>"$print_to_screen"; fi

    else
        full_current_archive_path="$current_archive_path"
        
        ExtractFirstAndLastPathComponent current_archive_path fpc_current_archive_path lpc_current_archive_path
        cd "$fpc_current_archive_path"
        fpc_current_archive_path="$PWD"
        
        ExtractFirstAndLastPathComponent fpc_current_archive_path fpc_fpc_current_archive_path lpc_fpc_current_archive_path
        current_archive_name_ext="${lpc_current_archive_path}"
        if [ ! -d "$current_archive_path" ]; then
            current_archive_name_ext_plus="$current_archive_name_ext""_extract"
        else
            current_archive_name_ext_plus="$current_archive_name_ext"
        fi
        full_current_archive_extract_to_path="$output_dir/$lpc_fpc_current_archive_path/$current_archive_name_ext_plus"

        
        if [ ! -e "$full_current_archive_extract_to_path" ]; then
            {
            error="false"
            cd "$output_dir" || error="true"
            mkdir "$lpc_fpc_current_archive_path"; cd "$lpc_fpc_current_archive_path" || error="true"
            mkdir "$current_archive_name_ext_plus"; cd "$current_archive_name_ext_plus" || error="true"
            } 2>/dev/null
            if [ "$error" = "true" ]; then printf '%s\n' "ERROR: Could not create/access <output> directory structure!">&2; { printf '%s\n' "Press Enter to exit..."; RestoreSettings; read temp; kill $$; }>"$print_to_screen"; fi
            
            case "$current_archive_path" in
                *'.zip' | *'.odt' | *'.ods' | *'.odp' | *'.docx' | *.'xlsx' | *'.pptx' | *'.ppsx' )
                    unzip "$full_current_archive_path" -d "$full_current_archive_extract_to_path"
                ;;
                *'.7z' )
                    7z x "$full_current_archive_path" -o"$full_current_archive_extract_to_path/"
                ;;
                *'.rar' )
                    unrar x "$full_current_archive_path" "$full_current_archive_extract_to_path/"
                ;;
                *'.pdf' )
                    pdftotext "$full_current_archive_path" "$full_current_archive_extract_to_path""/""temp.text.txt"
                    pdftohtml "$full_current_archive_path" "$full_current_archive_extract_to_path""/""temp.html"
                    cat "$full_current_archive_extract_to_path""/"*|eval "$extract_urls_command">>"$full_current_archive_extract_to_path""/""temp.links.txt"
                    full_current_archive_extract_to_path="$full_current_archive_extract_to_path"
                ;;
                *'.htm' | *'.html' )
                    cp "$full_current_archive_path" "$full_current_archive_extract_to_path""/""temp.html"
                    cat "$full_current_archive_extract_to_path""/"*|eval "$extract_urls_command">>"$full_current_archive_extract_to_path""/""temp.links.txt"
                    full_current_archive_extract_to_path="$full_current_archive_extract_to_path"
                ;;
                *'.bz2' | *'.xz' | *'.gz' )
                    cp "$full_current_archive_path" "$full_current_archive_extract_to_path"
                    case "$current_archive_path" in
                        *'.bz2' ) bzip2 "$full_current_archive_extract_to_path/""$current_archive_name_ext" -d "$full_current_archive_extract_to_path"; ;;
                        *'.xz' ) xz "$full_current_archive_extract_to_path/""$current_archive_name_ext" -d "$full_current_archive_extract_to_path"; ;;
                        *'.gz' ) gzip -d "$full_current_archive_extract_to_path/""$current_archive_name_ext"; ;;
                    esac
                    case "${current_archive_name_ext%"."*}" in
                        *'.tar' )
                            tar -xvf "$full_current_archive_extract_to_path/${current_archive_name_ext%"."*}" -C "$full_current_archive_extract_to_path"
                            rm "$full_current_archive_extract_to_path/${current_archive_name_ext%"."*}"
                        ;;
                    esac
                ;;
                *'.tgz' | *'.tar' )
                    tar -xvf "$full_current_archive_path" -C "$full_current_archive_extract_to_path"
                ;;
            esac >/dev/null 2>/dev/null
        else
            cd "$full_current_archive_extract_to_path"
        fi
    fi
    eval $2=\"\$full_current_archive_extract_to_path\"
}

ShowMessageDialog () {
    eval message="\"\$$1\""
    zenity --warning --text="$message" --no-wrap
    
}

CheckUtilitiesAndBuildMessage () {
    #Check if any of the necessary utilities is missing:
    
    message=""
    msg_type="warning"; msg_prefix="WARNING"
    warning="false"
    if [ "$1" = '--warning' ]; then
        shift
    elif [ "$1" = '--warning-message' ]; then
        eval message="\"\$$2\""
        shift; shift
    else
        msg_type="error"; msg_prefix="ERROR"
        error="false"
    fi
    
    warning_all="false"; error_all="false"
    error_or_warning_count="0"
    for utility; do
        which $utility >/dev/null 2>/dev/null || {
            error_or_warning_count=$(($error_or_warning_count + 1))
            if [ -z "$message" ]; then
                message="$msg_prefix: the '$utility'"
            else
                message="$message"", '$utility'"
            fi
            eval $msg_type="\"true\""
            eval $msg_type\_all="\"true\""
        }
    done
    
    if [ "$warning_all" = "true" ] || [ "$error_all" = "true" ]; then
        if [ "$error_or_warning_count" = "1" ]; then
            message="$message"" utility is not installed!"
        elif [ "$error_or_warning_count" -gt "1" ]; then
            message="$message"" utilities are not installed!"
        fi
    fi
    
    if [ "$error" = "true" ]; then RestoreSettings; fi
}

RestoreSettings () {
    IFS="$initial_IFS"
    cd "$initial_dir"
}

CheckCreateMainDirs () {
    {
        [ -n "$TEMPORARY_EXTRACT_PATH" ] && cd "$TEMPORARY_EXTRACT_PATH" && {
            if [ ! -e "$TEMPORARY_EXTRACT_FOLDER" ]; then
                mkdir "$TEMPORARY_EXTRACT_FOLDER" || error="true"
            fi
            cd "$TEMPORARY_EXTRACT_FOLDER" && output_dir="$PWD" || {
                error="true"
            }
        } || error="true"
    } 2>/dev/null
    if [ "$error" = "true" ]; then
        printf '%s\n' "Error: Could not access temporary folder \"$TEMPORARY_EXTRACT_FOLDER\" in the extract location: \"$TEMPORARY_EXTRACT_PATH\"!">&2
        { printf '%s\n' "Press Enter to exit..."; RestoreSettings; read temp; }>"$print_to_screen"; exit 1
    fi
}


set +f #Enable globbing (POSIX compliant)
setopt no_nomatch 2>/dev/null #Enable globbing (zsh)

Q="'"

initial_IFS="$IFS"

GetOSType OS_TYPE

cd "${0%/*}" 2>/dev/null
current_script_path="$(pwd -P)/${0##*/}"

GetCurrentShell current_shell_name current_shell_full_path

APPS_DESKTOP_FILES_FOLDER="$HOME/.local/share/applications" #(for Linux) this is the default location for .desktop files (should not be changed)

[ "$OS_TYPE" = "Linux" ] && [ -e '/dev/shm' ] && {
    TEMPORARY_EXTRACT_PATH='/dev/shm'
} 2>/dev/null || {
    [ "$OS_TYPE" = "BSD-based" ] && [ -e "$HOME" ] && {
        TEMPORARY_EXTRACT_PATH="$HOME"
    } || {
        printf '%s\n' "Please provide TEMPORARY_EXTRACT_PATH: ">&2
        read TEMPORARY_EXTRACT_PATH>"$print_to_screen"
    }
}
TEMPORARY_EXTRACT_FOLDER='TEMP_EXTR_FOLDER' #should not be changed

CheckCreateMainDirs

desktop_file_name_ext="FileComparerScript.desktop" #can be changed
desktop_file_path="$APPS_DESKTOP_FILES_FOLDER""/""$desktop_file_name_ext"

stored_file_paths_file_parent_dir_path="$APPS_DESKTOP_FILES_FOLDER" #can be changed
if [ ! -e "$stored_file_paths_file_parent_dir_path" ]; then
    stored_file_paths_file_parent_dir_path="$HOME" #can be changed
fi

stored_file_paths_file_path="$stored_file_paths_file_parent_dir_path""/"'FileComparerScriptSettings.txt'
temp_compared_status_file="$stored_file_paths_file_parent_dir_path""/"'temp_compared_status_file.txt'
temp_to_be_resetted_status_file="$stored_file_paths_file_parent_dir_path""/""temp_to_be_resetted.txt"

NL=$(printf '%s' "\n") #Store New Line for use with sed
TAB=$(printf '%s' "\t")

#By URL, it is meant a website link in the form: ...://...
insert_NL_before_and_after_URLs_command='sed -E '"'"'s/([^a-zA-Z]*)([a-zA-Z]+\:\/\/){1}((([a-zA-Z]+[0-9\-]*)+(\.[a-zA-Z]+[0-9\-]*)+)+)(([^ ^'"${TAB}"'^>^<])*)/'"${NL}"'\2\3\7'"${NL}"'/g'"'"
strip_NON_FULL_URL_text_command='sed -E '"'"'s/([^a-zA-Z]*)([a-zA-Z]+\:\/\/){1}((([a-zA-Z]+[0-9\-]*)+(\.[a-zA-Z]+[0-9\-]*)+)+)(([^ ^'"${TAB}"'^>^<])*).*/\2\3\7/g'"'"
delete_lines_not_containing_an_URL='sed -E '"'"'/.*([a-zA-Z]+\:\/\/){1}((([a-zA-Z]+[0-9\-]*)+(\.[a-zA-Z]+[0-9\-]*)+)+).*/!d'"'"
extract_urls_command="$insert_NL_before_and_after_URLs_command|$strip_NON_FULL_URL_text_command|$delete_lines_not_containing_an_URL"

print_to_screen='/dev/tty'

exit_code=0

OPEN_WITH_MENU=""; if [ "$1" = "OPEN_WITH_MENU" ]; then OPEN_WITH_MENU="OPEN_WITH_MENU"; shift; fi
if [ "$1" = "--install" ]; then
    
    IFS='
'
    
    if [ "$OS_TYPE" = "Linux" ]; then
        
        error="false"
        
        CheckUtilitiesAndBuildMessage grep update-desktop-database cat ps
        if [ "$error" = "true" ]; then message="INSTALL: ""$message"; ShowMessageDialog message; exit 1; fi
        
        cat '/dev/null'>"$desktop_file_path"
        
        GetTerminalEmulatorPlusLaunchFlagLinux
        
        #terminal_visible=false/true <=> not show / show: the initial launcher app (terminal) window
        #for LXDE and LXQt Desktop Environments: use "true"; otherwise: use "false"
        if [ -z "$terminal_emulator_plus_launch_flag" ]; then
            terminal_visible="true"
        else
            terminal_visible="false"
        fi
        
        PrintDesktopFile $terminal_visible>"$desktop_file_path"
        
        favorite_icons_list=$(dconf read /org/gnome/shell/favorite-apps 2>/dev/null) || { error="true"; }
        printf '%s' "$favorite_icons_list"|grep -F "$desktop_file_name_ext">/dev/null || {
            dconf write /org/gnome/shell/favorite-apps "${favorite_icons_list%"]"}"", ""'$desktop_file_name_ext'""]"
        } 2>/dev/null || { error="true"; }
        # Update database of desktop entries cache:
        update-desktop-database "$APPS_DESKTOP_FILES_FOLDER" || { error="true"; }
        
        if [ "$error" = "true" ]; then
            printf '\n%s\n\n' "ERROR: Install encountered errors."
        else
            printf '\n%s\n\n' "Installed as '$desktop_file_name_ext' in the Desktop Favorite Apps Ribbon (Dock)."
        fi
    else
        printf '\n%s\n\n' "ERROR: Currently, install is implemented only for the Linux operating systems!"
    fi
fi
if [ -z "$1" ]; then
    printf '%s\n' "true">"$temp_to_be_resetted_status_file"
fi
if [ ! "$1" = "--install" ]; then
    
    CheckUtilitiesAndBuildMessage mkdir cat kill unzip tar cp
    if [ "$error" = "true" ]; then ShowMessageDialog message; exit 1; fi
    
    initial_dir="$PWD"
    
    output_dir=""
    error="false"
    
    if [ ! -e "$temp_to_be_resetted_status_file" ]; then
        cat '/dev/null'>"$temp_to_be_resetted_status_file"
    fi
    
    cd "$initial_dir"
    
    
    if [ ! -e "$stored_file_paths_file_path" ]; then
        cat '/dev/null'>"$stored_file_paths_file_path"
    fi
    
    PrintJustInTitle "File Comparer"
    
    if [ -e "$1" ]; then
        #######
        if [ -z "$(cat "$temp_compared_status_file" 2>/dev/null)" ]; then
            printf '%s\n' "compared">"$temp_compared_status_file" 2>/dev/null
        else
            cat '/dev/null'>"$temp_compared_status_file" 2>/dev/null
        fi
        
        if [ "$(cat "$temp_to_be_resetted_status_file")" = "true" ]; then
            cat '/dev/null'>"$stored_file_paths_file_path"
            printf '%s\n' "false">"$temp_to_be_resetted_status_file"
            if [ -n "$TEMPORARY_EXTRACT_PATH" ] && [ -n "$TEMPORARY_EXTRACT_FOLDER" ] && [ -n "$output_dir" ]; then
                rm -R -f "$output_dir/"*
            fi
        fi
        #######
        
        for file; do
            printf '%s\n' "Loading file: '$file'..."
            files_folders_to_compare=$( \
                IFS='
'; \
                for current_file in $(cat "$stored_file_paths_file_path"); do \
                    ExtractFileIfArchive current_file; \
                done; \
                ExtractFileIfArchive file; \
            );
        done
    else
        if [ -z "$3" ]; then
            files_folders_to_compare=$( \
                IFS='
'; \
                for current_file in $(cat "$stored_file_paths_file_path"); do \
                    ExtractFileIfArchive current_file; \
                done; \
            );
        fi
        
        ##
        
        IFS='
'
        CheckFilesFoldersToCompare
        if [ "$exit_code" = "0" ]; then
            printf '%s\n' "compared">"$temp_compared_status_file"
            IFS='
'
            eval meld $files_folders_to_compare 2>/dev/null||{
                printf '%s\n' "ERROR: MELD (see above)">&2
                {
                printf '%s\n' "Press Enter to exit...";
                RestoreSettings; read temp;
                }>"$print_to_screen"
                exit_code=1
            }
        fi
    fi
fi
IFS="$initial_IFS"

在 Linux 上:

  1. 如果尚未完成:运行脚本来--install flag安装.desktop文件(以便快速访问)

  2. 第二步

    1. 右键单击 [ 文件夹/文件 / office/pdf 文档 / 档案 ],选择Open With,然后选择File Comparer
      -> 以便将这些 [ 文件夹/文件 / office/pdf 文档 / 档案 ] 添加到比较队列

    2. (可以重复运行:)运行不带参数的脚本以进行比较(文件选择会被记住,直到2.1.再次运行该步骤)

专为 Linux 设计,同时考虑到 macOS:可以适用于 macOS。

macOS 缺少的部分是 Dock 和 OpenWith 菜单项 - 请参阅下面的链接了解如何在 Mac 上手动创建这些:

Dock 链接

使用菜单打开的链接

相关内容