Last active
July 31, 2023 10:36
-
-
Save ThaiDat/1f7107376b0f95507808165df965782b to your computer and use it in GitHub Desktop.
Revisions
-
ThaiDat revised this gist
Jul 31, 2023 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,6 +13,7 @@ if [ -z ${CL_TARGET_DIR+x} ]; then CL_TARGET_DIR="${1:-$(pwd)}" fi # CL_VERBOSE: Set to 1 to print log if [ -z ${CL_VERBOSE+x} ]; then CL_VERBOSE=0 fi @@ -32,6 +33,7 @@ done for cl_file in $(find "$CL_TARGET_DIR" "${CL_PRUNE_DIRS[@]}" "${CL_INCLUDE_FILES[@]}" -false); do # Verbose if [ ${CL_VERBOSE} == 1 ]; then echo "${cl_file}" fi -
ThaiDat revised this gist
Jul 31, 2023 . 1 changed file with 10 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # CL_FILE_EXTENSIONS: The script will apply on files with given extensions if [ -z ${CL_FILE_EXTENSIONS+x} ]; then CL_FILE_EXTENSIONS=(txt md json xml yaml yml sh bat) fi # CL_IGNORED_SUB_DIR: The script will ignore files in given directories @@ -13,6 +13,10 @@ if [ -z ${CL_TARGET_DIR+x} ]; then CL_TARGET_DIR="${1:-$(pwd)}" fi if [ -z ${CL_VERBOSE+x} ]; then CL_VERBOSE=0 fi # Prepare parameters for find command to ignore directories in CL_IGNORED_SUB_DIR CL_PRUNE_DIRS=() for cl_dir in "${CL_IGNORED_SUB_DIR[@]}"; do @@ -27,8 +31,11 @@ done for cl_file in $(find "$CL_TARGET_DIR" "${CL_PRUNE_DIRS[@]}" "${CL_INCLUDE_FILES[@]}" -false); do if [ ${CL_VERBOSE} == 1 ]; then echo "${cl_file}" fi # Remove trailing whitespaces and tab characters sed -i 's/[ \t]*$//' "$cl_file" @@ -37,4 +44,4 @@ for cl_file in $(find "$CL_TARGET_DIR" "${CL_PRUNE_DIRS[@]}" "${CL_INCLUDE_FILES # Remove empty lines at the end sed -i -Ez '$ s/\n+$//' "$cl_file" done -
ThaiDat revised this gist
Jul 14, 2023 . 1 changed file with 20 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # CL_FILE_EXTENSIONS: The script will apply on files with given extensions if [ -z ${CL_FILE_EXTENSIONS+x} ]; then CL_FILE_EXTENSIONS=(txt md json xml yaml yml sh bat inf) fi # CL_IGNORED_SUB_DIR: The script will ignore files in given directories @@ -10,24 +10,31 @@ fi # CL_TARGET_DIR: The directory that the scripts will work on. if [ -z ${CL_TARGET_DIR+x} ]; then CL_TARGET_DIR="${1:-$(pwd)}" fi # Prepare parameters for find command to ignore directories in CL_IGNORED_SUB_DIR CL_PRUNE_DIRS=() for cl_dir in "${CL_IGNORED_SUB_DIR[@]}"; do CL_PRUNE_DIRS+=("-type" "f" "-name" "$cl_dir" "-prune" "-o") done # Prepare parameters for find command to include given extensions in CL_FILE_EXTENSIONS CL_INCLUDE_FILES=() for cl_ext in "${CL_FILE_EXTENSIONS[@]}"; do CL_INCLUDE_FILES+=("-type" "f" "-name" "*.${cl_ext}" "-o") done for cl_file in $(find "$CL_TARGET_DIR" "${CL_PRUNE_DIRS[@]}" "${CL_INCLUDE_FILES[@]}" -false); do #echo "${cl_file}" # Remove trailing whitespaces and tab characters sed -i 's/[ \t]*$//' "$cl_file" # Remove empty lines at the beginning sed -i '/./,$!d' "$cl_file" # Remove empty lines at the end sed -i -Ez '$ s/\n+$//' "$cl_file" done -
ThaiDat created this gist
May 11, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ # CL_FILE_EXTENSIONS: The script will apply on files with given extensions if [ -z ${CL_FILE_EXTENSIONS+x} ]; then CL_FILE_EXTENSIONS=(txt md json xml yaml yml sh bat) fi # CL_IGNORED_SUB_DIR: The script will ignore files in given directories if [ -z ${CL_IGNORED_SUB_DIR+x} ]; then CL_IGNORED_SUB_DIR=(.git) fi # CL_TARGET_DIR: The directory that the scripts will work on. if [ -z ${CL_TARGET_DIR+x} ]; then CL_TARGET_DIR="${1:-$(pwd)}" fi # Prepare parameters for find command to ignore directories in CL_IGNORED_SUB_DIR CL_PRUNE_DIRS=() for cl_dir in "${CL_IGNORED_SUB_DIR[@]}"; do CL_PRUNE_DIRS+=("-name" "$cl_dir" "-prune" "-o") done for cl_file in $(find "$CL_TARGET_DIR" "${CL_PRUNE_DIRS[@]}" -type f); do if [[ "${CL_FILE_EXTENSIONS[@]}" =~ "${cl_file##*.}" ]]; then # Remove trailing whitespaces and tab characters sed -i 's/[ \t]*$//' "$cl_file" # Remove empty lines at the beginning sed -i '/./,$!d' "$cl_file" # Remove empty lines at the end sed -i -Ez '$ s/\n+$//' "$cl_file" fi done