Advertisement
freddy87

UP 'n' and BACK 'n' functions for terminal

Jun 12th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. #add to .bashrc
  2.  
  3. function up( )
  4. {
  5. LIMIT=$1
  6. P="$PWD"
  7. for ((i=1; i <= LIMIT; i++))
  8. do
  9. P=$P/..
  10. done
  11. cd "$P"
  12. export MPWD=$P
  13. }
  14.  
  15. function back( )
  16. {
  17. LIMIT=$1
  18. P="$MPWD"
  19. for ((i=1; i <= LIMIT; i++))
  20. do
  21. P=${P%/..}
  22. done
  23. cd "$P"
  24. export MPWD=$P
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement