我想定义一个别名,连续运行以下两个命令。
gnome-screensaver
gnome-screensaver-command --lock
现在我添加了
alias lock='gnome-screensaver-command --lock'
到我的.bashrc,但由于我经常锁定我的工作站,只输入一个命令会更容易。
我想定义一个别名,连续运行以下两个命令。
gnome-screensaver
gnome-screensaver-command --lock
现在我添加了
alias lock='gnome-screensaver-command --lock'
到我的.bashrc,但由于我经常锁定我的工作站,只输入一个命令会更容易。
当前回答
function lock() {
gnome-screensaver
gnome-screensaver-command --lock
}
上面的代码在bash中翻译得很好:
bottom() {
clear
printf '\n%.0s' {1..100}
}
alias c="bottom"
All I wanted to do was clear the screen (c alias) and have the bash prompt appear at the bottom, not top of terminal window. I had solved this long ago (too long ago... forgot what I did), but now I've put the function in .bash_profile and it's off to the races! For now, I am also executing the function so that when I open a new term. window, the prompt, and only the prompt, appears at the bottom. Thanks much for the suggestion. I'm not sure if I just miss this kind of stuff or miss getting paid for it... probably both. :-)
其他回答
function lock() {
gnome-screensaver
gnome-screensaver-command --lock
}
上面的代码在bash中翻译得很好:
bottom() {
clear
printf '\n%.0s' {1..100}
}
alias c="bottom"
All I wanted to do was clear the screen (c alias) and have the bash prompt appear at the bottom, not top of terminal window. I had solved this long ago (too long ago... forgot what I did), but now I've put the function in .bash_profile and it's off to the races! For now, I am also executing the function so that when I open a new term. window, the prompt, and only the prompt, appears at the bottom. Thanks much for the suggestion. I'm not sure if I just miss this kind of stuff or miss getting paid for it... probably both. :-)
在11岁的讨论中加入我的2点意见,试试这个:
别名锁="gnome-screensaver \gnome-screensaver-command——lock"
这样不行吗?
alias whatever='gnome-screensaver ; gnome-screensaver-command --lock'
这将一个接一个地运行这两个命令:
alias lock='gnome-screensaver ; gnome-screensaver-command --lock'
Try:
alias lock='gnome-screensaver; gnome-screensaver-command --lock'
or
lock() {
gnome-screensaver
gnome-screensaver-command --lock
}
在你的。bashrc
第二个解决方案允许使用参数。