feh 命令详解

| 选择喜欢的代码风格  

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

feh 命令安装:


-bash/zsh: feh: command not found

# Windows (WSL2)
sudo apt-get update sudo apt-get install feh

# Debian
apt-get install feh

# Ubuntu
apt-get install feh

# Alpine
apk add feh

# Arch Linux
pacman -S feh

# Kali Linux
apt-get install feh

# Fedora
dnf install feh

# OS X
brew install feh

# Raspbian
apt-get install feh

# Dockerfile
dockerfile.run/feh

# Docker
docker run cmd.cat/feh feh

feh 命令补充说明:


feh 是一个轻量级、可配置且多功能的图像查看器。 它针对命令行用户,但也可以从图形文件管理器启动。 除了查看图像之外,它还可以编译文本和缩略图列表、显示(不可)加载文件、设置 X11 背景等等。

功能包括文件列表、各种图像排序模式、自定义操作脚本和图像标题。 feh 可以通过可配置的键盘和鼠标快捷键、终端输入和信号进行控制。 当未指定文件参数或文件列表且未使用 --start-at 时, feh 显示当前目录中的所有文件。

通过 --info 使用 exiv2 / exifgrep 支持 EXIF 标记(请参阅使用示例部分),或者通过使用 exif=1 编译 feh 作为内置功能。 在此版本的 feh 中,可以使用内置 EXIF 支持。

feh 命令语法:


feh [options] [--] [files | directories | URLs ...]

feh 命令选项:


-A, --action [flag][[title]]action
Specify a shell command as an action to perform on the image. In slideshow or multiwindow mode, the action will be run when the action_0 key is pressed, in list mode, it will be run for each file. In loadable/unloadable mode, it will be run for each loadable/unloadable file, respectively. In thumbnail mode, clicking on an image will cause the action to run instead of opening the image.
If flag is ";", feh will reload the current image instead of switching to the next one (slideshow mode) or closing the window (multiwindow mode) after executing the action. If [title] is specified (note the literal "[" and "]"), --draw-actions will display title instead of action in the action list. Note that title must not start with a space. If it does, the action is handled as if it did not have a title. This special case exists for backwards compatibility reasons and makes sure that actions like "[ -L %F ] && foo" still work.

The action will be executed by /bin/sh. Use format specifiers to refer to image info, see FORMAT SPECIFIERS for details. Example usage: "feh -A "mv %F ~/images/%N" *".

--action1 .. --action9 [flag][[title]]action
Extra actions which can be set and triggered using the appropriate number key.
--auto-reload
(optional feature, enabled in this build) automatically reload image when the underlying file changes. Note that auto-reload (if enabled in the build) is on by default. This option is only useful to re-enable auto-reload after it has been disabled by a preceding --reload=0 option.
Automatic reload is not supported in montage, index, or thumbnail mode.

--auto-rotate
(optional feature, available in this build) (deprecated in favor of Imlib2's auto-orientation support) Automatically rotate images based on EXIF data. Does not alter the image files.
Note that Imlib2 version 1.7.5+ performs auto-rotation by itself, so this option is obsolete on systems with Imlib2 version 1.7.5 or later. feh currently cannot detect this at runtime.

-Z, --auto-zoom
Zoom pictures to screen size in fullscreen / fixed geometry mode.
-x, --borderless
Create borderless windows.
--cache-size size
Set imlib2 in-memory cache to size MiB. A higher cache size can significantly improve performance especially for small slide shows, however at the cost of increased memory consumption. size must be between 0 and 2048 MiB and defaults to 4.
-P, --cache-thumbnails
Enable thumbnail caching. Thumbnails are saved in $XDG_CACHE_HOME/thumbnails, which defaults to ~/.cache/thumbnails. Note that thumbnails are only cached if the configured thumbnail size does not exceed 256x256 pixels.
-K, --caption-path path
Path to directory containing image captions. This turns on caption viewing, and if captions are found in path, which is relative to the directory of each image, they are overlayed on the displayed image. E.g. with caption path "captions/", and viewing image "images/foo.jpg", the caption will be looked for in "images/captions/foo.jpg.txt".
--conversion-timeout timeout
feh can use ImageMagick to try converting unloadable files into a supported file format. As this can take a long time, it is disabled by default. Set timeout to a non-negative value to enable it. A positive value specifies after how many seconds conversion attempts should be aborted, zero causes feh to try indefinitely. Negative values restore the default by disabling conversion altogether.
--class class
Set the X11 class hint to class. Default: feh
-L, --customlist format
Don't display images, print image info according to format instead. See FORMAT SPECIFIERS.
-G, --draw-actions
Draw the defined actions and what they do at the top-left of the image.
--draw-exif
(optional feature, available in this build) display some EXIF information in the bottom left corner, similar to using --info with exiv2 / exifgrep.
-d, --draw-filename
Draw the file name at the top-left of the image.
--draw-tinted
Show overlay texts (as created by --draw-filename et al) on a semi-transparent background to improve their readability.
--edit
Enable basic editing of files. This makes rotation and mirroring (bound to "<", ">", "|", and "_" by default) change the underlying file and not just its displayed content.
-f, --filelist file
This option is similar to the playlists used by music software. If file exists, it will be read for a list of files to load, in the order they appear. The format is a list of image file names, absolute or relative to the current directory, one file name per line.
If file doesn't exist, it will be created from the internal filelist at the end of a viewing session. This is best used to store the results of complex sorts (-Spixels for example) for later viewing.

Any changes to the internal filelist (such as deleting a file or it being pruned for being unloadable) will be saved to file when feh exits. You can add files to filelists by specifying them on the command line when also specifying the list.

If file is "-", feh will read the filelist from its standard input.

-e, --font font
Set global font. Should be a truetype font, resident in the current directory or the font directory, and should be defined in the form fontname/size, like "yudit/12" (which is the default).
-C, --fontpath path
Specify path as extra directory in which to search for fonts; can be used multiple times to add multiple paths.
--force-aliasing
Disable anti-aliasing for zooming, background setting etc.
-I, --fullindex
Same as index mode, but with additional information below the thumbnails. Works just like "feh --index --index-info "%n\n%S\n%wx%h"". Enables MONTAGE MODE OPTIONS.
Note: This option needs to load all images to calculate the dimensions of the feh window, so when using it with many files it will take a while before a feh window is visible. Use --preload to get a progress bar.

-F, --fullscreen
Make the window fullscreen. Note that in this mode, large images will always be scaled down to fit the screen, and --zoom zoom only affects smaller images and never scales larger than necessary to fit the screen size. The only exception is a zoom of 100, in which case images will always be shown at 100% zoom.
When combined with --thumbnails, this option only affects images opened from the thumbnail overview. The thumbnail list itself will still be windowed.

-g, --geometry width x height | + x + y | width x height + x + y
Use a fixed window size as specified in the X-style geometry string, e.g. 640x480. An optional +x+y window offset can be specified. Combine with --scale-down to scale down larger images like in fullscreen mode. Note that this option does not enforce the window size; changing it by a tiling WM or manually is still possible. However, auto-resize remains disabled.
-Y, --hide-pointer
Hide the pointer (useful for slideshows).
-B, --image-bg style
Use style as background for transparent image parts and the like. Accepted values: default, checks, or an XColor (e.g. "black" or "#428bdd"). Note that some shells treat the hash symbol as a special character, so you may need to quote or escape it for the XColor code to work. In windowed mode, the default is checks (a checkered background so transparent image parts are easy to see). In fullscreen and background setting mode, checks is not accepted and the default is black.
-i, --index
Enable Index mode. Index mode is similar to montage mode, and accepts the same options. It creates an index print of thumbnails, printing the image name beneath each thumbnail. Index mode enables certain other options, see INDEX AND THUMBNAIL MODE OPTIONS and MONTAGE MODE OPTIONS.
--info [flag]command_line
Execute command_line and display its output in the bottom left corner of the image. Can be used to display e.g. image dimensions or EXIF information. Supports FORMAT SPECIFIERS. If flag is set to ";", the output will not be displayed by default, but has to be enabled by the toggle_info key.
--insecure
When viewing files with HTTPS, this option disables all certificate checks. It allows images on sites with self-signed or expired certificates to be opened, but is no more secure than plain HTTP.
-k, --keep-http
When viewing files using HTTP, feh normally deletes the local copies after viewing, or, if caching, on exit. This option permanently stores them on disk, either in the directory specified by --output-dir, or in the current working directory.
--keep-zoom-vp
When switching images, keep zoom and viewport settings (zoom level and X, Y offsets)
-l, --list
Don't display images. Analyze them and display an ls(1) - style listing. Useful in scripts to hunt out images of a certain size/resolution/type etc.
-U, --loadable
Don't display images. Just print out their names if imlib2 can successfully load them. Returns false if at least one image failed to load.
--max-dimension width x height
Only show images with width <= width and height <= height. If you only care about one parameter, set the other to 0 (or a negative value).
-M, --menu-font font
Use font (truetype, with size, like "yudit/12") as menu font.
--min-dimension width x height
Only show images with width >= width and height >= height. If you only care about one parameter, set the other to 0.
-m, --montage
Enable montage mode. Montage mode creates a new image consisting of a grid of thumbnails of the images in the filelist. When montage mode is selected, certain other options become available. See MONTAGE MODE OPTIONS.
-w, --multiwindow
Disable slideshow mode. With this setting, instead of opening multiple files in slideshow mode, multiple windows will be opened; one per file.
--no-conversion-cache
When loading images via HTTP, ImageMagick or dcraw, feh will only load/convert them once and re-use the cached file on subsequent slideshow passes. This option disables the cache. It is also disabled when --reload is used. Use it if you rely on frequently changing files loaded via one of these sources. Note that it will impair performance.
--no-jump-on-resort
Don't jump to the first image after resorting the filelist.
-N, --no-menus
Don't load or show any menus.
--no-screen-clip
By default, window sizes are limited to the screen size. With this option, windows will have the size of the image inside them. Note that they may become very large this way, making them unmanageable in certain window managers.
--no-xinerama
(optional feature, enabled in this build) Disable Xinerama support.
--on-last-slide hold | quit | resume
Select behaviour when trying to select the next image on the last slide (or the previous image on the first slide) in a slide show.
With hold, feh will stop advancing images in this case and continue displaying the first/last image, respectively. This is intended for linear slide shows. Behaviour is unspecified when using other navigation commands than previous and next image.

quit will cause feh to quit when trying to advance past the last image in the slide show.

resume is the default behaviour: On the last (first) image, feh will wrap around to the first (last) image.

-j, --output-dir directory
Save files to directory when using --keep-http or the save_image or save_filelist command. By default, files are saved in the current working directory.
-p, --preload
Preload images. This doesn't mean hold them in RAM, it means run through them and eliminate unloadable images first. Otherwise they will be removed as you flick through. This also analyses the images to get data for use in sorting, such as pixel size, type etc. A preload run will be automatically performed if you specify one of these sort modes.
-q, --quiet
Don't report non-fatal errors for failed loads. Verbose and quiet modes are not mutually exclusive, the first controls informational messages, the second only errors.
-z, --randomize
When viewing multiple files in a slideshow, randomize the file list before displaying. The list is re-randomized whenever the slideshow cycles (that is, transitions from last to first image).
-r, --recursive
Recursively expand any directories in the command line arguments to the content of those directories, all the way down to the bottom level.
--no-recursive
Don't recursively expand any directories. This is the default, but this option is useful to override themes containing --recursive.
-R, --reload int
Reload filelist and current image after int seconds. Useful for viewing HTTP webcams or frequently changing directories. (Note that filelist reloading is still experimental.) Set to zero to disable any kind of automatic reloading.
If an image is removed, feh will either show the next one or quit. However, if an image still exists, but can no longer be loaded, feh will continue to try loading it.

Setting this option causes inotify-based auto-reload to be disabled. Reload is not supported in montage, index, or thumbnail mode.

-n, --reverse
Reverse the sort order. Use this to invert the order of the filelist. E.g. to sort in reverse width order, use -nSwidth.
-., --scale-down
Scale images to fit window geometry (defaults to screen size when no geometry was specified). Note that the window geometry is not updated when changing images at the moment. This option is recommended for tiling window managers. This option is ignored when in fullscreen and thumbnail list mode.
In tiling environments, this also causes the image to be centered in the window.

--scroll-step count
Scroll count pixels whenever scroll_up, scroll_down, scroll_left or scroll_right is pressed. Note that this option accepts negative numbers in case you need to reverse the scroll direction. See KEYS CONFIG SYNTAX for how to reverse it permanently. Default: 20
-D, --slideshow-delay float
For slideshow mode, wait float seconds between automatically changing slides. Useful for presentations. Specify a negative number to set the delay (which will then be float * (-1)), but start feh in paused mode.
-S, --sort sort_type
Sort file list according to image parameters. Allowed sort types are: name, none, filename, dirname, mtime, width, height, pixels, size, format. For sort modes other than name, none, filename, dirname, or mtime, a preload run is necessary, causing a delay proportional to the number of images in the list.
mtime starts with the most recently modified image. width, height, pixels and size start with the smallest. Use --reverse to sort by oldest or largest first.

For name, filename, and dirname you can use --version-sort to sort numbers naturally, so that e.g. 10.jpg comes after 2.jpg.

none is the default; you can specify it explicitly to discard a sort mode that has been specified at an earlier point in the command line arguments.

-|, --start-at filename
Start the filelist at filename. If no other files or filelists were specified on the command line, feh will first load all files from the directory in which filename resides. This way, it's possible to look at a specific image and use the next / prev keys to browse through the directory. See USAGE EXAMPLES for examples. If filename is a remote URL and no files or filelists were specified, feh will show filename and not attempt to load additional files or directories.
Note: If you use relative paths in your filelist, filename should also be a relative path. If you use absolute paths, it should also be an absolute path. If feh cannot find an exact match, it will compare basenames (filenames without the directory suffix). This may lead to mismatches if several files in your filelist have the same basename.

-T, --theme theme
Load options from config file with name theme - see THEMES CONFIG SYNTAX for more info. Note that command line options always override theme options. The theme can also be set via the program name (e.g. with symlinks), so by default feh will look for a "feh" theme.
-t, --thumbnails
Same as Index mode, but the thumbnails are clickable image launchers. Note that --fullscreen and --scale-down do not affect the thumbnail window. They do, however, work for image windows launched from thumbnail mode. Also supports INDEX AND THUMBNAIL MODE OPTIONS as well as MONTAGE MODE OPTIONS.
-~, --thumb-title string
Set title for windows opened from thumbnail mode. See also FORMAT SPECIFIERS.
-^, --title title
Set window title. Applies to all windows except those opened from thumbnail mode. See FORMAT SPECIFIERS.
-u, --unloadable
Don't display images. Just print out their names if imlib2 can NOT successfully load them. Returns false if at least one image was loadable.
-V, --verbose
output useful information, progress bars, etc.
-v, --version
output version information and exit.
--version-sort
When combined with --sort name, --sort filename, or --sort dirname: use natural sorting for file and directory names. In this mode, filenames are sorted as an ordinary human would expect, e.g. "2.jpg" comes before "10.jpg". Note that this option only has an effect when a sort mode is set using --sort.
--window-id windowid
Draw to an existing X11 window by its ID windowid. This option is intended for use with software such as xcreensaver or xsecurelock, which provide a window for other applications to draw into. Unexpected things will happen if you specify a window belonging to software which does not expect feh to draw into it or attempt to use options or keybindings which affect window attributes, such as full-screen mode.
--xinerama-index monitor
(optional feature, enabled in this build) Override feh's idea of the active Xinerama monitor. May be useful in certain circumstances where the window manager places the feh window on Xinerama monitor A while feh assumes that it will be placed on monitor B.
In background setting mode: When used with any option other than --bg-tile: Only set wallpaper on monitor. All other monitors will be filled black/white. This is most useful in a Xinerama configuration with overlapping monitors. For instance, assume you have two overlapping displays (index 0 and 1), where index 0 is smaller. To center a background on the display with index 0 and fill the extra space on index 1 black/white, use "--xinerama-index 0" when setting the wallpaper.

Use xrandr --listmonitor to determine how Xinerama monitor IDs map to screens/monitors in your setup.

--zoom percent | max | fill
Zoom images by percent when in full screen mode or when window geometry is fixed. When combined with --auto-zoom, zooming will be limited to the specified percent. Specifying max is like setting --auto-zoom, using fill makes feh zoom the image like the --bg-fill mode.
--zoom-step percent
Zoom images in and out by percent (default: 25) when using the zoom keys and buttons.
MONTAGE MODE OPTIONS
These additional options can be used for index, montage and (partially) thumbnail mode.

-a, --alpha int
When drawing thumbnails onto the background, set their transparency level to int (0 - 255).
-b, --bg file | trans
Use file as background for your montage. With this option specified, the montage size will default to the size of file if no size restrictions were specified. Alternatively, if file is "trans", the background will be made transparent.
-X, --ignore-aspect
By default, the montage thumbnails will retain their aspect ratios, while fitting into thumb-width/-height. This options forces them to be the size set by --thumb-width and --thumb-height. This will prevent any empty space in the final montage.
-H, --limit-height pixels
Limit the height of the montage.
-W, --limit-width pixels
Limit the width of the montage, defaults to 800 pixels.
If both --limit-width and --limit-height are specified, the montage will be exactly width x height pixels in dimensions.

-o, --output file
Save the created montage to file.
-O, --output-only file
Just save the created montage to file without displaying it.
-s, --stretch
Normally, if an image is smaller than the specified thumbnail size, it will not be enlarged. If this option is set, the image will be scaled up to fit the thumbnail size. Aspect ratio will be maintained unless --ignore-aspect is specified.
-E, --thumb-height pixels
Set thumbnail height.
-y, --thumb-width pixels
Set thumbnail width.
INDEX AND THUMBNAIL MODE OPTIONS
In addition to MONTAGE MODE OPTIONS --alpha, --bg, --limit-height, --limit-width, --output, --output-only, --thumb-height, --thumb-width, the following options can be used.

--index-info format
Show image information based on format below thumbnails in index / thumbnail mode. See FORMAT SPECIFIERS. May contain newlines. Use "--index-info ''" to display thumbnails without any info text
Note: If you specify image-related formats (such as %w or %s), feh needs to load all images to calculate the dimensions of its own window. So when using them with many files, it will take a while before a feh window becomes visible. Use --preload to get a progress bar.

-@, --title-font font
Set font to print a title on the index, if no font is specified, no title will be printed.
-J, --thumb-redraw n
Redraw thumbnail window every n images while generating thumbnails. Redrawing takes quite long, so the default is 10. Set n = 1 to update the thumbnail window immediately. With n = 0, there will only be one redraw once all thumbnails are loaded.
BACKGROUND SETTING
In many desktop environments, feh can also be used as a background setter. Unless you pass the --no-fehbg option, it will write a script to set the current background to ~/.fehbg. So to have your background restored every time you start X, you can add "~/.fehbg &" to your X startup script (such as ~/.xinitrc). Note that the commandline written to ~/.fehbg always includes the --no-fehbg option to ensure that it is not inadvertently changed by differences in X11 screen layout or similar.

Note that feh does not support setting the wallpaper of GNOME shell desktops. In this environment, you can use "gsettings set org.gnome.desktop.background picture-uri file:///path" instead.

For --bg-center, --bg-fill, and --bg-max, you can use --geometry to specify an offset from one side of the monitor instead of centering the image. Positive values will offset from the left/top side, negative values from the bottom/right. +0 and -0 are both valid and distinct values.

Note that all options except --bg-tile support Xinerama. For instance, if you have multiple monitors connected and use e.g. --bg-center, feh will center or appropriately offset the image on each monitor. You may even specify more than one file, in that case, the first file is set on monitor 0, the second on monitor 1, and so on. Use xrandr --listmonitor to determine how Xinerama monitor IDs map to screens / monitors in your setup.

Use --no-xinerama to treat the whole X display as one monitor when setting wallpapers. You may also use --xinerama-index to use feh as a background setter for a specific monitor.

--bg-center
Center the file on the background. If it is too small, it will be surrounded by a border as specified by --image-bg.
--bg-fill
Like --bg-scale, but preserves aspect ratio by zooming the image until it fits. Either a horizontal or a vertical part of the image will be cut off
--bg-max
Like --bg-fill, but scale the image to the maximum size that fits the screen with borders on one side. The border color can be set using --image-bg.
--bg-scale
Fit the file into the background without repeating it, cutting off stuff or using borders. But the aspect ratio is not preserved either
--bg-tile
Tile (repeat) the image in case it is too small for the screen
--no-fehbg
Do not write a ~/.fehbg file

feh 命令实例:


feh 在本地或使用 URL 查看图像:

feh path/to/images

feh 递归查看图像:

feh --recursive path/to/images

feh 查看没有窗口边框的图像:

feh --borderless path/to/images

feh 设置幻灯片循环延迟:

feh --slideshow-delay seconds path/to/images

feh 设置壁纸(居中、填充、最大化、缩放或平铺):

feh --bg-center|fill|max|scale|tile path/to/image

feh 创建目录中所有图像的蒙太奇。 输出为新图像:

feh --montage --thumb-height 150 --thumb-width 150 --index-info "%nn%wx%h" --output path/to/montage_image.png

feh 命令扩展阅读:




feh 命令评论