I'm trying to sort my bash functions inside my .bash_functions
file.
Here is what I type :
:g/^function /,/^}$/ s/\n/@@@
:sort /^function /
:%s/@@@/\r/g
EDIT0 : Here is some of the input :
function listVideosFromRSSPodCastPlayList {
test $# = 1 && {
local rssURL="$1"
local wget="$(which wget2 2>/dev/null || which wget)"
# echo $(youtube-dl -g "$rssURL")
echo $(curl -s "$rssURL" | egrep -o "https?:[^ <>]*(mp4|webm)" | grep -v .google.com/ | uniq)
}
}
function getVideosFromRSSPodCastPlayList {
test $# = 1 && {
local rssURL="$1"
local wget="$(which wget2 2>/dev/null || which wget)"
# $wget $(youtube-dl -g "$rssURL")
$wget $(curl -s "$rssURL" | egrep -o "https?:[^ <>]*(mp4|webm)" | grep -v .google.com/ | uniq)
}
}
function jpgRotate {
test $# = 0 && {
echo "=> Usage: $FUNCNAME angle file1 file2 file3 ..." >&2
return 1
}
local angle=$1
shift
for pic
do
extension="${pic/*./}"
newFile="${pic/.$extension/_ROTATED.$extension}"
echo "=> Losslessly rotating $pic by $angle degrees into $newFile ..." >&2
jpegtran -perfect -rotate $angle "$pic" > "$newFile"
touch -r "$pic" "$newFile"
done
}
Something is wrong with my first command because the functions' code should be converted into one liners.
However, here is a little piece of the output I get instead :
function listVideosFromRSSPodCastPlayList {@@@ test $# = 1 && {@@@ local rssURL="$1"@@@ local wget="$(which wget2 2>/dev/null || which wget)"@@@# echo $(youtube-dl -g "$rssURL")@@@ echo $(curl -s "$rssURL" | egrep -o "https?:[^ <>]*(mp4|webm)" | grep -v .google.com/ | uniq)@@@ }@@@}@@@function getVideosFromRSSPodCastPlayList {
test $# = 1 && {
local rssURL="$1"
local wget="$(which wget2 2>/dev/null || which wget)"
# $wget $(youtube-dl -g "$rssURL")
$wget $(curl -s "$rssURL" | egrep -o "https?:[^ <>]*(mp4|webm)" | grep -v .google.com/ | uniq)
}
}
function jpgRotate {@@@ test $# = 0 && {@@@ echo "=> Usage: $FUNCNAME angle file1 file2 file3 ..." >&2@@@ return 1@@@ }@@@@@@ local angle=$1@@@ shift@@@ for pic@@@ do@@@ extension="${pic/*./}"@@@ newFile="${pic/.$extension/_ROTATED.$extension}"@@@ echo "=> Losslessly rotating $pic by $angle degrees into $newFile ..." >&2@@@ jpegtran -perfect -rotate $angle "$pic" > "$newFile"@@@ touch -r "$pic" "$newFile"@@@ done@@@}@@@function locateBin {
local regExp="$1"
shift
locate "bin/.*$regExp" "$@"
}
...
Can you help me ?