Nemoファイルマネージャは、ソート時にディレクトリ名の先頭の「_」を完全に無視します。

Nemoファイルマネージャは、ソート時にディレクトリ名の先頭の「_」を完全に無視します。

前任者。いくつかのディレクトリの名前が指定されたとします。

absorbing
appreciate
arrive
connect
depend
drop
few
fold
littlel
popcorn
shrill
sticky

_Windowsでは、ディレクトリの前に置くとこんなに上に来ます。

_connect
_few
_little
_shrill
absorbing
appreciate
arrive
depend
drop
fold
popcorn
sticky

ただし、Nemo 4.0.6でアルファベット順に並べ替えると、同じディレクトリが次のようになります(具体的にはLinux Mint 19.1、Cinnamon 4.0.10)。

absorbing
appreciate
arrive
_connect
depend
drop
_few
fold
_little
popcorn
_shrill
sticky

したがって、Nemoのソートアルゴリズムは_ディレクトリ名の先頭を完全に無視します。

最初のリストのようにソートが機能するようにしたいのですが、これを行う方法はありますか?

ベストアンサー1

私はこのソリューションをLinux Mint 19.3でテストしました。

まず読んでください。nemoファイルのソート順序は/ bin / lsとは異なります。少し背景。

2つのステップがあります。

  1. ロケールに基づいてソートされるように Nemo を変更します。
  2. ロケールを編集/usr/share/i18n/locales/iso14651_t1_commonして必要に応じて並べ替えます。

1. ニモを修正する

主なガイドは次の場所にあります。GitHub

git clone https://github.com/linuxmint/nemo

今編集する必要があります。nemo/libnemo-private/nemo-file.c

削除する:

/* Files that start with these characters sort after files that don't. */
#define SORT_LAST_CHAR1 '.'
#define SORT_LAST_CHAR2 '#'

変える:

static int
compare_by_display_name (NemoFile *file_1, NemoFile *file_2)
{
    const char *name_1, *name_2;
    const char *key_1, *key_2;
    gboolean sort_last_1, sort_last_2;
    int compare=0;

    name_1 = nemo_file_peek_display_name (file_1);
    name_2 = nemo_file_peek_display_name (file_2);

    sort_last_1 = name_1 && (name_1[0] == SORT_LAST_CHAR1 || name_1[0] == SORT_LAST_CHAR2);
    sort_last_2 = name_2 && (name_2[0] == SORT_LAST_CHAR1 || name_2[0] == SORT_LAST_CHAR2);

    if (sort_last_1 && !sort_last_2) {
        compare = +1;
    } else if (!sort_last_1 && sort_last_2) {
        compare = -1;
    } else if (name_1 == NULL || name_2 == NULL) {
        if (name_1 && !name_2)
            compare = +1;
        else if (!name_1 && name_2)
            compare = -1;
    } else {
        key_1 = nemo_file_peek_display_name_collation_key (file_1);
        key_2 = nemo_file_peek_display_name_collation_key (file_2);
        compare = g_strcmp0 (key_1, key_2);
    }

    return compare;
}

そして:

static int
compare_by_display_name (NemoFile *file_1, NemoFile *file_2)
{
    const char *key_1, *key_2;
    int compare=0;

    key_1 = nemo_file_peek_display_name_collation_key (file_1);
    key_2 = nemo_file_peek_display_name_collation_key (file_2);
    compare = strcmp (key_1, key_2);

    return compare;
}

そして、次のものを交換してください:

file->details->display_name_collation_key = g_utf8_collate_key_for_filename (display_name, -1);

そして:

file->details->display_name_collation_key = g_utf8_collate_key (display_name, -1);

今開くソースコードリポジトリソフトウェアソースから。

次に、nemoディレクトリから次のコマンドを実行します。

sudo apt-get build-dep nemo 
dpkg-buildpackage 
cd .. && sudo dpkg -i *.deb

その後、ctrlaltbackspaceXorgを再起動します。

ここに画像の説明を入力してください。

2. 修正iso14651_t1_common

管理者として開きます/usr/share/i18n/locales/iso14651_t1_common

変える:

<U005F> IGNORE;IGNORE;IGNORE;<U005F> # 33 _ 

そして:

<U005F> <RES-2>;IGNORE;IGNORE;<U005F> # 33 _

走るsudo locale-gen

感謝の言葉

  1. マイケル・ウェブスター教えるソースから Nemo をビルド

  2. bjd-pfq設立するg_utf8_collat​​e_key_for_filenameの問題

  3. スティーブンシュ私に向かって案内してくださいニモとティンカー

  4. 理解に役立つ2つ /usr/share/i18n/locales/iso14651_t1_commonの記事豆ディップ。正解は、大文字と小文字を区別せずに「ls」にドットファイルを最初に表示させる方法は?&LC_COLLATE を使用して、小文字が大文字の前に来るようにソート順を指定します。

ポリスチレンこの回答の以前のバージョンは以下にあります。改訂

おすすめ記事