zsh中别名子命令的制表符完成:别名gco ='git checkout'

时间:2013-01-13 19:10:09

标签: git zsh tab-completion

我有一个别名:alias gco='git checkout'

如何添加标签完成功能,就像我输入了git checkout

一样

对于alias g='git'我使用compdef g='git'

我一直在尝试使用compdef,但我没有取得任何成功。

3 个答案:

答案 0 :(得分:23)

禁用此选项,你也很好......

# don't expand aliases _before_ completion has finished
#   like: git comm-[tab]
# setopt complete_aliases

答案 1 :(得分:16)

您无需执行任何操作,尤其是compdef g='git',它应该无需任何配置即可运行。只有在使用函数代替别名时才需要某些东西。

答案 2 :(得分:1)

对我来说,添加compdefalias docker-compose-dev='docker-compose -f docker-compose.yml -f docker-compose-dev.yml' compdef docker-compose-dev='docker-compose' setopt complete_aliases 是必要的,以便获得以下代码段工作:

AVURLAsset* videoAsset = [[AVURLAsset alloc]initWithURL:url options:nil];

AVMutableComposition* miComposition = [AVMutableComposition composition];

AVMutableCompositionTrack *compositionVideoTrack = [miComposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
AVAssetTrack *clipVideoTrack = [videoAsset tracksWithMediaType:AVMediaTypeVideo].firstObject;
AVMutableCompositionTrack *compositionAudioTrack = [miComposition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid];
AVAssetTrack *clipAudioTrack = [videoAsset tracksWithMediaType:AVMediaTypeAudio].firstObject;
//If you need audio as well add the Asset Track for audio here

[compositionVideoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, [videoAsset duration]) ofTrack:clipVideoTrack atTime:kCMTimeZero error:nil];
[compositionAudioTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, [videoAsset duration]) ofTrack:clipAudioTrack atTime:kCMTimeZero error:nil];

[compositionVideoTrack setPreferredTransform:[[videoAsset tracksWithMediaType:AVMediaTypeVideo].firstObject preferredTransform]];



CGSize sizeOfVideo=[clipVideoTrack naturalSize];



//Image of watermark
UIImage *myImage=[UIImage imageNamed:@"_minutestory.png"];
CALayer *layerCa = [CALayer layer];
layerCa.contents = (id)myImage.CGImage;
layerCa.frame = CGRectMake((sizeOfVideo.width - 100),20 , 100, 100);
layerCa.opacity = 0.6;

CALayer *optionalLayer=[CALayer layer];

optionalLayer.frame=CGRectMake(0, 0, sizeOfVideo.width, sizeOfVideo.height);
[optionalLayer setMasksToBounds:YES];

CALayer *parentLayer=[CALayer layer];
CALayer *videoLayer=[CALayer layer];
parentLayer.frame=CGRectMake(0, 0, sizeOfVideo.width, sizeOfVideo.height);
videoLayer.frame=CGRectMake(0, 0, sizeOfVideo.width, sizeOfVideo.height);
[parentLayer addSublayer:videoLayer];
[parentLayer addSublayer:optionalLayer];
[parentLayer addSublayer:layerCa];

AVMutableVideoComposition *videoComposition=[AVMutableVideoComposition videoComposition] ;
videoComposition.frameDuration=CMTimeMake(1, 30);
videoComposition.renderSize=sizeOfVideo;
videoComposition.animationTool=[AVVideoCompositionCoreAnimationTool videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer:videoLayer inLayer:parentLayer];

AVMutableVideoCompositionInstruction *instruction = [AVMutableVideoCompositionInstruction videoCompositionInstruction];
instruction.timeRange = CMTimeRangeMake(kCMTimeZero, [miComposition duration]);
AVAssetTrack *vidTrack = [[miComposition tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
AVMutableVideoCompositionLayerInstruction* layerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:vidTrack];
instruction.layerInstructions = [NSArray arrayWithObject:layerInstruction];
videoComposition.instructions = [NSArray arrayWithObject: instruction];

[[NSFileManager defaultManager] removeItemAtPath:url error:NULL];

exporter2 =
[[AVAssetExportSession alloc] initWithAsset:mixComposition presetName:AVAssetExportPresetHighestQuality];
exporter2.videoComposition = videoComposition;

exporter2.outputURL=url;
exporter2.outputFileType = AVFileTypeMPEG4;
exporter2.shouldOptimizeForNetworkUse = YES;




exportProgressBarTimer = [NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector(updateExportDisplay) userInfo:nil repeats:YES];

[exporter2 exportAsynchronouslyWithCompletionHandler:^{
    dispatch_async(dispatch_get_main_queue(), ^{
        [self exportFinish:exporter2];


    });
}];