I'm currently using fresh to rebuild and restart the webserver on every change of any of the source files in my project.
It works ok. However, after some time files are created at pkg directory. This causes the refresh does not happens anymore, and the reason is instead of getting the source files (.go files) to build the binary, it gets the .a files. How can I avoid this feature?
Adding information:
File: runner.conf at the same level of main.go
root: .
tmp_path: ./tmp
build_name: bin/app.bin
build_log: runner-build-errors.log
valid_ext: .go, .tpl, .tmpl, .html
build_delay: 600
colors: 1
log_color_main: cyan
log_color_build: yellow
log_color_runner: green
log_color_watcher: magenta
log_color_app:
ignore_dirs: ./pkg
Is not working at all:
13:39:48 watcher | Watching .
13:39:48 watcher | Watching bin
13:39:48 watcher | Watching pkg
13:39:48 watcher | Watching pkg/darwin_amd64
13:39:48 watcher | Watching public
13:39:48 watcher | Watching src
13:39:48 watcher | Watching src/site.org
13:39:48 watcher | Watching src/site.org/application
13:39:48 watcher | Watching src/site.org/application/controllers
13:39:48 watcher | Watching src/site.org/application/controllers/web
13:39:48 watcher | Watching src/site.org/system
FIXING
In the end, I was not able to make it work. However, I create a solution using this plugin:
https://github.com/alexnj/SublimeOnSaveBuild
That tries to build on save, and I've created this build system (called GoLang):
{
"shell_cmd": "sh /Users/acruz/go_projects/build_go.sh \"$project_path\"",
"working_dir": "${project_path}"
}
And the file build_go.sh is:
#!/bin/sh
echo "Removing PKG folder if exists"
rm -Rf pkg
echo "Building application"
go build -o bin/app.bin main.go
echo "Killing application"
killall app.bin
echo "Running application ./bin/app.bin"
echo ""
echo "Debug information:"
echo ""
./bin/app.bin
One #TODO will be defining in the project configuration the name of the binary... but for me this works ok. One of the benefits of doing this is you don't have to add the -a flag, which will make slow the compilation process, and the debug information will be showed just there in the build window...
You can change $GOPATH/src/github.com/pilu/fresh/runner/build.go#L13
cmd := exec.Command("go", "build", "-o", buildPath(), root())
to be
cmd := exec.Command("go", "build", "-a", "-o", buildPath(), root())
and then
go install -a github.com/pilu/fresh
flag -a force recompiling of .a files
Considering Pull Request 20 was about "Added ignore_dirs setting", you could use that new setting to explicitly ignore the pkg folder.
ignore_dirs path1, path2, ...
Check how that ignore_dirs path is checked:
if info.IsDir() && !isTmpDir(path) {
if _, ignore := ignorePaths[info.Name()]; (len(path) > 1 &&
strings.HasPrefix(filepath.Base(path), ".")) || ignore {
return filepath.SkipDir
Related
I'm trying to get Sublime Text 3 to run a Python script. A simple two liner
var = raw_input("Enter something: ")
print("You entered " + var)
which asks for input, waits for it, then prints it out in windows console prompt.
Seeing the number of similar questions on the site, this is a problem for quite a number of users, so I went through those and tried ... stuff. Made a copy of exec.py file, commented that one line, made a new pythonw build file, tried messing about with the build file ... nothing seems to work.
In lack of a definite solution, how do you work with input using Sublime Text?
Sublime Text on its own cannot handle input via raw_input() (Python 2) or input() (Python 3). The same is true of other languages as well - Ruby's gets, Java's Scanner class, Node's readline class, scanf in C, cin in C++, etc. One short-term solution is to get Package Control if you don't already have it, then install SublimeREPL. It allows you to transfer or run part or all of your code through the running REPL. It may require some configuration of the Main.sublime-menu files to get your preferred interpreter to run properly. Alternatively, you can use the excellent Terminus plugin - details are at the bottom.
If the code you're running doesn't play well with SublimeREPL (for instance, you're using C/C++/Java/etc. and need to compile code before it runs), or you just want to run it independently of Sublime, you'll need to make your own build system. Save the following as Packages/User/Python_cmd.sublime-build:
Windows
{
"cmd": ["start", "cmd", "/k", "c:/python38/python.exe", "$file"],
"selector": "source.python",
"shell": true,
"working_dir": "$file_dir",
"env": {"PYTHONIOENCODING": "utf-8"}
}
changing the path to your Python executable as appropriate. Then, go to Tools -> Build System and select Python_cmd, and when you hit CtrlB to build, a new cmd window will open up with your file running. The /k option returns to the command prompt, without closing the window, after your program is done running so you can examine output, tracebacks, etc.
Please note that this build system is Windows-specific, as macOS and Linux do not have cmd. Build systems for those platforms are below.
macOS
If you are running OS X/macOS, the following build system will open your program in a new instance of Terminal. Save it as Packages/User/Python_Terminal.sublime-build. In my testing on macOS 10.15, the Terminal window didn't always come to the top when activated, so if you may need to look for it behind other windows.
{
"shell_cmd": "osascript -e 'tell app \"Terminal\" to do script \"cd $file_path && python3 -u $file\"'",
"working_dir": "$file_path",
"selector": "source.python",
"env": {"PYTHONIOENCODING": "utf-8"}
}
You may need to specify the path to your Python executable if it's not on your $PATH.
Linux
And finally, here is a build system for Linux. It was tested on Ubuntu, so if you use another distribution you'll need to ensure that gnome-terminal is installed. Save it as Packages/User/Python_shell.sublime-build. Once the program has finished running, hit any key to close the window.
{
"shell_cmd": "gnome-terminal --working-directory=$file_path -- bash -c 'python3 -u \"$file\" && read -n 1 -s -r'",
"working_dir": "$file_path",
"selector": "source.python",
"env": {"PYTHONIOENCODING": "utf-8"}
}
For reference, the Packages directory is the one opened when selecting Preferences → Browse Packages…:
Linux: ~/.config/sublime-text-3/Packages or ~/.config/sublime-text/Packages
OS X: ~/Library/Application Support/Sublime Text 3/Packages or ~/Library/Application Support/Sublime Text/Packages
Windows Regular Install: C:\Users\YourUserName\AppData\Roaming\Sublime Text 3\Packages or C:\Users\YourUserName\AppData\Roaming\Sublime Text\Packages
Windows Portable Install: InstallationFolder\Sublime Text 3\Data\Packages InstallationFolder\Sublime Text\Data\Packages
The exact path depends on version and whether or not you upgraded from Sublime Text 3.
I have only tested these build systems with Python, but they should work fine for any language. When modifying, just make sure that all the single and double quotes match up – you'll get errors or unexpected behavior if they don't.
UPDATE
There is a platform-independent plugin called Terminus that, among other things, provides a drop-in replacement for the default exec build system engine. It allows you to interact with your program in the build panel below your code. Once you've installed it from Package Control, create the following build system (again, for Python):
{
"target": "terminus_exec",
"cancel": "terminus_cancel_build",
"cmd": [
"/path/to/python", "-u", "$file"
],
"working_dir": "$file_path",
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
}
You'll need to adjust the path to your Python executable, as above. Make sure you read the documentation to find out all the other ways you can make use of this great plugin.
To add on to the answer from Shritam Kumar Mund, to make a key binding for this:
{ "keys": ["alt+k", "alt+k"], "command": "repl_open", "args": {"cmd":
["python", "-u", "$file_basename"], "cwd": "$file_path", "encoding":
"utf8", "extend_env": {"PYTHONIOENCODING": "utf-8"}, "external_id":
"python", "syntax": "Packages/Python/Python.tmLanguage", "type":
"subprocess"}},
I found this by using the following in the console:
sublime.log_commands(True)
Sublime Text does not support inputting data into a program. For working with inputs you need to install a package called SublimeREPL.
Follow this:
open Sublime Text >> CTRL + P
CTRL + P will open the Package control
Click on Package Control: Install package
Wait for a sec to pop up a search bar.
Type SublimeREPL and Click it.
It'll get installed in a few secs.
Then follow the following steps to run your program;
Tools >> SublimeREPL >> Python >> Python run Current File
It'll open a new window, where you can give your input and get the output.
You can use this sublime_build file which make run on cmd when you press ctrl+B .
Just go to tool ->sublime build->new build system and paste the below given as it is;
I have personally edited this sublime build file with my experience and believe me it has some good functionalities:
color changing when program terminates or ends
interactive output and input
console window automatic opening
pause after program finishes and wait till enter
{
"cmd":["start", "cmd", "/c" ,"python $file && color b0 && pause"],
"selector": "source.python",
"working_dir": "${file_path}",
"file_regex": "(.+):(\\d+): error: ",
"shell": true
}
Thanks #MattDMo for the answer, which doesn't require installing any plugin. But after I tried the command in macOS:
"shell_cmd": "osascript -e 'tell app \"Terminal\" to do script \"cd $file_path && python3 -u $file\"'",
I find it seems to run from background every time, which is not convenient.
So I tried another method: to use a temp.sh to run. Here is the command:
"cmd": ["zsh", "-c", "echo \"python3 ${file}\" > /tmp/tmp.sh ; chmod +x /tmp/tmp.sh ; open -a Terminal /tmp/tmp.sh ; sleep 2 ;rm /tmp/tmp.sh"],
This method will pop up a new window to the front, and it should be feasible on other platforms after a small modification, but I didn't try.
here is the full content in "python_input.sublime-build":
{
"cmd": ["zsh", "-c", "echo \"python3 ${file}\" > /tmp/tmp.sh ; chmod +x /tmp/tmp.sh ; open -a Terminal /tmp/tmp.sh ; sleep 2 ;rm /tmp/tmp.sh"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.python",
"env": {"PYTHONIOENCODING": "utf-8"},
}
On Windows 10 Qt 5.15, I'm getting git commit id on Qt qmake project at qmake time with
COMMIT = '\\"$$system(git rev-parse --verify master)\\"'
DEFINES += COMMIT_VERSION=\"$${COMMIT}\"
And on main.cpp I can print that with qDebug() << COMMIT_VERSION;
Since some commits do not require a full project rebuild I'm getting old (not the latest) commit ids.
How can I get that updated on every build?
I use Ubuntu but for doing what you want I try this:
what you do is like in cmd or terminal always type this command :
git rev-parse --verify master
so for doing this I use QProcess like this :
first of all, I create one bash file and put that command there.
I always put commands in one shell script file because it's easy and just put.sh file in the start process.
test.sh
#!/bin/sh
cd /home/parisa/projectFolderName;git rev-parse --verify master
and this is code :
QProcess *myProcess = new QProcess();
myProcess->start("/home/parisa/untitled1/test.sh");
myProcess->waitForFinished(3);
QString str = myProcess->readAll();
qDebug() << "git id : " << str;
delete myProcess;
and this is the output :
In QTCreator short cut Alt + K or Alt +G will show you the git log.
I'm trying to get Sublime Text 3 to run a Python script. A simple two liner
var = raw_input("Enter something: ")
print("You entered " + var)
which asks for input, waits for it, then prints it out in windows console prompt.
Seeing the number of similar questions on the site, this is a problem for quite a number of users, so I went through those and tried ... stuff. Made a copy of exec.py file, commented that one line, made a new pythonw build file, tried messing about with the build file ... nothing seems to work.
In lack of a definite solution, how do you work with input using Sublime Text?
Sublime Text on its own cannot handle input via raw_input() (Python 2) or input() (Python 3). The same is true of other languages as well - Ruby's gets, Java's Scanner class, Node's readline class, scanf in C, cin in C++, etc. One short-term solution is to get Package Control if you don't already have it, then install SublimeREPL. It allows you to transfer or run part or all of your code through the running REPL. It may require some configuration of the Main.sublime-menu files to get your preferred interpreter to run properly. Alternatively, you can use the excellent Terminus plugin - details are at the bottom.
If the code you're running doesn't play well with SublimeREPL (for instance, you're using C/C++/Java/etc. and need to compile code before it runs), or you just want to run it independently of Sublime, you'll need to make your own build system. Save the following as Packages/User/Python_cmd.sublime-build:
Windows
{
"cmd": ["start", "cmd", "/k", "c:/python38/python.exe", "$file"],
"selector": "source.python",
"shell": true,
"working_dir": "$file_dir",
"env": {"PYTHONIOENCODING": "utf-8"}
}
changing the path to your Python executable as appropriate. Then, go to Tools -> Build System and select Python_cmd, and when you hit CtrlB to build, a new cmd window will open up with your file running. The /k option returns to the command prompt, without closing the window, after your program is done running so you can examine output, tracebacks, etc.
Please note that this build system is Windows-specific, as macOS and Linux do not have cmd. Build systems for those platforms are below.
macOS
If you are running OS X/macOS, the following build system will open your program in a new instance of Terminal. Save it as Packages/User/Python_Terminal.sublime-build. In my testing on macOS 10.15, the Terminal window didn't always come to the top when activated, so if you may need to look for it behind other windows.
{
"shell_cmd": "osascript -e 'tell app \"Terminal\" to do script \"cd $file_path && python3 -u $file\"'",
"working_dir": "$file_path",
"selector": "source.python",
"env": {"PYTHONIOENCODING": "utf-8"}
}
You may need to specify the path to your Python executable if it's not on your $PATH.
Linux
And finally, here is a build system for Linux. It was tested on Ubuntu, so if you use another distribution you'll need to ensure that gnome-terminal is installed. Save it as Packages/User/Python_shell.sublime-build. Once the program has finished running, hit any key to close the window.
{
"shell_cmd": "gnome-terminal --working-directory=$file_path -- bash -c 'python3 -u \"$file\" && read -n 1 -s -r'",
"working_dir": "$file_path",
"selector": "source.python",
"env": {"PYTHONIOENCODING": "utf-8"}
}
For reference, the Packages directory is the one opened when selecting Preferences → Browse Packages…:
Linux: ~/.config/sublime-text-3/Packages or ~/.config/sublime-text/Packages
OS X: ~/Library/Application Support/Sublime Text 3/Packages or ~/Library/Application Support/Sublime Text/Packages
Windows Regular Install: C:\Users\YourUserName\AppData\Roaming\Sublime Text 3\Packages or C:\Users\YourUserName\AppData\Roaming\Sublime Text\Packages
Windows Portable Install: InstallationFolder\Sublime Text 3\Data\Packages InstallationFolder\Sublime Text\Data\Packages
The exact path depends on version and whether or not you upgraded from Sublime Text 3.
I have only tested these build systems with Python, but they should work fine for any language. When modifying, just make sure that all the single and double quotes match up – you'll get errors or unexpected behavior if they don't.
UPDATE
There is a platform-independent plugin called Terminus that, among other things, provides a drop-in replacement for the default exec build system engine. It allows you to interact with your program in the build panel below your code. Once you've installed it from Package Control, create the following build system (again, for Python):
{
"target": "terminus_exec",
"cancel": "terminus_cancel_build",
"cmd": [
"/path/to/python", "-u", "$file"
],
"working_dir": "$file_path",
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
}
You'll need to adjust the path to your Python executable, as above. Make sure you read the documentation to find out all the other ways you can make use of this great plugin.
To add on to the answer from Shritam Kumar Mund, to make a key binding for this:
{ "keys": ["alt+k", "alt+k"], "command": "repl_open", "args": {"cmd":
["python", "-u", "$file_basename"], "cwd": "$file_path", "encoding":
"utf8", "extend_env": {"PYTHONIOENCODING": "utf-8"}, "external_id":
"python", "syntax": "Packages/Python/Python.tmLanguage", "type":
"subprocess"}},
I found this by using the following in the console:
sublime.log_commands(True)
Sublime Text does not support inputting data into a program. For working with inputs you need to install a package called SublimeREPL.
Follow this:
open Sublime Text >> CTRL + P
CTRL + P will open the Package control
Click on Package Control: Install package
Wait for a sec to pop up a search bar.
Type SublimeREPL and Click it.
It'll get installed in a few secs.
Then follow the following steps to run your program;
Tools >> SublimeREPL >> Python >> Python run Current File
It'll open a new window, where you can give your input and get the output.
You can use this sublime_build file which make run on cmd when you press ctrl+B .
Just go to tool ->sublime build->new build system and paste the below given as it is;
I have personally edited this sublime build file with my experience and believe me it has some good functionalities:
color changing when program terminates or ends
interactive output and input
console window automatic opening
pause after program finishes and wait till enter
{
"cmd":["start", "cmd", "/c" ,"python $file && color b0 && pause"],
"selector": "source.python",
"working_dir": "${file_path}",
"file_regex": "(.+):(\\d+): error: ",
"shell": true
}
Thanks #MattDMo for the answer, which doesn't require installing any plugin. But after I tried the command in macOS:
"shell_cmd": "osascript -e 'tell app \"Terminal\" to do script \"cd $file_path && python3 -u $file\"'",
I find it seems to run from background every time, which is not convenient.
So I tried another method: to use a temp.sh to run. Here is the command:
"cmd": ["zsh", "-c", "echo \"python3 ${file}\" > /tmp/tmp.sh ; chmod +x /tmp/tmp.sh ; open -a Terminal /tmp/tmp.sh ; sleep 2 ;rm /tmp/tmp.sh"],
This method will pop up a new window to the front, and it should be feasible on other platforms after a small modification, but I didn't try.
here is the full content in "python_input.sublime-build":
{
"cmd": ["zsh", "-c", "echo \"python3 ${file}\" > /tmp/tmp.sh ; chmod +x /tmp/tmp.sh ; open -a Terminal /tmp/tmp.sh ; sleep 2 ;rm /tmp/tmp.sh"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.python",
"env": {"PYTHONIOENCODING": "utf-8"},
}
I'm trying to get Sublime Text 3 to run a Python script. A simple two liner
var = raw_input("Enter something: ")
print("You entered " + var)
which asks for input, waits for it, then prints it out in windows console prompt.
Seeing the number of similar questions on the site, this is a problem for quite a number of users, so I went through those and tried ... stuff. Made a copy of exec.py file, commented that one line, made a new pythonw build file, tried messing about with the build file ... nothing seems to work.
In lack of a definite solution, how do you work with input using Sublime Text?
Sublime Text on its own cannot handle input via raw_input() (Python 2) or input() (Python 3). The same is true of other languages as well - Ruby's gets, Java's Scanner class, Node's readline class, scanf in C, cin in C++, etc. One short-term solution is to get Package Control if you don't already have it, then install SublimeREPL. It allows you to transfer or run part or all of your code through the running REPL. It may require some configuration of the Main.sublime-menu files to get your preferred interpreter to run properly. Alternatively, you can use the excellent Terminus plugin - details are at the bottom.
If the code you're running doesn't play well with SublimeREPL (for instance, you're using C/C++/Java/etc. and need to compile code before it runs), or you just want to run it independently of Sublime, you'll need to make your own build system. Save the following as Packages/User/Python_cmd.sublime-build:
Windows
{
"cmd": ["start", "cmd", "/k", "c:/python38/python.exe", "$file"],
"selector": "source.python",
"shell": true,
"working_dir": "$file_dir",
"env": {"PYTHONIOENCODING": "utf-8"}
}
changing the path to your Python executable as appropriate. Then, go to Tools -> Build System and select Python_cmd, and when you hit CtrlB to build, a new cmd window will open up with your file running. The /k option returns to the command prompt, without closing the window, after your program is done running so you can examine output, tracebacks, etc.
Please note that this build system is Windows-specific, as macOS and Linux do not have cmd. Build systems for those platforms are below.
macOS
If you are running OS X/macOS, the following build system will open your program in a new instance of Terminal. Save it as Packages/User/Python_Terminal.sublime-build. In my testing on macOS 10.15, the Terminal window didn't always come to the top when activated, so if you may need to look for it behind other windows.
{
"shell_cmd": "osascript -e 'tell app \"Terminal\" to do script \"cd $file_path && python3 -u $file\"'",
"working_dir": "$file_path",
"selector": "source.python",
"env": {"PYTHONIOENCODING": "utf-8"}
}
You may need to specify the path to your Python executable if it's not on your $PATH.
Linux
And finally, here is a build system for Linux. It was tested on Ubuntu, so if you use another distribution you'll need to ensure that gnome-terminal is installed. Save it as Packages/User/Python_shell.sublime-build. Once the program has finished running, hit any key to close the window.
{
"shell_cmd": "gnome-terminal --working-directory=$file_path -- bash -c 'python3 -u \"$file\" && read -n 1 -s -r'",
"working_dir": "$file_path",
"selector": "source.python",
"env": {"PYTHONIOENCODING": "utf-8"}
}
For reference, the Packages directory is the one opened when selecting Preferences → Browse Packages…:
Linux: ~/.config/sublime-text-3/Packages or ~/.config/sublime-text/Packages
OS X: ~/Library/Application Support/Sublime Text 3/Packages or ~/Library/Application Support/Sublime Text/Packages
Windows Regular Install: C:\Users\YourUserName\AppData\Roaming\Sublime Text 3\Packages or C:\Users\YourUserName\AppData\Roaming\Sublime Text\Packages
Windows Portable Install: InstallationFolder\Sublime Text 3\Data\Packages InstallationFolder\Sublime Text\Data\Packages
The exact path depends on version and whether or not you upgraded from Sublime Text 3.
I have only tested these build systems with Python, but they should work fine for any language. When modifying, just make sure that all the single and double quotes match up – you'll get errors or unexpected behavior if they don't.
UPDATE
There is a platform-independent plugin called Terminus that, among other things, provides a drop-in replacement for the default exec build system engine. It allows you to interact with your program in the build panel below your code. Once you've installed it from Package Control, create the following build system (again, for Python):
{
"target": "terminus_exec",
"cancel": "terminus_cancel_build",
"cmd": [
"/path/to/python", "-u", "$file"
],
"working_dir": "$file_path",
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
}
You'll need to adjust the path to your Python executable, as above. Make sure you read the documentation to find out all the other ways you can make use of this great plugin.
To add on to the answer from Shritam Kumar Mund, to make a key binding for this:
{ "keys": ["alt+k", "alt+k"], "command": "repl_open", "args": {"cmd":
["python", "-u", "$file_basename"], "cwd": "$file_path", "encoding":
"utf8", "extend_env": {"PYTHONIOENCODING": "utf-8"}, "external_id":
"python", "syntax": "Packages/Python/Python.tmLanguage", "type":
"subprocess"}},
I found this by using the following in the console:
sublime.log_commands(True)
Sublime Text does not support inputting data into a program. For working with inputs you need to install a package called SublimeREPL.
Follow this:
open Sublime Text >> CTRL + P
CTRL + P will open the Package control
Click on Package Control: Install package
Wait for a sec to pop up a search bar.
Type SublimeREPL and Click it.
It'll get installed in a few secs.
Then follow the following steps to run your program;
Tools >> SublimeREPL >> Python >> Python run Current File
It'll open a new window, where you can give your input and get the output.
You can use this sublime_build file which make run on cmd when you press ctrl+B .
Just go to tool ->sublime build->new build system and paste the below given as it is;
I have personally edited this sublime build file with my experience and believe me it has some good functionalities:
color changing when program terminates or ends
interactive output and input
console window automatic opening
pause after program finishes and wait till enter
{
"cmd":["start", "cmd", "/c" ,"python $file && color b0 && pause"],
"selector": "source.python",
"working_dir": "${file_path}",
"file_regex": "(.+):(\\d+): error: ",
"shell": true
}
Thanks #MattDMo for the answer, which doesn't require installing any plugin. But after I tried the command in macOS:
"shell_cmd": "osascript -e 'tell app \"Terminal\" to do script \"cd $file_path && python3 -u $file\"'",
I find it seems to run from background every time, which is not convenient.
So I tried another method: to use a temp.sh to run. Here is the command:
"cmd": ["zsh", "-c", "echo \"python3 ${file}\" > /tmp/tmp.sh ; chmod +x /tmp/tmp.sh ; open -a Terminal /tmp/tmp.sh ; sleep 2 ;rm /tmp/tmp.sh"],
This method will pop up a new window to the front, and it should be feasible on other platforms after a small modification, but I didn't try.
here is the full content in "python_input.sublime-build":
{
"cmd": ["zsh", "-c", "echo \"python3 ${file}\" > /tmp/tmp.sh ; chmod +x /tmp/tmp.sh ; open -a Terminal /tmp/tmp.sh ; sleep 2 ;rm /tmp/tmp.sh"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.python",
"env": {"PYTHONIOENCODING": "utf-8"},
}
I've created a simple service using automator, that takes a *.tiff, creates a *.jpg out of it and than deletes the original.
However, I run this on a *.tiff file, it keeps on running, meaning it keeps on converting the (then jpg) file over and over again. That is, I believe it does, since the file disappears and reappears about 2 times a minute and the timestamp changes. How do I tell it to run the service (i.e. the shell commands) just once?
The Service in Automator is just this one action of type "run Shell-Script". The Shell script is
newName=${#%.tiff}.jpg
echo "$newName"
sips -s format jpeg "$#" --out "${newName}"
rm "$#"
Thanks!
(Would have posted a picture of the Automator window, but was not allowed to)
This behavior seems to be a folder actions.
if you created a folder action :
1- You must filter the TIFF files for that folder action doesn't process the created JPEG file.
2- You must use a loop, if you drop one or more files in that folder.
3- Use "&&" to delete the TIFF file only when the sips command finishes successfully.
Here's the script:
for f in "$#";do
if [[ "$f" = *.tiff ]]; then
sips -s format jpeg "$f" --out "${f%.tiff}.jpg" && rm "$f"
fi
done