├── README.md ├── package.json └── xcv /README.md: -------------------------------------------------------------------------------- 1 | # xcv 2 | 3 | Cut, Copy and Paste files with Bash 4 | 5 | ```sh 6 | $ xcv 7 | Usage: $ xcv [options] 8 | 9 | Description: 10 | xcv wraps the cp, mv and ls built in commands, however 11 | cutting (x) and copying (c) do not require a target directory, while 12 | pasting (v) and listing (l) do not require a source directory, because all selected 13 | files are placed into, listed and pulled from: 14 | $HOME/.xcv 15 | 16 | Options: 17 | x Cut files, using the mv command options 18 | c Copy files, using the cp command options 19 | v Paste files into the current working directory 20 | l List files available for pasting, using the ls command options 21 | ``` 22 | 23 | ## Homebrew Installation 24 | 25 | ```sh 26 | $ brew install xcv 27 | ``` 28 | 29 | ## Bpkg Installation 30 | 31 | With [bpkg](https://github.com/bpkg/bpkg) do: 32 | 33 | ```sh 34 | $ bpkg install busterc/xcv 35 | ``` 36 | 37 | ## NPM Installation 38 | 39 | ```sh 40 | $ npm install xcv --global 41 | ``` 42 | 43 | ## Nifty Aliases 44 | 45 | ```sh 46 | alias fsx="xcv x" 47 | alias fsc="xcv c" 48 | alias fsv="xcv v" 49 | alias fsl="xcv l" 50 | ``` 51 | 52 | ## Walkthrough Example 53 | 54 | 1. Start with a directory of files 55 | 56 | ```sh 57 | $ find . 58 | ./a.txt 59 | ./b.txt 60 | ./c 61 | ./c/d.txt 62 | ``` 63 | 64 | 1. Then, **copy** all the files recursively 65 | 66 | ```sh 67 | $ xcv c -R . 68 | ``` 69 | 70 | 1. Then, **list** the _copied_ files 71 | 72 | ```sh 73 | $ xcv l 74 | a.txt b.txt c 75 | ``` 76 | 77 | 1. Then, change directories and **paste** in the _copied_ files 78 | 79 | ```sh 80 | $ cd ~/elsewhere 81 | $ xcv v 82 | ``` 83 | 84 | 1. Then, list the _pasted_ files in the CWD, along with any pre-existing files 85 | 86 | ```sh 87 | $ ls 88 | a.txt b.txt c x.txt 89 | ``` 90 | 91 | 1. Then, **cut** all the files in the CWD 92 | 93 | ```sh 94 | $ xcv x * 95 | ``` 96 | 97 | 1. Then, notice all the files have been _cut_ out 98 | 99 | ```sh 100 | $ ls 101 | ``` 102 | 103 | 1. Then, change directories and **paste** in the _cut_ files 104 | 105 | ```sh 106 | $ cd ~/somewhere 107 | $ xcv v 108 | ``` 109 | 110 | 1. Then, list the _pasted_ files in the CWD, along with any pre-existing files 111 | 112 | ```sh 113 | $ ls 114 | a.txt b.txt c x.txt y.txt 115 | ``` 116 | 117 | ## License 118 | 119 | ISC License (ISC) 120 | 121 | Copyright © 2015, Buster Collings 122 | 123 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 124 | 125 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 126 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "xcv", 3 | "version": "1.0.1", 4 | "description": "Cut, Copy and Paste files with Bash", 5 | "preferGlobal": true, 6 | "global": true, 7 | "install": "install -c xcv ${PREFIX:-/usr/local}/bin", 8 | "bin": { 9 | "xcv": "xcv" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/busterc/xcv" 14 | }, 15 | "keywords": [ 16 | "xcv", 17 | "cut", 18 | "copy", 19 | "paste", 20 | "move", 21 | "files", 22 | "bash", 23 | "cli", 24 | "cp", 25 | "mv", 26 | "shell" 27 | ], 28 | "author": "Buster Collings", 29 | "license": "ISC", 30 | "bugs": { 31 | "url": "https://github.com/busterc/xcv/issues" 32 | }, 33 | "homepage": "https://github.com/busterc/xcv" 34 | } 35 | -------------------------------------------------------------------------------- /xcv: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # CLI Cut, Copy, Paste files, for bash 4 | function xcv() { 5 | unset GLOBIGNORE 6 | shopt -s dotglob 7 | 8 | local options="" 9 | local xcvdir="$HOME/.xcv" 10 | mkdir -p "$xcvdir" 11 | 12 | function rmxcv() { 13 | rm -rf "$xcvdir" 14 | mkdir -p "$xcvdir" 15 | } 16 | 17 | local action=$1 18 | shift 19 | case "$action" in 20 | x) 21 | # Cut files 22 | if [[ $# -lt 1 ]]; then 23 | printf >&2 "Error Cutting: not enough options\n\n" 24 | xcv 25 | else 26 | rmxcv 27 | mv "$@" "$xcvdir" 28 | fi 29 | ;; 30 | c) 31 | # Copy files 32 | if [[ $# -lt 1 ]]; then 33 | printf >&2 "Error Copying: not enough options\n\n" 34 | xcv 35 | else 36 | rmxcv 37 | cp "$@" "$xcvdir" 38 | fi 39 | ;; 40 | v) 41 | # Paste files 42 | cp -r "$xcvdir"/* . 43 | rmxcv 44 | ;; 45 | l) 46 | # List files available for pasting 47 | ls "$@" "$xcvdir" 48 | ;; 49 | *) 50 | cat < [options] 52 | 53 | Description: 54 | xcv wraps the cp, mv and ls built in commands, however 55 | cutting (x) and copying (c) do not require a target directory, while 56 | pasting (v) and listing (l) do not require a source directory, because all selected 57 | files are placed into, listed and pulled from: 58 | $HOME/.xcv 59 | 60 | Options: 61 | x Cut files, using the mv command options 62 | c Copy files, using the cp command options 63 | v Paste files into the current working directory 64 | l List files available for pasting, using the ls command options 65 | 66 | EOF 67 | ;; 68 | esac 69 | } 70 | xcv "$@" 71 | --------------------------------------------------------------------------------