Difference between revisions of "Quitting Vifm"

From Vifm Wiki
Jump to navigation Jump to search
Line 12: Line 12:
  
 
Below is the table of all possible values.  Note those marked as ''obsolete'', they might be removed
 
Below is the table of all possible values.  Note those marked as ''obsolete'', they might be removed
in future versions (for a good reason: they don't fit into usual way configuration fails are used; it's better
+
in future versions (for a good reason: they don't fit into usual way configuration files are used; it's better
 
to put commands that correspond to this items into <code>vifmrc</code>).
 
to put commands that correspond to this items into <code>vifmrc</code>).
  
 
{| class="wikitable"
 
{| class="wikitable"
|+Available elements of <code>vifminfo</code> value
+
|+Available elements of <code>'vifminfo'</code> value
 
! width="70px" | Value
 
! width="70px" | Value
 
! width="65px" | Default
 
! width="65px" | Default
Line 24: Line 24:
 
|-
 
|-
 
| tui      ||! align="center" | No  || State of the user interface (sorting, number of windows, quick view state, active view).
 
| tui      ||! align="center" | No  || State of the user interface (sorting, number of windows, quick view state, active view).
|-
 
| dhistory  ||! align="center" | No  || Directory history.
 
 
|-
 
|-
 
| state    ||! align="center" | No  || File name and dot filters and terminal multiplexers integration state.
 
| state    ||! align="center" | No  || File name and dot filters and terminal multiplexers integration state.
Line 32: Line 30:
 
|-
 
|-
 
| savedirs  ||! align="center" | No  || Save last visited directory (requires <code>dhistory</code>).
 
| savedirs  ||! align="center" | No  || Save last visited directory (requires <code>dhistory</code>).
 +
|-
 +
| dhistory  ||! align="center" | No  || Directory history.
 
|-
 
|-
 
| chistory  ||! align="center" | No  || Command line history.
 
| chistory  ||! align="center" | No  || Command line history.
Line 41: Line 41:
 
| fhistory  ||! align="center" | No  || Local filter history.
 
| fhistory  ||! align="center" | No  || Local filter history.
 
|-
 
|-
| dirstack  ||! align="center" | No  || Directory stack overwrites previous stack, unless stack of current session is empty.
+
| dirstack  ||! align="center" | No  || Directory stack (see <code>:dirs</code>, <code>:pushd</code>, <code>:popd</code>).
 
|-
 
|-
 
| registers ||! align="center" | No  || Registers content.
 
| registers ||! align="center" | No  || Registers content.
Line 54: Line 54:
 
|}
 
|}
  
'''TODO:''' merging of state.
+
These are not always trivial to combine, the next table describes how Vifm does it.
 +
 
 +
{| class="wikitable"
 +
|+How <code>vifminfo</code> data is merged
 +
! width="70px" | Value
 +
! width="700px" | Merging
 +
|-
 +
| bookmarks || Newer bookmark wins (they are timestamped).
 +
|-
 +
| tui<br>state<br>cs || Completely overwritten.
 +
|-
 +
| savedirs  || No special treatment required.
 +
|-
 +
| dhistory<br>chistory<br>shistory<br>phistory<br>fhistory || Previous history items are append to history of current instance.
 +
|-
 +
| dirstack  || Directory stack of current instance overwrites previous stack, unless stack of current session is empty.
 +
|-
 +
| registers || Registers content adds up.
 +
|-
 +
! colspan="4" align="center" font="bold" | Obsolete
 +
|-
 +
| options  || Completely overwritten.
 +
|-
 +
| filetypes || Added up.
 +
|-
 +
| commands  || Added up.
 +
|}
  
 
=== Remembering last visited directories of panes ===
 
=== Remembering last visited directories of panes ===

Revision as of 20:18, 19 September 2014

Preserving runtime state across sessions

As described in Configuration model, Vifm can store some information between invocations in vifminfo file. What exactly is stored depends on the value of 'vifminfo' option. The option enumerates values elements of run-time state that can be saved on exit and restored on startup. It works this way:

  1. On exit Vifm stores all th is listed in vifminfo.
  2. On startup Vifm loads reads vifmrc, which normally contains set vifminfo=... and restores from vifminfo only items that correspond to that values.

By default only bookmarks are stored.

Below is the table of all possible values. Note those marked as obsolete, they might be removed in future versions (for a good reason: they don't fit into usual way configuration files are used; it's better to put commands that correspond to this items into vifmrc).

Available elements of 'vifminfo' value
Value Default Description
bookmarks Yes Bookmarks, except special ones like '< and '>.
tui No State of the user interface (sorting, number of windows, quick view state, active view).
state No File name and dot filters and terminal multiplexers integration state.
cs No Primary color scheme.
savedirs No Save last visited directory (requires dhistory).
dhistory No Directory history.
chistory No Command line history.
shistory No Search history (/ and ? commands).
phistory No Prompt history.
fhistory No Local filter history.
dirstack No Directory stack (see :dirs, :pushd, :popd).
registers No Registers content.
Obsolete
options No All options that can be set with the :set command.
filetypes No Associated programs and viewers.
commands No User defined commands.

These are not always trivial to combine, the next table describes how Vifm does it.

How vifminfo data is merged
Value Merging
bookmarks Newer bookmark wins (they are timestamped).
tui
state
cs
Completely overwritten.
savedirs No special treatment required.
dhistory
chistory
shistory
phistory
fhistory
Previous history items are append to history of current instance.
dirstack Directory stack of current instance overwrites previous stack, unless stack of current session is empty.
registers Registers content adds up.
Obsolete
options Completely overwritten.
filetypes Added up.
commands Added up.

Remembering last visited directories of panes

Without previous state (e.g. by default or on first start up) and with no arguments provided Vifm starts with both directories set to the current directory of a shell.

With previous state, when 'vifminfo' contains both dhistory and savedirs, Vifm reuses top-most items of panes' directory history.

However, specifying directories on the command-line overwrites previous state.

Quitting Vifm started in file picker mode (e.g. from Vim plugin)

When -f command-line argument is given to Vifm, it starts acting like file picker. Most of commands work as usual, but instead of opening files Vifm:

  1. Stores selected files (or current file when selection is empty) in place accessible by invoker (see below).
  2. Quits.

And quiting Vifm by user causes empty list of files to be written, so that output file always contains list of selected files (which is empty in case of abortion of file picking).

Selected files are stored in main configuration directory (~/.vifm/ by default) in file named vimfiles. Each file name is stored on a new line (which means that file names containing new line characters won't work properly).

Usage example

Here is an example how this special mode can be used from a shell. Say, one wants to open file in in Vim, but it's easier to pick it with Vifm rather than writing path. It's also might be desirable to get process tree like

shell --> vim

instead of

shell --> vifm --> vim

i.e. use Vifm to pick a file and close it afterwards. It could as simple as the following one-liner in Bash:

vifm -f && [ -s ~/.vifm/vimfiles ] && xargs --arg-file ~/.vifm/vimfiles -d '\n' vim
# or
vifm -f && xargs --no-run-if-empty --arg-file ~/.vifm/vimfiles -d '\n' vim

Where [ -s "path" ] checks that file specified by the path exists and has non-zero size. xargs passes each line of the file as a separate argument to Vim.

Updating shell directory after leaving Vifm

See How to set shell working directory after leaving Vifm.