Skip to content

Instantly share code, notes, and snippets.

@pcreux
Created December 4, 2023 16:51
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 pcreux/cdabbc42687c43c61077a551b7bb57fd to your computer and use it in GitHub Desktop.
Save pcreux/cdabbc42687c43c61077a551b7bb57fd to your computer and use it in GitHub Desktop.
Generate ctags for dbt models and macros
#!/usr/bin/env ruby
# Generate ctags for dbt models and macros.
sql_files = Dir['macros/**/*.sql'] + Dir['models/**/*.sql']
mappings = sql_files
.map { |path| [File.basename(path, '.sql'), path] }
.sort
File.open('tags', 'w') do |f|
mappings.each do |mapping|
keyword, path = mapping
line_number = 1
f.puts [keyword, path, line_number].join("\t")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment