Files
fish-config/functions/copy.fish
T
rootiest 02c46ebea7 docs(functions): merge manual-only examples and notes into headers
Folds the examples Section 5 carried but the headers did not into each
function's `# EXAMPLE`, and moves the three lines that only looked like
examples -- the two typo-abbreviation notes and rm's /usr/bin/rm fallback --
into `# NOTES`, the label already in use.

Also corrects gi's synopsis, which omitted -l, and documents yt-dlp's
--no-embed-thumbnail in `# ARGUMENTS`.
2026-07-26 03:47:25 -04:00

32 lines
841 B
Fish

# Copyright (C) 2026 Rootiest
# SPDX-License-Identifier: AGPL-3.0-or-later
# CATEGORY
# 01-file-and-directory
#
# SYNOPSIS
# copy <source> <dest>
#
# DESCRIPTION
# Wrapper for cp that strips trailing slashes from source directories,
# preventing unwanted nested copies when the destination already exists.
#
# ARGUMENTS
# source Source file or directory
# dest Destination path
#
# EXAMPLE
# copy ./mydir/ ~/backup
# copy ./mydir/ ~/backup # copies mydir INTO backup, not backup/mydir/
function copy
set count (count $argv)
if test "$count" = 2; and test -d "$argv[1]"
# 'string trim' is built straight into Fish and works everywhere
set from (string trim --right --chars=/ $argv[1])
set to (echo $argv[2])
command cp -r $from $to
else
command cp $argv
end
end