- #!/bin/sh
-
- show_help () {
- cat<<DOC
- yank: stashes a file or directory for moving with unyank
-
- USAGE:
- yank path_to_yank
-
- EXAMPLE:
- yank random.txt
- cd ~/notes
- unyank
- DOC
- }
-
- main () {
- if [ $# -eq 0 ]; then
- echo "No path given to yank."
- echo
- show_help
- exit 65
- fi
-
- # Here we get the real path, chop the newline off the end, and stash.
- yanked_path=`realpath "$1"`
- yanked_path=${yanked_path%\\n}
- echo "$yanked_path" > ~/.yanked_file && echo "yanked '$yanked_path'; unyank to move to cwd"
- }
-
- main "$@"
|