Skip to content

Instantly share code, notes, and snippets.

@posva
Last active August 29, 2015 13:57
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 posva/9737267 to your computer and use it in GitHub Desktop.
Save posva/9737267 to your computer and use it in GitHub Desktop.
#! /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