若是shell是 zsh,则可:
使用 alias -s 定义后缀别名 (zsh)
% alias -s pl=perl
% script.pl
perl script.pl
% alias -s pdf=zathura
% vimbook.pdf
zathura vimbook.pdf
如果你用的是 Gnome, KDE, xfce, LXDE 等桌面系统(如ubuntu),则:
You can also use:
$ xdg-open foo.pdf
xdg-open works in Gnome, KDE, xfce, LXDE and perhaps on other desktops.
You can put an alias in your ~/.bash_aliases:
alias hopen='xdg-open 2>/dev/null'
ubuntu修改文件默认打开方式
方法1:例如修改pdf的打开方式,只要查看任意一pdf格式文件的属性。这样修改之后,所有pdf格式文件都改变了打开方式。
方法2:修改/usr/share/applications/defaults.list这个配置文件(也就是/etc/gnome/defaults.list这个文件,做软链接过去的,作用于整个系统的所有用户),同时也可以修改~/.local/share/applications/defaults.list,这个配置文件作用于当前用户。