├── CHANGELOG.md ├── Dockerfile ├── LICENSE ├── README.md └── copy-pasta.plugin.zsh /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 1.0.0 2 | 3 | Initial Release 4 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine 2 | 3 | COPY ./copy-pasta.plugin.zsh /src/ 4 | 5 | WORKDIR src 6 | ENTRYPOINT bash 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 Chris Penner 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Copy Pasta 2 | 3 | 4 | 5 | * [Compatibility](#compatibility) 6 | * [Installation options:](#installation-options) 7 | * [Usage](#usage) 8 | 9 | 10 | 11 | Use at your own risk. I use it daily without trouble, and have tried my best to make it safe to use, but I'm not responsible if it causes you to delete files by accident. Cheers! 12 | 13 | 14 | [![asciicast](https://asciinema.org/a/etRqNM09mR9CgLRCVYAPQqM9d.svg)](https://asciinema.org/a/etRqNM09mR9CgLRCVYAPQqM9d) 15 | 16 | Copy Pasta is a shell utility which let's you copy and paste in your terminal as you're used to doing in your GUI. 17 | 18 | It works like this: 19 | 20 | ```sh 21 | # Copy some files 22 | copy cool-file.txt best-dir-around/ 23 | 24 | # Take your time looking around and find your destination 25 | cd ../../some-other-place 26 | cd other-cool-subdir 27 | 28 | # 'pasta' to dump what you've copied into your current working directory 29 | pasta 30 | ``` 31 | 32 | Copy Pasta doesn't pollute your clipboard, and even works across different terminals! 33 | 34 | I use it a lot when I have two tmux panes open for different projects and I just want to copy-paste some files over, I can `copy *` in one pane, switch panes, then `pasta`! 35 | 36 | ## Compatibility 37 | 38 | Copy Pasta should work on most linux and mac machines, and works with most bash-compatible shells. 39 | 40 | ## Installation options: 41 | 42 | * copy-paste `copy-pasta.plugin.zsh` onto your machine and source it from your shell's `rc` file. (E.g. `~/.bashrc` or `~/.zshrc`) 43 | * Add to your ZSH plugin manager as `ChrisPenner/copy-pasta` 44 | 45 | ## Usage 46 | 47 | ``` 48 | Usage: 49 | 50 | copy 51 | 52 | pasta [destination dir] 53 | If destination dir is omitted the current directory is used. 54 | If the destination dir does not exist it will be created. 55 | ``` 56 | -------------------------------------------------------------------------------- /copy-pasta.plugin.zsh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Use at your own risk :P 4 | 5 | # Operates in a subshell so we can exit on errors for safety 6 | copy() {( 7 | local copy_pasta_folder="/tmp/copy-pasta" 8 | # Exit on missing vars or failure for safety 9 | set -u 10 | set -e 11 | # Don't print errors on glob fail 12 | setopt +o nomatch 13 | 14 | if [ $# -lt 1 ]; then 15 | cat << EOF 16 | Usage: 17 | 18 | copy 19 | 20 | pasta [destination dir] 21 | If destination dir is omitted the current directory is used. 22 | If the destination dir does not exist it will be created. 23 | EOF 24 | return 1 25 | fi 26 | 27 | if [ -d "$copy_pasta_folder" ]; then 28 | rm -rf "${copy_pasta_folder:?}"/{*,.*} 2>/dev/null || true 29 | else 30 | mkdir "$copy_pasta_folder" 31 | fi 32 | 33 | cp -r "$@" "$copy_pasta_folder" 34 | 35 | )} 36 | 37 | # Operates in a subshell so we can exit on errors for safety 38 | pasta() {( 39 | local copy_pasta_folder="/tmp/copy-pasta" 40 | # Exit on missing vars or failure for safety 41 | set -u 42 | set -e 43 | # Don't print errors on glob fail 44 | setopt +o nomatch 45 | 46 | if [ $# -gt 1 ]; then 47 | cat >&2 << EOF 48 | Usage: 49 | 50 | copy 51 | 52 | pasta [destination dir] 53 | If destination dir is omitted the current directory is used. 54 | If the destination dir does not exist it will be created. 55 | EOF 56 | return 1 57 | elif [ $# -eq 0 ]; then 58 | local dest="." 59 | else 60 | local dest="$1" 61 | if ! [ -d "$dest" ] ; then 62 | echo "Creating $dest directory" >&2; 63 | mkdir -p "$dest" 64 | fi 65 | fi 66 | 67 | if [ ! -d "$copy_pasta_folder" ]; then 68 | cat >&2 << EOF 69 | Remember to copy before you pasta! 70 | EOF 71 | return 1 72 | fi 73 | 74 | cp -r "$copy_pasta_folder"/{*,.*} "$dest" 2> /dev/null || true 75 | )} 76 | --------------------------------------------------------------------------------