Last active
December 29, 2016 11:43
-
-
Save StefanoBelli/60a4705284360e52efb0204d12ce8d3a to your computer and use it in GitHub Desktop.
Uncrustify your source code very fast with this fish shell function
This file contains 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 characters
function uncrustyme | |
set UCM_CFG $HOME/.uncrustyme.cfg | |
set cnt 1 | |
set total 0 | |
set rc (ls | grep "\.$UCM_EXT\$") | |
if test -f $UCM_CFG | |
printf " \033[32m==>\033[0m Found configuration file: $UCM_CFG\n" | |
else | |
printf " \033[31m==>\033[0m Cannot find configuration file: $UCM_CFG\n" | |
return 1 | |
end | |
printf " \033[34m==>\033[0m Counting objects..." | |
for i in $rc | |
set total (math $total + 1) | |
end | |
echo | |
if math "$total == 0" >/dev/null | |
printf " \033[31m==>\033[0m Cannot find any match with \".$UCM_EXT\" \n" | |
return 2 | |
end | |
for i in $rc | |
printf " \033[33m==>\033[0m [$cnt/$total] Doing work on $i\n" | |
uncrustify -c $UCM_CFG -f $i -o $i.$UCM_EXT 2>/dev/null >/dev/null ;and printf " \033[32m==>\033[0m OK!\n" ;or printf " \033[31m==>\033[0m FAILED!\n" | |
mv $i.$UCM_EXT $i | |
set cnt (math $cnt + 1) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example
You have to get your uncrustify config in $HOME/.uncrustyme.cfg
Get and customize it here: http://uncrustify.sourceforge.net/default.cfg