diff --git a/vmtree.sh b/vmtree.sh deleted file mode 100755 index e72d9b5..0000000 --- a/vmtree.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# Create a linkified vimwiki tree of the specified directory and subdirectories. -# It takes one argument: the base directory of the vimwiki. -# For the links to make sense, save the output of this script into a file located in this base directory. -# This script requires `tree` to be installed. - -# Print header -echo '= Table of contents =' -echo - -cd "$1" -while IFS='' read -r line; do - # Assuming there are no files with ── in their name. - filename="$(<<<"$line" sed -r 's/.*── (.*)/\1/' )" - treetrunk="$(<<<"$line" sed -r 's/(.*── ).*/\1/')" - - # Calculate depth of current file, where 1 is current directory. - depth=$(( $(<<<"$treetrunk" wc -m ) / 4 )) - - # Work out path - path_array[$depth]="$filename" - path_formatted="$(printf "/%s" "${path_array[@]:1:$depth}")" - path_formatted="${path_formatted:1}" - - # Print out line - echo -n "$treetrunk" - if $(<<<"$filename" grep -q '.wiki$'); then - echo "[[${path_formatted%.wiki}|${filename%.wiki}]]" - else - echo "$filename" - fi -done <<< "$(tree | head -n -2 | tail -n +2)" diff --git a/vwtree.sh b/vwtree.sh new file mode 100644 index 0000000..db93fd9 --- /dev/null +++ b/vwtree.sh @@ -0,0 +1,93 @@ +#!/bin/bash +# Create a linkified vimwiki file of unchecked todo items and a tree of the specified directory and +# subdirectories. For the links to make sense, save the output of this script into a file located +# in this base directory. +# This script requires `tree` and `perl` to be installed. + +# Define usage. +usage() { + cat <