Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/home/m/Downloads/bash-5.3/bash
- # testing script for a mod to bash that allows for cd -N to
- # navigate to N directories up instead of typing ../../../ or ......
- # whatever, plus cd -N should be itterable in scripts
- # if that could possibly be useful.
- # Create test directory structure
- og=$(pwd)
- mkdir -p ~/testdir/a/b/c/d/e/f/g/h/i/j
- cd ~/testdir/a/b/c/d/e/f/g/h/i/j
- pwd
- echo "cd -2 (should go up 2 directories)"
- cd -2
- pwd
- echo "# Should show .../g/h/i"
- echo "# Test cd -1 (should work like cd -)"
- cd /tmp
- pwd
- cd /usr
- pwd
- cd -1
- echo "# Should go back to /tmp"
- pwd
- echo "# Test cd -0 (no-op)"
- cd -0
- pwd
- echo "# Should still be in /tmp"
- echo "# Test larger numbers"
- cd ~/testdir/a/b/c/d/e/f/g/h/i/j
- cd -5
- pwd
- echo "# Should show .../a/b/c/d"
- echo "# Test the original cd - still works"
- cd /tmp
- cd /usr
- cd -
- echo "# Should go back to /tmp"
- pwd
- cd -
- echo "# Should go back to /usr"
- pwd
- cd $og
- ls
Advertisement
Add Comment
Please, Sign In to add comment