-
-
Save victorMoneratto/9b07a9a6f4845a2914d3bf9789f8a0cd to your computer and use it in GitHub Desktop.
My ZIM custom functions
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
| mkdir -p $1 | |
| cd $1 |
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
| local TO_TRASH="$(pwd)" | |
| cd .. | |
| trash "$TO_TRASH" |
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
| local EXPRESSION="$1" | |
| if [ -z "$EXPRESSION" ]; then | |
| echo "A folder expression must be provided." >&2 | |
| return 1 | |
| fi | |
| if [ "$EXPRESSION" = "/" ]; then | |
| cd "/" | |
| return 0 | |
| fi | |
| local CURRENT_FOLDER="$(pwd)" | |
| local MATCHED_DIR="" | |
| local MATCHING=true | |
| while [ "$MATCHING" = true ]; do | |
| if [[ "$CURRENT_FOLDER" =~ "$EXPRESSION" ]]; then | |
| MATCHED_DIR="$CURRENT_FOLDER" | |
| CURRENT_FOLDER=$(dirname "$CURRENT_FOLDER") | |
| else | |
| MATCHING=false | |
| fi | |
| done | |
| if [ -n "$MATCHED_DIR" ]; then | |
| cd "$MATCHED_DIR" | |
| return 0 | |
| else | |
| echo "No Match." >&2 | |
| return 1 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment