I'm effectively asking this question:
Unison: sync only in one direction
but I'd like to apply the accepted answer to a profile script. Can I do that?
unison /src/dir /dest/dir -force /src/dir -nodeletion /dest/dir
Cheers!
Yes, of course you can write that command line to the profile script.
Locate the corresponding .prf unison preferences/profile file (usually under $HOME/.unison, but please double check, this may vary depending on your OS or Unison installation)
Edit the .prf file and add the following:
# Unison preferences
label = Sync in only one direction (mirror)
root = /src/dir
root = /dest/dir
force = /src/dir # force changes from this replica to the other
nodeletion = /dest/dir # prevent file deletions on this replica
noupdate = /src/dir # prevent file updates on this replica
You can also replace step #1 above by creating a new preferences profile using the Profile Editor in the GUI, or your text editor of choice. Please remember the name and location of this file (e.g. $HOME/.unison/sync-one-direction.prf). Then you can call unison from the command line like this:
unison $HOME/.unison/sync-one-direction.prf
or
unison -i
The latter will start an interactive profile selection.
HTH
Related
I will run the script on the Blender command line. All I want to do is run the same script for several files. I have completed the steps to run a background file (.blend) and run a script in Blender, but since I have just loaded one file, I can not run the script on another file.
I looked up the Blender manual, but I could not find the command to import the file.
I proceeded to creating a .blend file and running the script.
blender -b background.blend -P pythonfile.py
In addition, if possible, I would appreciate it if you could tell me how to script the camera and track axes to track to contraint (Ctrl + T -> Track to constraint).
really thank you for reading my ask.
Blender can only have one blend file open at a time, any open scripts are cleared out when a new file is opened. What you want is a loop that starts blender for each blend file using the same script file.
On *nix systems you can use a simple shell script
#!/bin/sh
for BF in $(ls *.blend)
do
blender -b ${BF} -P pythonfile.py
done
A more cross platform solution is to use python -
from glob import glob
from subprocess import call
for blendFile in glob('*.blend'):
call([ 'blender',
'-b', blendFile,
'--python', 'pythonfile.py' ])
To add a Track-to constraint to Camera pointing it at Cube -
camera = bpy.data.objects['Camera']
c = camera.constraints.new('TRACK_TO')
c.target = bpy.data.objects['Cube']
c.track_axis = 'TRACK_NEGATIVE_Z'
c.up_axis = 'UP_Y'
This is taken from my answer here which also animates the camera going around the object.
bpy.context.view_layer.objects.active = CameraObject
bpy.ops.object.constraint_add(type='TRACK_TO')
CameraObject.constraints["Track To"].target = bpy.data.objects['ObjectToTrack']
So, i've found this page here, showing how to use intellij's idea merge and diff from command line, and i'm trying to set it as a default for hg.
However, i still have some problems when merging branches (many files):
If hg merge is called while there's no idea instance running, it starts a new instance, show the diff, wait for my response (click on apply / abort). After that, it proceeds to the next file, and do the same. File by file. Works pretty well, but is also veery slow (since it needs to start a new instance every time). Also, as said, there must be no idea instance running, to do that.
If hg merge is called while an idea instance is running, it shows the first diff window, but at the same time starts to merge all other files... This end up in a lot of pop-ups of "file not found" on idea, pointing to tmp files (of .other and .original).
Does anybody know how to do that in a usable way? hg merge using idea merge as default ?
Here's my .hgrc file: [ui]
merge=idea
[merge-tools]
idea =
idea.gui = True
idea.args = merge $local $base $other $output
idea.priority = 1000
idea.premerge = False
Sorry for the bad english, and thanks to all in advance
Hi here are the settings I used successfully.
[ui]
merge=idea
[merge-tools]
idea.args = merge $local $other $base $output
Also ensure that idea is on the path.
My references are the mercurial MergeToolConfiguration and Merging files using IntelliJ IDEA as a command line tool.
Idea does not wait, but gives return too early. A good way to solve this problem is to get mercurial to prompt you.
By setting this configuration in the .hgrc
idea.check = prompt
Mercurial will ask for confirmation on each file. You must finish the merge in Idea before clicking "Yes" on the confirmation box.
By default, IntelliJ Idea will insert (something like) the following as the header of a new source file:
/**
* Created by JohnDoe on 2016-04-27.
*/
The corresponding template is:
/**
* Created by ${USER} on ${DATE}.
*/
Is it possible to update this template so that it inserts the last date of modification when the file is changed? For example:
/**
* Created by JohnDoe on 2016-03-27.
* Last modified by JaneDoe on 2016-04-27
*/
It is not supported out of the box. I suggest you do not include information about author and last edit/create time in file at all.
The reason is that your version control system (Git, SVN) contains the same information automatically. So the manual labelling is just duplicate of already existing info, but is only more error prone and needs to be manually updated.
Here's a working solution similar to what I'm using. Tested on mac os.
Create a bash script which will replace first occurrence of Last modified by JaneDoe on $DATE only if the exact value is not contained in the file:
#!/bin/bash
FILE=src/java/test/Test.java
DATE=`date '+%Y-%m-%d'`
PREFIX="Last modified by JaneDoe on "
STRING="$PREFIX.*$"
SUBSTITUTE="$PREFIX$DATE"
if ! grep -q "$SUBSTITUTE" "$FILE"; then
sed -i '' "1,/$(echo "$STRING")/ s/$(echo "$STRING")/$(echo "$SUBSTITUTE")/" $FILE
fi
Install File Watchers plugin.
Create a file watcher with appropriate scope (it may be this single file or any other scope, so that any change in project's source code will update modified date or version etc.) and put a path to your bash script into Program field.
Now every time the file changes the date will update. If you want to update date for each file separately, an argument $FilePath$ should be passed to the script.
This might have been just a comment to #oleg-mikhailov excellent idea, but the code snippet won't fit. Basically, I just tweaked his solution.
I needed a slightly different syntax but that's not the issue. The issue was that when the script ran automatically upon file save using the File Watchers plugin, if ran on a file which doesn't include PREFIX it would run over and over for ever.
I presume the that the issue is with the plugin itself, as it didn't happen when run from the shell, but I'm not sure why it happened.
Anyway, I ended up running the following script (as I said only a slight change with respect to the original). The new script also raises an error if the the prefix doesn't exist. For me this is a feature as Pycharm prompts me with the error, and I can fix the file.
Tested with PyCharm 2021.2.3 on macOS 11.6.
#!/bin/bash
FILE=$1
DATE=`date '+%Y-%m-%d'`
PREFIX="last_modified_date: "
STRING="$PREFIX.*$"
SUBSTITUTE="$PREFIX$DATE"
if ! grep -q "$SUBSTITUTE" "$FILE"; then
if grep -q "$PREFIX" "$FILE"; then
sed -i '' "s/$(echo "$STRING")/$(echo "$SUBSTITUTE")/" $FILE
else
echo "Error!"
echo "'$PREFIX' doesn't appear in $FILE"
exit 1
fi
fi
PHPStorm has not a "hook" for launching task after detect a change in file (just for uploading in server yes). Code templating is based on the creation of file not change.
The behaviour you want (automatic change file after manual change file) can be useful for lot of things but it's circular headhache for editor. Because if you change a file it must change file (and if a file is change ? it change file ?).
However, You can, perhaps, "enable Live Templates" when you launch a "reformat code" which able to rewrite your begin template code that way rewrite date modification.
Other solution is that use a tools with as grunt but I don't know if manage php file.
This is a hypothetical question because I'd like to know if it's even possible before I delve in to scripting it, but is it theoretically possible to have the output of a script/process (in particular one run via cron for instance) spit out in to terminal on the next ssh login?
Some pseudocode that I hope illustrates my point:
#!/bin/bash
# Download latest example of a database (updated automatically and periodically)
wget -mirror "http://somedatabase/database_latest
# Run a command that generates an output for a set of files queried against the latest database)
for file in /some/dir/*;
do
command -output $file.txt -database database_latest
done
# Now for the bit I'm more interested in.
# If the database has been updated, the 'output.txt'
# for each file will be different.
# So, using diff...:
if [ diff $file.txt $file_old.txt == 1 ] # where file_old.txt is
# the output of the command the
# last time it ran for that file.
then
mv $file_old ./archive/ # Keep the old file but stash it in a separate dir
else
break
fi
# Make some report file from all of the outputs
cat *.txt > report.txt
So my question being, is it possible to have the script 'inform me' next time I log in to our server, if any differences were found for each file? There are a lot of files, and the 'report.txt' would become large quickly, so I only want to check it if differences are found.
How about this:
create three directories: new, cur, old
your weekly cronjob writes data to new. This script should delete everything from new before writing new data. Or else you won't be able to notice that a file is missing
cur contains the last version of the data that you looked at or consideret
old contains the previous version of the data
Each time you log on, run:
#!/bin/bash
# clear the archive
rm old/*
# move all the old files to the archive
cp cur/* old
# move all the new files to the location of the old
cp new/* cur
# show which files have changed between
diff -q cur old | tee report.txt
The diff-command will print which files are new, which are missing and which are changed. Output from diff will also be in report.txt. The cur-directory will contain all files from the last run and you can look closer at these in an editor, or you can compare them to the previous version in old. Note that if a file is missing in new, it won't be deleted from cur. The next time you log on, you will lose the contents of the old-directory. If you want to keep a history of all previous results, this should be managed by the weekly cronjob, not the login-script (you want to store a separate version each time you generate the data, not each time you log in)
How to keep/promote with a multi line comment from the accurev command line?
For example if I try:
accurev stat -n -fl | xargs accurev keep -c "git log 1234..4311"
I simple get the error:
You can not use non-printable characters on the command line: # On
branch master\x0a... AccuRev was unable to understand your command.
I can of course strip out the new lines but then the comment is not really useful.
AccuRev commands that take a -c option for a comment must currently be enclosed in quotes and have no line breaks.
As for the output from git log 1234..4311 that could be captured as a manifest file and kept with the other files.
Dave
I'm not sure about doing it directly from the command-line without any extra step, and I'm hesitant to try anything on my client's AccuRev setup. That said, according to the entry on accurev keep from the CLI manual:
–c <comment>
Specify a comment for the transaction. The next command-line argument should be
a quoted string. Alternatively, the next argument can be in the form
#<comment-file>, which uses the contents of text-file <comment-file> as the
comment.
Default: enter a comment interactively, using the text editor named in
environment variable EDITOR (or a system-dependent default editor).
Reading this, I see two ways you can do what you want from the command line (meaning, not using the GUI).
1.) Pipe or cat your stat info into file, the use the #file syntax to get it into your commit
2.) Get your stat into into your clipboard, then don't give an argument to the keep command, let your editor open up, paste, save, and close.
There may be a way to get this all done via CLI without these middle-steps (perhaps you need to format the \x0a into \r\n or something?), but as I said, I'm unwilling to try it on my AccuRev setup as AccuRev gives me (and everyone else) enough trouble as it is.
HTH