Dotfiles, utilities, and other apparatus.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
545 B

  1. #!/bin/sh
  2. show_help () {
  3. cat<<DOC
  4. yank: stashes a file or directory for moving with unyank
  5. USAGE:
  6. yank path_to_yank
  7. EXAMPLE:
  8. yank random.txt
  9. cd ~/notes
  10. unyank
  11. DOC
  12. }
  13. main () {
  14. if [ $# -eq 0 ]; then
  15. echo "No path given to yank."
  16. echo
  17. show_help
  18. exit 65
  19. fi
  20. # Here we get the real path, chop the newline off the end, and stash.
  21. yanked_path=`realpath "$1"`
  22. yanked_path=${yanked_path%\\n}
  23. echo "$yanked_path" > ~/.yanked_file && echo "yanked '$yanked_path'; unyank to move to cwd"
  24. }
  25. main "$@"