Skip to content

Instantly share code, notes, and snippets.

@sideseal
Created April 14, 2025 00:12
Show Gist options
  • Select an option

  • Save sideseal/34b23013f39d43eb8445734d3536f9b8 to your computer and use it in GitHub Desktop.

Select an option

Save sideseal/34b23013f39d43eb8445734d3536f9b8 to your computer and use it in GitHub Desktop.
generate cscope & ctags
#!/bin/bash
CTAGS_FILE="tags"
CSCOPE_OUT="cscope.out"
VIMRC_FILE="$HOME/.vimrc"
CURRENT_DIR=$(pwd)
echo "Creating ctags file ..."
ctags -R .
echo "Creating cscope file ..."
cscope -Rbq
if grep -q "set tags+=" "$VIMRC_FILE"; then
echo "Updating ctags path ..."
sed -i "s|^set tags+=.*|set tags+=$CURRENT_DIR/$CTAGS_FILE|" "$VIMRC_FILE"
fi
if grep -q "cs add" "$VIMRC_FILE"; then
echo "Updating cscope path ..."
sed -i "s|^[[:space:]]*cs add .*|cs add $CURRENT_DIR/$CSCOPE_OUT|" "$VIMRC_FILE"
fi
echo "END"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment