Tracking Code Productivity: Counting Lines of Code in Your Project with Terminal Commands

Are you a programmer looking to keep track of how much code you’ve typed on a project? You can easily obtain this data using a terminal and a few simple commands. Today, I’ll explain how to do it.

To get the total number of lines of code in a directory with a specific file extension on a Mac, you can use the following command:

# Get total number of code from directory with file extension on mac
find . -name '*.dart' | xargs wc -l

Replace ‘*.dart‘ with the file extension you’re interested in, such as .php or .js. The command will search for files with the specified extension and then count the lines of code in those files.

When you run this command, you’ll see an output that provides you with the total number of lines of code in the selected files.

find . -name ‘*.dart’ | xargs wc -l

This is a handy way to track and measure the code you’ve written in a project, and it can be useful for keeping tabs on your progress and productivity.

I hope this helps! If you have any more questions or need further assistance, feel free to ask.