jayin
<a href="https://github.com/fritx/jayin"><img width="90" height="20" src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg"></a>
Let's say you have a gitignore-like file:
# https://github.com/fritx/dotfiles
# .gitignore
*
!.gitignore
!README.md
!prs-welcome.svg
!.bashrc
!.bash_profile
!.exports
!.aliases
!.editorconfig
You want to cp the listed files to another folder.
Do it in bash?
files=$(cat .gitignore | sed /^\*$/d | sed s/\!//)
for file in $files; do cp $file ./dotfiles/; done
# or even
cat file | sed /^\*$/d | sed s/\!// \
| while read -r file; do cp $file ./dotfiles/; done
# thanks to @congeec, http://v2ex.com/t/278831#reply3
sed /^\*$/d .gitignore | sed s/\!// | xargs -I{} cp {} ./dotfiles/
<a href="https://github.com/fritx/jayin"><img width="213" height="211" src="https://raw.gitmirror.com/we-cli/jayin/dev/wtf.jpg"></a>
WTF?
As a node.js developer, what if using just js flow/style?
cat .gitignore | js -ti 'x.trim().split(`\n`).slice(1).map(x => x.slice(1))' \
| js -e 'exec(`cp ${x} ./dotfiles/`)'
# same as
cat .gitignore | js -ti 'x.trim().split(`\n`)' \
| js 'x.slice(1)' \
| js 'x.map(x => x.slice(1))' \
| js -e -c 'cp ${x} ./dotfiles/'
# lodash is also integrated in
# https://github.com/lodash/lodash
echo '[1,2,3,4]' | js '_.filter(x, x => x % 2)' \
| js '_.reverse(x)' \
> file
# or in chain
echo '[1,2,3,4]' \
| js '_(x).filter(x => x % 2).reverse().value()' \
> file