superfile 設定

設定你的 superfile

你可以使用以下指令編輯 superfile 設定檔:

$EDITOR config_path

設定

  • theme

點這裡查看編輯 theme 的說明。

  • editor

開啟檔案時使用的編輯器(留空會使用 EDITOR 環境變數。如果未設定 EDITOR 環境變數,macOS/Linux 預設為 nano,Windows 預設為 notepad)。

  • dir_editor

開啟目錄時使用的編輯器(留空會使用預設值:vi - Linux、open - macOS、explorer - Windows)。

  • auto_check_update

true => 離開 superfile 時檢查是否需要更新(每天只檢查一次)。

false => 不執行檢查。

  • cd_on_quit

true => 離開 superfile 時,將終端機路徑變更為你最後使用的 file 面板。

false => 離開 superfile 時,終端機路徑維持進入 superfile 前的位置。

設定為 true 後,你需要更新 shell 設定檔。範例變更:

macOS/Linux(bash 或 fish)
Bash

開啟檔案:

$EDITOR ~/.bashrc

將以下程式碼複製到檔案中:

cd_on_quit/cd_on_quit.sh
spf() {
    os=$(uname -s)

    # Linux
    if [[ "$os" == "Linux" ]]; then
        export SPF_LAST_DIR="${XDG_STATE_HOME:-$HOME/.local/state}/superfile/lastdir"
    fi

    # macOS
    if [[ "$os" == "Darwin" ]]; then
        export SPF_LAST_DIR="$HOME/Library/Application Support/superfile/lastdir"
    fi

    command spf "$@"

    [ ! -f "$SPF_LAST_DIR" ] || {
        . "$SPF_LAST_DIR"
        rm -f -- "$SPF_LAST_DIR" > /dev/null
    }
}

儲存、離開,並重新載入 .bashrc 檔案:

source ~/.bashrc
Fish

開啟檔案:

$EDITOR ~/.config/fish/config.fish

如果你懷疑 config.fish 檔案位於其他位置,請閱讀 Fish shell 文件

將以下程式碼複製到檔案中:

cd_on_quit/cd_on_quit.fish
function spf
    set os $(uname -s)

    if test "$os" = "Linux"
        set spf_last_dir "$HOME/.local/state/superfile/lastdir"
    end

    if test "$os" = "Darwin"
        set spf_last_dir "$HOME/Library/Application Support/superfile/lastdir"
    end

    command spf $argv

    if test -f "$spf_last_dir"
        source "$spf_last_dir"
        rm -f -- "$spf_last_dir" >> /dev/null
    end
end

儲存、離開,並重新載入 config.fish

source ~/.config/fish/config.fish
Windows (Powershell)

開啟檔案:

notepad $PROFILE

將以下程式碼複製到檔案中:

cd_on_quit/cd_on_quit.ps1
function spf() {
    param (
        [string[]]$Params
    )
    $spf_location = [Environment]::GetFolderPath("LocalApplicationData") + "\Programs\superfile\spf.exe"
    $SPF_LAST_DIR_PATH = [Environment]::GetFolderPath("LocalApplicationData") + "\superfile\lastdir"

    & $spf_location @Params

    if (Test-Path $SPF_LAST_DIR_PATH) {
        $SPF_LAST_DIR = Get-Content -Path $SPF_LAST_DIR_PATH
        Invoke-Expression $SPF_LAST_DIR
        Remove-Item -Force $SPF_LAST_DIR_PATH
    }
}

儲存、離開,並重新載入你的 profile。

. $PROFILE
  • default_open_file_preview

true => 執行 superfile 時顯示檔案預覽視窗。

false => 執行 superfile 時隱藏檔案預覽視窗。

  • show_image_preview

true => 選取圖片檔案時,在 file preview panel 中顯示圖片預覽。

false => 不顯示圖片預覽。

true => 在 file panel 顯示額外 footer 資訊,例如 panel mode 和 sort type。

false => 不在 file panel 顯示額外 footer 資訊。

  • file_size_use_si

true => 使用 1000 次方顯示檔案或目錄大小(kB、MB、GB)。

false => 使用 1024 次方顯示檔案或目錄大小(KiB、MiB、GiB)。

  • default_directory

每次開啟 superfile 時的預設位置。支援 ~.

  • default_sort_type

File panel 排序類型。目錄一律會顯示在最上方。

0 => Name

1 => Size

2 => Date Modified

3 => Type

4 => Natural

  • sort_order_reversed

File panel 排序順序。

false => 遞增(a-z)

true => 遞減(z-a)

  • case_sensitive_sort

File panel 排序是否區分大小寫(如果為 true,大寫字母會排在小寫字母前面)。

true => 區分大小寫(“B” 排在 “a” 前面)

false => 不區分大小寫(“a” 排在 “B” 前面)

  • debug

是否啟用 debug mode(如果為 true,會在 log file 寫入更詳細的 logs)。

true => DEBUG、INFO、WARN、ERROR logs 會寫入 log file

false => INFO、WARN、ERROR logs 會寫入 log file

  • ignore_missing_fields

控制是否顯示設定檔缺少欄位的警告。

true => 設定檔缺少欄位時不顯示警告

false => 設定檔缺少任何欄位時都會顯示警告

  • page_scroll_size

使用 PgUp/PgDown 鍵時捲動的行數。

0 => 捲動整頁(預設行為)

n(其中 n > 0)=> 精確捲動 n 行

  • file_panel_extra_columns

File panel 中除檔名外的額外欄位數量。

0 => 停用額外欄位功能 1 => 也顯示大小欄位 2 => 也顯示修改日期 3 => 也顯示權限欄位

  • file_panel_name_percent

分配給 file panel 檔名的寬度百分比(25-100)。數值越高,檔名可用空間越多,額外欄位可用空間越少。

樣式

  • code_previewer

'' => 使用內建的 chroma 語法醒目提示來預覽程式碼檔案。 'bat' => 使用 bat 命令列工具提供的語法醒目提示。

  • nerdfont

true => 對目錄和檔案圖示使用 nerdfont。

false => 不使用 nerdfont。如果你沒有安裝或不想安裝 Nerdfont,可以關閉此選項。

  • show_select_icons

true => 在 select mode 顯示 checkbox icons。

false => 不在 select mode 顯示 checkbox icons。

  • transparent_background

true => 不渲染背景色(透明)。如果你的終端機背景是透明的,這會很有用。

false => 渲染背景(含顏色)以維持 theme 一致性。

  • file_preview_width

此設定為整數。

0 => 檔案預覽視窗寬度與 file panel 相同。

X => 檔案預覽視窗寬度為終端機寬度(扣除 sidebar 寬度)的 1/X。計算方式為:(terminal width - sidebar width) / X

  • enable_file_preview_border

true => 啟用 file preview panel 周圍的邊框

false => 停用 file preview panel 周圍的邊框

此設定為整數。

0 => 不顯示 sidebar。

X => sidebar 的寬度(不含邊框)。

Sidebar sections 的順序。

["home", "pinned", "disks"] => 預設順序。

只有包含在此清單中的 sections 會顯示。你可以移除 sections 或變更順序,例如:["pinned", "home"]

  • border style

以下是幾種建議樣式,當然你也可以改成自己的樣式:

# ...
border_top = "━"
border_bottom = "━"
border_left = "┃"
border_right = "┃"
border_top_left = "┏"
border_top_right = "┓"
border_bottom_left = "┗"
border_bottom_right = "┛"
border_middle_left = "┣"
border_middle_right = "┫"
#...
# ...
border_top = "─"
border_bottom = "─"
border_left = "│"
border_right = "│"
border_top_left = "╭"
border_top_right = "╮"
border_bottom_left = "╰"
border_bottom_right = "╯"
border_middle_left = "├"
border_middle_right = "┤"
#...
  • open_with

允許使用者將副檔名對應到用來開啟它們的指令。檔案路徑會附加為最後一個參數。

[open_with]
xopp = "xournalpp"
conf = "nvim"

預設 superfile 設定

src/superfile_config/config.toml
##############################################
#                                            #
#           Superfile Configuration          #
#                                            #
##############################################

# This contains the root config file for superfile! More details can be found at
# https://superfile.dev/configure/superfile-config/.

###############################################################################
#                                   Defaults                                  #
###############################################################################

#-- File Editor
# Default: $EDITOR
editor = ""

#-- Directory Editor
# 
dir_editor = ""

#-- Auto check for update
auto_check_update = true

#-- cd on quit
# Should we cd the shell to the last directory open in superfile when the
# program exits? 
cd_on_quit = false

#-- File Preview
# Should we open a file preview by default whenever selection-hovering over a
# file?
default_open_file_preview = true

#-- Image Preview
# Should we open an image preview by default whenever selection-hovering over an
# image?
show_image_preview = true

#-- File Info Footer
# Should we display a footer in the file panel that provides more file information?
show_panel_footer_info = true

#-- Default Directory
# The initial path that the file panel should navigate to when superfile is
# opened. This setting understands relative paths such as ".", "..", etc.
default_directory = "."

#-- File Size Units
# true: SI decimal units of 1000 (kB, MB, GB).
# false: IEC binary units of 1024 (KiB, MiB, GiB).
file_size_use_si = false

#-- Default File Sort Type
# (0: Name, 1: Size, 2: Date Modified, 3: Type, 4: Natural).
# Natural sort treats numeric sequences as numbers (e.g., file2 before file10).
default_sort_type = 0

#-- Sort Order Reversing
# true: Descending.
# false: Ascending.
sort_order_reversed = false

#-- Case-Sensitive Sorting
# An uppercase "B" comes before a lowercase "a" if true.
case_sensitive_sort = false

#-- Exit Shell on Success
# Whether to exit the shell on successful command execution.
shell_close_on_success = false

#-- Page Scroll Size
# Number of lines to scroll for PgUp/PgDown keys (0: full page, default behavior).
page_scroll_size = 0

#-- Debug Mode
debug = false

#-- Ignore Missing Config Fields
# Whether to silence any warnings about missing config fields.
ignore_missing_fields = false

#-- File Panel Extra Columns Count
# Count of extra columns in file panel in addition to file name. When option equal 0 then feature is disabled.
file_panel_extra_columns = 0

#-- File name width in File Panel
# Percentage of file panel width allocated to file names (25-100). Higher values give more space to names, less to extra columns.
file_panel_name_percent = 50


###############################################################################
#                                   Styling                                   #
###############################################################################

#-- Theme
# Put your theme's name here!
theme = "catppuccin-mocha"

#-- Code Previewer
# Whether to use the builtin syntax highlighting with chroma or use bat. Values: "" for builtin chroma, "bat" for bat
code_previewer = ""

#-- Nerd Fonts Support
# Whether to enable support for Nerd Fonts symbols.
# Requires:  Font patched with the Nerd Fonts patch.
nerdfont = true

#-- Show checkbox icons in select mode
# Requires: nerdfont = true
show_select_icons = true

#-- Transparent Background Support
# Set to true to enable background transparency.
# Requires: terminal support for colour transparency
transparent_background = false

#-- File Preview Panel Width
# Width of the file preview panel will be 1/n of the total width.
# Values recommended to be in 2–10.
# Default (0): Use the same width as file picker panel.
file_preview_width = 0

#-- File Preview Border
# Enable border around the file preview panel for better visual separation.
# Default: false (no border)
enable_file_preview_border = false

#-- Sidebar Width
# If you don't want to display the sidebar, you can input 0 directly.
# Values recommended to be in 5–20.
sidebar_width = 20

#-- Sidebar Section Order
# Order of sidebar sections (valid values: "home", "pinned", "disks")
# Only enabled sections will be displayed
sidebar_sections = ["home", "pinned", "disks"]

#-- Border
# Make sure to add strings that are exactly one character wide!
# Use ' ' for borderless.
border_top = '─'
border_bottom = '─'
border_left = '│'
border_right = '│'
border_top_left = '╭'
border_top_right = '╮'
border_bottom_left = '╰'
border_bottom_right = '╯'
border_middle_left = '├'
border_middle_right = '┤'

###############################################################################
#                                   Plugins                                   #
###############################################################################

# This section is for using plugins with superfile, external addons that extend
# the default capabilities of the program! More info can be found at
# https://superfile.dev/list/plugin-list/.

#-- Detailed Metadata
# Requires: exiftool
metadata = false

#-- MD5 Checksum Generation
# Requires: md5sum
enable_md5_checksum = false
#
#-- Zoxide Support - Smart directory navigation!
# Requires: zoxide
zoxide_support = false

#-- File opening rules
# Map file extensions to commands used to open them.
# The file path will be appended as the last argument.
# MUST BE IN THE VERY END OF THE FILE BECAUSE TOML CANNOT CLOSE TABLES
# Example:
#   png = "feh"
#   pdf = "zathura"
#   conf = "nvim"
[open_with]