vim ~/.config/fish/config.fish
添加complete -c ycd -x -a '( cat /opt/dir/yulove/yuinit/src/shell/mbin/bin_yucd.py |grep "\": print" | cut -d \" -f 2 )'function ycd cd (python /opt/dir/yulove/yuinit/src/shell/mbin/bin_yucd.py $argv)end
文件bin_yucd.py 内容 :(文件路径可修改,但是需要是python代码,要python执行)#!/usr/bin/env python3# -- coding: utf-8 --import sysif sys.argv[1] == "yulove": print('/opt/dir/yulove')elif sys.argv[1] == "YuCode": print('/opt/dir/YuCode')elif sys.argv[1] == "yuinit": print('/opt/dir/yulove/yuinit')elif sys.argv[1] == "YuKnowApp": print('/opt/dir/YuCode/open_app/YuKnowApp')elif sys.argv[1] == "yudata": print('/opt/dir/yulove/yudata')
有新的目录需要调整都可以按上面的格式添加最后执行看下效果输入ycd,再按tab键呼出
如图:最后脚本很简单,有意思的地方是组合起来满足自己的需求,支持输入字符后再tab键补全(图片来源网络,侵删)
0 评论