Last active
December 21, 2015 22:19
-
-
Save jon-uw/6374730 to your computer and use it in GitHub Desktop.
linux directory mark utils to change dir fast. copy from: http://www.ccvita.com/520.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # mark dir | |
| # add this line to ~/.bashrc: | |
| # if [ -f cd_mark ]; then ./cd_mark; fi | |
| # usage: func $mark | |
| # mls: list all the mark | |
| # mcd: cd marked dir | |
| # mark: add new mark | |
| # unmark: delete mark | |
| # dir mark | |
| export MARK_DIR=$HOME/.marks | |
| export DEFAULT_MARK=tango | |
| function mcd { | |
| local m=$1 | |
| if [ "$m" = "" ]; then m=$DEFAULT_MARK; fi | |
| cd -P "$MARK_DIR/$m" 2>/dev/null || echo "No such mark: $m" | |
| } | |
| function mark { | |
| mkdir -p $MARK_DIR | |
| local m=$1 | |
| if [ "$m" = "" ]; then m=$DEFAULT_MARK; fi | |
| rm -f $MARK_DIR/$m | |
| ln -s `pwd` $MARK_DIR/$m | |
| } | |
| function unmark { | |
| local m=$1 | |
| if [ "$m" = "" ]; then m=$DEFAULT_MARK; fi | |
| rm -i "$MARK_DIR/$m" | |
| } | |
| function mls { | |
| # sed to replace multiple spaces to one | |
| ls -l "$MARK_DIR" | grep ^l | sed 's/\s\s*/ /g' | cut -d ' ' -f 9- | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment