In this post, I will share a tip on using Vifm as the default file manager.
vifm-tab script
This script allows me to use Vifm as a single instance and when I want to open
a directory that utilizes xdg-open to launch the default file manager, it
opens in this instance’s new tab.
For this script to work you need to set the server name in your vifmrc:
let $VIFM_SERVER_NAME = v:servername
Save this script to your PATH: (I’ve added some comments inside the script so
you can adjust to your needs.)
#!/bin/shif[-n"$*"];thenif["$1"=.];then# Browsers are passing . as an argument and setting PWD for dir pathcmd="tabnew | cd \"$PWD\""elsecmd="tabnew | cd \"$*\""fielsecmd=redraw
fiif[-n"$(vifm --server-list)"];then
vifm --server-name vifm --remote-c"$cmd"elseif[-t2];then# When you call vifm-tab from terminal this will set terminal instance# to 'vifm' so you can assign window rule in your wm
xdotool getactivewindow set_window --classname vifm &
vifm -c"$cmd"else# You can adjust this to your terminal and shell:
alacritty --class vifm -esh-c"vifm -c '$cmd'; zsh">/dev/null 2>&1&fifi
Now you can open vifm with vifm-tab and pass your path as an argument to open
in this single instance.
Setting vifm-tab as a default file manager
Create vifm-tab.desktop file under ~/.local/share/applications/ with the following content.