Create a custom file list using a simple bash function

Often I find myself needing to copy and paste a bunch of file names into my code. This process on a mac can be arguise so I made a simple bash function to make this process a breeze.

Paste the code found below into your .bash_profile found in the root of your computer. Open up a new terminal instance and boom you have a quick file list. The script will add the list automatically to your clipboard. No need to cat just paste. I have some improvements I am working on already, but if you have some ideas I would love to hear about them.

filelist() {

if [ $# -gt 0 ]; then shopt -s nullglob for ext in "$@"; do printf '%s\n' .$ext done | pbcopy echo "copied listing for $@ files to clipboard" else shopt -s nullglob for ext in *.; do echo "$ext" done | pbcopy echo "copied listing for all files to clipboard" fi