Skip to content

Instantly share code, notes, and snippets.

@taveras
Last active November 3, 2016 23:05
Show Gist options
  • Save taveras/162860deae8f62a6d774292abe6442f4 to your computer and use it in GitHub Desktop.
Save taveras/162860deae8f62a6d774292abe6442f4 to your computer and use it in GitHub Desktop.

Revisions

  1. taveras revised this gist Nov 3, 2016. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion convert-redirects.sh
    Original file line number Diff line number Diff line change
    @@ -19,7 +19,6 @@ vim ${2}-tmp -c "%g/^#/normal dd" \
    -c "%normal A;" \
    -c "%g/\S\/\;/normal f;hx" \
    -c "%g/\/ /normal Ex" \
    -c "%normal Vgu" \
    -c "wq"

    cat ${2}-tmp | awk '!x[$0]++' > $2
  2. taveras revised this gist Sep 13, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion convert-redirects.sh
    Original file line number Diff line number Diff line change
    @@ -9,10 +9,10 @@ yes | cp $1 ${2}-tmp
    # %g/\S\/\;/normal f;hx # Removes trailling slash for second segment
    # %g/\/ /normal Ex # Removes trailing slash for first segment
    # %normal Vgu # Lower cases all characters
    # %sort u # Sort all redirects, remove duplicates
    # wq # Save file and quit

    # open vim and run the above ex commands
    # awk '!x[$0]++' # remove duplicate lines without sorting

    vim ${2}-tmp -c "%g/^#/normal dd" \
    -c "%normal Elcw " \
  3. taveras revised this gist Sep 13, 2016. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions convert-redirects.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/bin/bash

    # copy file 1 to file 2, and overwrite file 2 if necessary
    yes | cp $1 $2
    yes | cp $1 ${2}-tmp

    # %g/^#/normal dd # Deletes all comments
    # %normal Elcw # Collapses whitespace between segments
    @@ -14,11 +14,13 @@ yes | cp $1 $2

    # open vim and run the above ex commands

    vim $2 -c "%g/^#/normal dd" \
    vim ${2}-tmp -c "%g/^#/normal dd" \
    -c "%normal Elcw " \
    -c "%normal A;" \
    -c "%g/\S\/\;/normal f;hx" \
    -c "%g/\/ /normal Ex" \
    -c "%normal Vgu" \
    -c "%sort u" \
    -c "wq"

    cat ${2}-tmp | awk '!x[$0]++' > $2
    rm ${2}-tmp
  4. taveras revised this gist Sep 8, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion convert-redirects.sh
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ yes | cp $1 $2

    # open vim and run the above ex commands

    vim -T dumb -X -n --noplugin $2 -c "%g/^#/normal dd" \
    vim $2 -c "%g/^#/normal dd" \
    -c "%normal Elcw " \
    -c "%normal A;" \
    -c "%g/\S\/\;/normal f;hx" \
  5. taveras revised this gist Sep 8, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion convert-redirects.sh
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ yes | cp $1 $2

    # open vim and run the above ex commands

    vim -T dumb --noplugin $2 -c "%g/^#/normal dd" \
    vim -T dumb -X -n --noplugin $2 -c "%g/^#/normal dd" \
    -c "%normal Elcw " \
    -c "%normal A;" \
    -c "%g/\S\/\;/normal f;hx" \
  6. taveras revised this gist Sep 8, 2016. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions convert-redirects.sh
    Original file line number Diff line number Diff line change
    @@ -6,8 +6,8 @@ yes | cp $1 $2
    # %g/^#/normal dd # Deletes all comments
    # %normal Elcw # Collapses whitespace between segments
    # %normal A; # Adds semicolon to the end of each line
    # g/\S\/\;/normal f;hx # Removes trailling slash for second segment
    # g/\/ /normal Ex # Removes trailing slash for first segment
    # %g/\S\/\;/normal f;hx # Removes trailling slash for second segment
    # %g/\/ /normal Ex # Removes trailing slash for first segment
    # %normal Vgu # Lower cases all characters
    # %sort u # Sort all redirects, remove duplicates
    # wq # Save file and quit
    @@ -17,8 +17,8 @@ yes | cp $1 $2
    vim -T dumb --noplugin $2 -c "%g/^#/normal dd" \
    -c "%normal Elcw " \
    -c "%normal A;" \
    -c "g/\S\/\;/normal f;hx" \
    -c "g/\/ /normal Ex" \
    -c "%g/\S\/\;/normal f;hx" \
    -c "%g/\/ /normal Ex" \
    -c "%normal Vgu" \
    -c "%sort u" \
    -c "wq"
  7. taveras revised this gist Sep 7, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion convert-redirects.sh
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    # copy file 1 to file 2, and overwrite file 2 if necessary
    yes | cp $1 $2

    # %g/^#/normal dd # Deletes all command lines
    # %g/^#/normal dd # Deletes all comments
    # %normal Elcw # Collapses whitespace between segments
    # %normal A; # Adds semicolon to the end of each line
    # g/\S\/\;/normal f;hx # Removes trailling slash for second segment
  8. taveras revised this gist Sep 6, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion convert-redirects.sh
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ yes | cp $1 $2

    # open vim and run the above ex commands

    vim $2 -c "%g/^#/normal dd" \
    vim -T dumb --noplugin $2 -c "%g/^#/normal dd" \
    -c "%normal Elcw " \
    -c "%normal A;" \
    -c "g/\S\/\;/normal f;hx" \
  9. taveras created this gist Sep 6, 2016.
    24 changes: 24 additions & 0 deletions convert-redirects.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    #!/bin/bash

    # copy file 1 to file 2, and overwrite file 2 if necessary
    yes | cp $1 $2

    # %g/^#/normal dd # Deletes all command lines
    # %normal Elcw # Collapses whitespace between segments
    # %normal A; # Adds semicolon to the end of each line
    # g/\S\/\;/normal f;hx # Removes trailling slash for second segment
    # g/\/ /normal Ex # Removes trailing slash for first segment
    # %normal Vgu # Lower cases all characters
    # %sort u # Sort all redirects, remove duplicates
    # wq # Save file and quit

    # open vim and run the above ex commands

    vim $2 -c "%g/^#/normal dd" \
    -c "%normal Elcw " \
    -c "%normal A;" \
    -c "g/\S\/\;/normal f;hx" \
    -c "g/\/ /normal Ex" \
    -c "%normal Vgu" \
    -c "%sort u" \
    -c "wq"