Created
April 2, 2018 14:53
-
-
Save victorboissiere/17f02de669fdd8eb47ed678b89be8c2b to your computer and use it in GitHub Desktop.
à placer dans .oh-my-zsh/custom
This file contains 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
function vs() | |
{ | |
RESULTS=`find . -type f -not -path '*/\.*' -not -path '*/vendor/*' -not -path '*/packages/*' -ipath "*$1*"` | |
red() { echo -e "\033[00;31m$1\033[0m"; } | |
NB_FILES=$(echo $RESULTS | wc -w) | |
if [ $NB_FILES -eq "1" ]; then | |
$EDITOR $(echo "$RESULTS" | head -n1 | cut -d " " -f1) | |
elif [ $NB_FILES -eq "0" ]; then | |
>&2 red "No matching file" | |
else | |
>&2 red "Error. Found more than one file" | |
column <<< "$(printf '%s\n' $RESULTS)" | |
fi | |
} | |
#_vs() { | |
# local curcontext="$curcontext" state line expl | |
# setopt extendedglob | |
# | |
# _arguments -C \ | |
# '*:: :->open_files' | |
# | |
# case "$state" in | |
# open_files) | |
# local file | |
# | |
# file=${words[CURRENT]} | |
# compadd -M 'm:{A-Za-z}={a-zA-Z}' `find . -type f -not -path '*/\.*' -not -path '*/vendor/*' -not -path '*/packages/*' -ipath "*$file*"` | |
# ;; | |
# esac | |
#} | |
# | |
#compdef _vs vs | |
_vs() { | |
local curcontext="$curcontext" state line expl | |
setopt extendedglob | |
local file | |
file=${words[CURRENT]} | |
reply=(`find . -type f -not -path '*/\.*' -not -path '*/vendor/*' -not -path '*/packages/*' -ipath "*$file*"`) | |
} | |
compctl -K _vs vs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment