Skip to content

Instantly share code, notes, and snippets.

@enisozgen
Last active July 19, 2018 06:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enisozgen/5f34095f59ce261ee327901492725e03 to your computer and use it in GitHub Desktop.
Save enisozgen/5f34095f59ce261ee327901492725e03 to your computer and use it in GitHub Desktop.
# 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