fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
a53db7256
master
1# localization: skip(private) 2function __fish_preview_current_file --description"Open the file at the cursor in a pager" 3if __fish_edit_command_if_at_cursor 4return 0 5end 6 7set -l pager( __fish_anypager ) 8or set pager cat 9 10# commandline -t will never return an empty list. However, the token 11# could comprise multiple lines, so join them into a single string. 12set -l file( commandline -t| string collect) 13set -l prefix eval set 14 15if test -z $file 16# $backslash will parsed as regex which may need additional escaping. 17set -l backslash'\\\\' 18not status test-feature regex-easyesc&& set backslash$backslash$backslash 19set file( string replace -ra --'([ ;#^<>&|()"\'])' " $backslash \$1" ( commandline -xc)[ -1 ]) 20set prefix set 21end 22 23set -q file[ 1 ] || return 24 25# strip -option= from token if present 26set file( string replace -r --'^-[^\s=]*=' '' $file | string collect) 27 28$prefix -l files$file || return # Bail if $file does not tokenize. 29 30if set -q files[ 1 ] && test -f $files [ 1 ] 31$pager $files 32commandline -f repaint 33end 34end