Last active
July 19, 2018 06:16
-
-
Save enisozgen/5f34095f59ce261ee327901492725e03 to your computer and use it in GitHub Desktop.
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
# https://github.com/jhawthorn/fzy | |
# I have just discovered what is fzy. I created helpful functions that helps to edit or navigte directories at the light of speed | |
# I'm agree with you that function could be more simple :) | |
# Use the force wisely | |
alias git-root='cd $(git rev-parse --show-toplevel)' | |
# Change directory and don't show hidden directories like .git in the git repository | |
function cdinproject() { | |
EXCLUDED_PATHS=("*/\.*" "*/some/folder/*") | |
GIT_ROOT=`git rev-parse --show-toplevel` 2> /dev/null && cd $(find ${GIT_ROOT} -type d $(printf "! -path %s " ${EXCLUDED_PATHS[*]}) | fzy ) || echo "You are NOT in git project" | |
} | |
# Edit files except .pem and .pub files and ./git related files in the git repository | |
function editonproject() { | |
EXCLUDED_PATHS=("*/\.*" "*/some/folder/*") | |
EXCLUDED_EXTENSIONS=("*.pem" "*.pub" "*.gpg") | |
EDITOR="vim" | |
# EDITOR="emacsclient" | |
GIT_ROOT=`git rev-parse --show-toplevel` 2> /dev/null && ${EDITOR} $(find ${GIT_ROOT} $(printf "! -name %s " ${EXCLUDED_EXTENSIONS[*]}) $(printf "! -not -path %s " ${EXCLUDED_PATHS[*]}) -type f| fzy ) || echo "You are NOT in git project" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment