我的.bash_profile中有一个别名alias cdpy="cd python"
,我已经找到了它。但是我仍然无法在我的另一个shell脚本pygitup中使用它。
我用Google搜索了它,并得到了一些答案,例如添加shopt -s expand_aliases
。我已将其添加到pygitup中,但仍然无法正常工作。我使用错了吗?这是我的用法:
# some code
shopt -s expand_aliases
cdpy
# some code
答案 0 :(得分:1)
别名不是由外部命令继承的,因此没有别名可以扩展。您必须source
在脚本中再次定义别名的文件:
# some code
shopt -s expand_aliases
source ~/.bash_profile
cdpy
# some code
答案 1 :(得分:1)
如果从环境中使用前导“点空间”运行export var addCompetitionSubmissions = (competitionSubmissions) => {
return {
type: 'ADD_COMPETITION_SUBMISSIONS',
competitionSubmissions
};
};
export var startAddCompetitionSubmissions = () => {
return (dispatch, getState) => {
var competitionSubmissionsRef = firebaseRef.child(`competitionSubmissions`);
return competitionSubmissionsRef.once('value').then((snapshot) => {
var competitionSubmissions = snapshot.val() || {};
var parsedCompetitionSubmissions = [];
Object.keys(competitionSubmissions).forEach((competitionSubmissionId) => {
parsedCompetitionSubmissions.push({
id: competitionSubmissionId,
...competitionSubmissions[competitionSubmissionId]
});
});
dispatch(addCompetitionSubmissions(parsedCompetitionSubmissions));
});
};
};
,它将继承您外壳程序的配置,包括别名。
一个带有bash脚本的简单示例:
pygitup