Skip to content

Commit

Permalink
repair cp and add cy with optional $2 (994ba9c)
Browse files Browse the repository at this point in the history
the following function works on Alpine Linux, but failed and closed
terminal windows on macOS (until I renamed it from `cp` to `cy`). I
tested with both `cp` and `cp -r -i --` and as `cp ()` and
`function cp ()`.
  cy () {
    if [[ -n $2 ]]; then
      cp -r -i -- "$1" "$2"
    else
      cp -r -i -- "$1" "$PWD"
    fi
  }
  • Loading branch information
LucasLarson committed Oct 3, 2020
1 parent 581317b commit 4129618
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions .oh-my-zsh/custom/aliases.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ alias pip="pip3"


# shell
cp () {
# https://mywiki.wooledge.org/BashPitfalls?rev=524#Filenames_with_leading_dashes
alias cp="cp -r -i --"
cy () {
if [[ -n $2 ]]; then
# prefix the arguments with `--` for safety
# https://mywiki.wooledge.org/BashPitfalls?rev=524#Filenames_with_leading_dashes
cp -r -i -- "$1" "$2"
cp "$1" "$2"
else
# if there is no second argument,
# then copy to the current directory
cp -r -i -- "$1" "$PWD"
cp "$1" "$PWD"
fi
}
alias mv="mv -v -i" # https://unix.stackexchange.com/a/30950
Expand Down

0 comments on commit 4129618

Please sign in to comment.