-
-
Save posva/9737267 to your computer and use it in GitHub Desktop.
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
#! /bin/bash | |
# Open multiple files in vim | |
# Every hpp, cpp couple is opened in a separted tab | |
# by Eduardo San Martin Morote aka Posva | |
# http://posva.net | |
HPP="hpp" | |
CPP="cpp" | |
function _set_T() { | |
if [ "$T" ]; then | |
if [ $2 ]; then | |
T="$T | tabnew $1 | vsp $2" | |
else | |
T="$T | tabnew $1" | |
fi | |
else | |
if [ $2 ]; then | |
T="edit $1 | vsp $2" | |
else | |
T="edit $1" | |
fi | |
fi | |
} | |
DIR="." | |
if [[ "$1" && -d "$1" ]]; then | |
DIR="$1" | |
fi | |
T="" | |
for i in `find "$DIR" -name "*.${HPP}" | tr '\n' ' '`; do | |
j=`basename -s .${HPP} $i` | |
if [[ -f ${j}.${CPP} ]];then | |
_set_T $i ${j}.${CPP} | |
else | |
_set_T $i | |
fi | |
done | |
vim -c "$T" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment