Skip to content

Commit

Permalink
repair cy function to allow cp without a second argument
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasLarson committed Nov 25, 2020
1 parent c93f539 commit 8a68835
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions .oh-my-zsh/custom/aliases.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,19 @@ alias pip="pip3"
# http://mywiki.wooledge.org/BashPitfalls?rev=524#Filenames_with_leading_dashes
alias cp="cp -r"

cy () {
if [ -n $2 ]; then
cp "$1" "$2"
else
cy () {(
# if within git repo, then auto-overwrite
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
interactive="-i"
fi
if [ -z "$2" ]; then
# if there is no second argument,
# then copy to the current directory
cp "$1" "$PWD"
eval cp -r "$interactive -- $1 '$PWD'"
else
eval cp -r "$interactive -- $1 $2"
fi
}
)}

garbage () {(
# if `garbage -v` or `garbage --verbose`,
Expand Down

0 comments on commit 8a68835

Please sign in to comment.