通过脚本通过终端 (os x) 自动执行 Sass
我最近开始通过 Rubygems 使用 Haml/Sass,我真的很喜欢它(尽管这与我的问题没有太大关系)...
我想创建一个简单的脚本,我可以将其放入根目录中我的每个项目都将启动终端,cd 到我的 CSS 文件夹,然后运行 sass。所以本质上是一个脚本:
cd ~/path_to_here/css/
sass --watch style.scss:style.css --style compact
我不太确定解决这个问题的最佳方法,任何涉及命令行的事情总是稍微超出我的舒适区。非常感谢。
I started using Haml/Sass thru Rubygems recently, and I'm really liking it (although that doesn't have much to do with my question)...
I would like to create a simple script I can throw in the root directory of each of my projects that will launch terminal, cd to my CSS folder, and run sass. so essentially a script that:
cd ~/path_to_here/css/
sass --watch style.scss:style.css --style compact
I'm not really sure the best way to go about this, anything involving the command line is always slightly out of my comfort zone. Many thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
该脚本不会为您打开终端;但它会为您提供一条快捷方式来执行更改到项目目录并调用
compass watch
命令的重复任务。 (我强烈建议您使用 Compass,这是一个 SASS 工具编译,可以让您的生活更轻松。)在您的
~/.profile
文件中并重新启动终端:请记住将
~/Dev/ruby/
更改为您的目录路径。之后,您可以轻松地
watch myProject
。希望有帮助。
This script won't open the Terminal for you; but it will give you a shortcut to do the repetitive task of changing to the project directory and calling the
compass watch
command. (I highly recommend you to use Compass which is a SASS compilation of Tools to make your life easier.)Put this inside your
~/.profile
file and restart your terminal:Remember to change the
~/Dev/ruby/
to your directory path.After this you can easily do a
watch myProject
.Hope it helps.
考虑使用 Compass 来管理 Sass 文件的构建:它有一个脚本用于监视所有项目中的更改文件并设置所有输出参数。
您可以创建一个扩展名为
.command
的简单文本文件,这将使其成为 OSX 中的可双击脚本:Consider using Compass for managing the building of your Sass files: It has a script for watching changes in all your project files and setting up all the output parameters.
You can create a simple text file with the extension
.command
which will make it a double-clickable script in OSX:您可以编写一个启动终端的 applescript,并调用 shell 脚本。
苹果脚本
告诉应用程序“终端”
执行脚本“pushd /blash/sassstup.sh”
结束告诉
shell脚本:
cd css文件夹
/bin/sass --watch style.scss:style.css --style 紧凑
You could write a applescript that would launch terminal, and call a shell script.
Applescript
tell application "Terminal"
do script "pushd /blash/sassstup.sh"
end tell
shell script:
cd cssfolder
/bin/sass --watch style.scss:style.css --style compact