# usage: skip N [files...] # skip n elements from input function skip set -l n $argv[1] set argv $argv[2..-1] # tail -n +N+1 means start printing from line n+1 tail -n + (math $n + 1) $argv end # usage: get N # get specified line number from stdin function get sed -n "$argv[1]p" end # usage: data_url FILE # turn file into a data url function data_url if test (count $argv) -eq 1 set file_path $argv[1] if test -f $file_path # base64 output (base64 reads from stdin in fish with <) set base64_data (base64 < $file_path) set mime_type (file --mime-type -b $file_path) echo "data:$mime_type;base64,$base64_data" else echo "File not found: $file_path" end else echo "\$ data_url [FILE_PATH]" echo "Turn data into a data URL" end end