2014-09-13 32 views
28

Yapmak istediğim şeyle şanssız ve coşkulu ctags kullanmaya çalıştım. Ben bu tür dizinleri .git, node_modules, test, vb. Hariç tutmak istediğim bir projede çalışmaya çalışan bir macdayım. ctags -R --exclude=[.git, node_modules, test] gibi bir şey denediğimde, karşılığında hiçbir şey alamıyorum. Gerçekten sadece ana dizinimde çalışmasına ihtiyacım var. Bunu nasıl başaracağınıza dair bir fikrin var mı?Exuberant ctags ile birden çok dizin nasıl hariç tutulur?

+0

Olası kopyası [Exuberant CTag'larda Dizinler hariç] (https://stackoverflow.com/questions/8193178/excluding-directories-in-exuberant-ctags) –

cevap

41

--exclude seçeneği, dosyaların bir listesini beklemez. ctags 'in man sayfasına göre, "Bu seçenek istenildiği kadar çok kez belirtilebilir." Yani, bu gibi:

ctags -R --exclude=.git --exclude=node_modules --exclude=test

+0

Tamam, bu kısmen işe yarar. Öyleyse başka bir soru sormak ve bunun için size cevap vermek zorunda değilim - sadece bir dizin içermenin ve dışlama yapmak zorunda olmadığın bir yol var mı? Tek ihtiyacım olan temel dizinim – pertrai1

+0

Sadece istediğiniz dizini isimlendirebilirsin, değil mi? 'Ctags -R your_dir' gibi. Yoksa ne demek istediğini anlamadım. – aalazz

+0

Evet, bunu denediğimde çekirdek dizinden hiçbir şey etiketlemiyor. :-( – pertrai1

23

R ead T o F antastic M anual hep bir sorunu çözmek için herhangi bir girişimde ilk adım olmalıdır.

$ man ctags itibaren

: Alacağınız iki birinci cümle itibaren

--exclude=[pattern] 
    Add pattern to a list of excluded files and directories. This option may 
    be specified as many times as desired. For each file name considered by 
    both the complete path (e.g. some/path/base.ext) and the base name (e.g. 
    base.ext) of the file, thus allowing patterns which match a given file 
    name irrespective of its path, or match only a specific path. If appro- 
    priate support is available from the runtime library of your C compiler, 
    then pattern may contain the usual shell wildcards (not regular expres- 
    sions) common on Unix (be sure to quote the option parameter to protect 
    the wildcards from being expanded by the shell before being passed to 
    ctags; also be aware that wildcards can match the slash character, '/'). 
    You can determine if shell wildcards are available on your platform by 
    examining the output of the --version option, which will include "+wild- 
    cards" in the compiled feature list; otherwise, pattern is matched 
    against file names using a simple textual comparison. 

    If pattern begins with the character '@', then the rest of the string is 
    interpreted as a file name from which to read exclusion patterns, one per 
    line. If pattern is empty, the list of excluded patterns is cleared. 
    Note that at program startup, the default exclude list contains "EIFGEN", 
    "SCCS", "RCS", and "CVS", which are names of directories for which it is 
    generally not desirable to descend while processing the --recurse option. 

: biraz ayrıntılı ama bu takma adlar ve eşleştirmeleri ve benzeri bunun için var olabilir

$ ctags -R --exclude=dir1 --exclude=dir2 --exclude=dir3 . 

. Alternatif olarak, ikinci paragrafın bu olsun:

$ ctags -R [email protected] . 

.ctagsignore aşağıdaki ile: kadar yazmadan o 3 dizinleri hariç ortaya eserler

dir1 
dir2 
dir3 

.

+3

Hmmm. kullanışlı bir cevap olarak kabul edildi, ama tahminimce buraya gelmek yerine RTFM'im olması gerektiği için beni kötü bir insan yapıyor! – artfulrobot

2

tek bir --exclude seçeneğiyle katlarına işlemek için küme parantezleri ile virgülle ayrılmış listesini sarabiliriz:

ctags -R --exclude={folder1,folder2,folder3} 

Bu sadece komutu veren nereye kök klasörler için çalışıyor gibi görünebilir. İç içe geçmiş klasörlerin hariç tutulması ayrı bir --exclude seçeneği gerektirir.

+0

Kabuk ataşmanı genişlemesinin şık kullanımı! –