File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,31 @@ function maxcpu100 -d "literally max out all your cores."
179179 for i in (seq (nproc)); yes > /dev/null & end
180180end
181181
182+ function copy_modification_date -d " Copies the modification time (and access time) of one file to another"
183+ # Check if the correct number of arguments are provided
184+ if test (count $argv ) -ne 2
185+ echo " Usage: cpmodtime <source_file> <target_file>" >&2
186+ echo " Copies the modification time (and access time) from <source_file> to <target_file>." >&2
187+ return 1
188+ end
189+
190+ set -l source_file $argv [1]
191+ set -l target_file $argv [2]
192+
193+ # Check if the source file exists and is a regular file
194+ if not test -f " $source_file "
195+ echo " Error: Source file '$source_file ' does not exist or is not a regular file." >&2
196+ return 1
197+ end
198+
199+ # Use 'touch -r' to copy the timestamps (both modification and access)
200+ touch -r " $source_file " " $target_file "
201+ end
202+
203+
204+
205+
206+
182207# requires my excellent `npm install -g statikk`
183208function server -d ' Start a HTTP server in the current dir, optionally specifying the port'
184209 # arg can either be port number or extra args to statikk
You can’t perform that action at this time.
0 commit comments