fish: functions/dotg: Do not add dot to output file name

If a file name was foo.dot the current implementation generated a
foo.dot.svg. Fix it to just output a foo.svg.

Also fix a bug, where we were not considering the provided dotpath.
This commit is contained in:
Sanchayan Maity 2023-03-03 11:28:28 +05:30
parent ebac7a3beb
commit e6c64c61ae
Signed by: sanchayanmaity
GPG Key ID: 6F6A0609C12038F3
1 changed files with 4 additions and 3 deletions

View File

@ -5,10 +5,11 @@ function dotg --description 'Generate gstreamer dot graph for selected file'
set dotpath "$GST_DEBUG_DUMP_DOT_DIR"
end
find /tmp/gst-dot -maxdepth 1 -regextype posix-extended -regex ".*\.(dot)" -printf '%T@ %p\n' | sort -k 1 -n -r | fzf --bind "ctrl-d:half-page-down,ctrl-u:half-page-up" | awk -F' ' '{print $2}' | read -l result
find $dotpath -maxdepth 1 -regextype posix-extended -regex ".*\.(dot)" -printf '%T@ %p\n' | sort -k 1 -n -r | fzf --bind "ctrl-d:half-page-down,ctrl-u:half-page-up" | awk -F' ' '{print $2}' | read -l result
if test -n "$result"
dot -Tsvg "$result" -O
mv "$result".svg ~/Pictures/gstreamer
set filename (echo $result | sed 's/\.[^.]*$//')
dot -Tsvg "$result" -o "$filename".svg
mv "$filename".svg ~/Pictures/gstreamer
end
end