-
Notifications
You must be signed in to change notification settings - Fork 7
/
xcv
executable file
·70 lines (63 loc) · 1.36 KB
/
xcv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# CLI Cut, Copy, Paste files, for bash
function xcv() {
unset GLOBIGNORE
shopt -s dotglob
local options=""
local xcvdir="$HOME/.xcv"
mkdir -p "$xcvdir"
function rmxcv() {
rm -rf "$xcvdir"
mkdir -p "$xcvdir"
}
local action=$1
shift
case "$action" in
x)
# Cut files
if [[ $# -lt 1 ]]; then
printf >&2 "Error Cutting: not enough options\n\n"
xcv
else
rmxcv
mv "$@" "$xcvdir"
fi
;;
c)
# Copy files
if [[ $# -lt 1 ]]; then
printf >&2 "Error Copying: not enough options\n\n"
xcv
else
rmxcv
cp "$@" "$xcvdir"
fi
;;
v)
# Paste files
cp -r "$xcvdir"/* .
rmxcv
;;
l)
# List files available for pasting
ls "$@" "$xcvdir"
;;
*)
cat <<EOF
Usage: $ xcv <x|c|v|l> [options]
Description:
xcv wraps the cp, mv and ls built in commands, however
cutting (x) and copying (c) do not require a target directory, while
pasting (v) and listing (l) do not require a source directory, because all selected
files are placed into, listed and pulled from:
$HOME/.xcv
Options:
x Cut files, using the mv command options
c Copy files, using the cp command options
v Paste files into the current working directory
l List files available for pasting, using the ls command options
EOF
;;
esac
}
xcv "$@"