Adding better wslpath functions for easier unix/win path conversions

This commit is contained in:
Joseph Ferano 2020-04-22 21:00:00 +07:00
parent e2922ae33d
commit 1d0a2e77ef
3 changed files with 11 additions and 15 deletions

View File

@ -0,0 +1,5 @@
function cw
set -l wpath (wslpath -a -w (readlink -f "$argv[1]"))
echo Copied \"$wpath\" to clipboard
echo -n $wpath | clip.exe
end

View File

@ -0,0 +1,5 @@
function w2u
set -l wpath (wslpath "$argv[1]")
echo Copied \"$wpath\" to clipboard
echo -n "$wpath" | clip.exe
end

View File

@ -73,7 +73,7 @@ function bookmark --description "Bookmark files and directories in fish"
echo "$bname $bpath" >> $BMS_FILE echo "$bname $bpath" >> $BMS_FILE
set -l ftype ([ -d $bname ] && echo "file" || echo "directory") set -l ftype ([ -d $bname ] && echo "file" || echo "directory")
echo "Bookmark '$bname' added for $ftype $bpath" echo "Bookmark '$bname' added for $ftype $bpath"
__bookmarks_update_completions # __bookmarks_update_completions
case "remove" case "remove"
if [ (count $argv) -lt 2 ] if [ (count $argv) -lt 2 ]
@ -99,20 +99,6 @@ function bookmark --description "Bookmark files and directories in fish"
end end
function _valid_bookmark
if begin; [ (count $argv) -lt 1 ]; or not [ -n $argv[1] ]; end
return 1
else
cat $BMS_FILE | grep "^export DIR_" | sed "s/^export /set -x /" | sed "s/=/ /" | .
set -l bookmark (env | grep "^DIR_$argv[1]=" | cut -f1 -d "=" | cut -f2 -d "_" )
if begin; not [ -n "$bookmark" ]; or not [ $bookmark=$argv[1] ]; end
return 1
else
return 0
end
end
end
function __bookmarks_opener --description "Default opener" function __bookmarks_opener --description "Default opener"
set -l f "$argv[1]" set -l f "$argv[1]"
switch (file --mime-type -b "$f") switch (file --mime-type -b "$f")