Meld: can I clear the read-only flag on file? - meld

The version control system that I have to use (Perforce) by default gives me read-only files. I want to move some changes from one directory to another, and the target files are read-only. I want to clear the read-only flag from the Meld UI. (Otherwise I will have to manually locate changed files in the directory tree, which is just stupid.)
How do I clear the read-only flag on file from the meld UI?
(Something ready-to-use? Or maybe it is easy to write some small extension?)

C:\Windows\clearro.cmd:
attrib -r %1
(Menu)--Meld-Preferences--the [Editor] tab
Uncheck "Use default system editor"
specify clearro.cmd as Editor command.
Now, to clear the read-only attribute, you right-click the mouse on the file and choose "Open Externally" from the menu. Instead of opening the external editor, it will invoke clearro.cmd on the file. If you need to open the file, you can go to preferences and check the checkbox.
Yes, it should be an external tool invocation rather than an editor hack, but this at least works.
(Did not try this on Linux, but it should be something like chmod a+w $1 in the file clearro.sh, don't forget to chmod a+x clearro.sh to make it executable.)

Related

How do I revert my .bash_profile back to a TextEdit document?

I was following a Git course on Udacity and we made some changes to our bash profiles.
Somehow my .bash_profile is now recognized as a Unix executable file rather than a TextEdit document. I can still use it as before, but it bothers me that this change has happened. More than anything I would also like to know what is going on under the hood.
Where on my computer (I'm running MacOS) is the data stored that this is an executable? It doesn't have a file extension so how does the computer know? I changed its 'open with' field found in the 'get info' window but it still identifies as an executable.
in unix each file has permission bits which you can see with ls -l. In this case the 'x' bit has been set which means the file is executable. To revert the file back simply execute chmod -x on the file and it will unset the 'x' permission flag making the file a text file.

"You must type a file name" error thrown, when I create a .gitignore file on Windows

When I try to do this, I get the following error:
Obviously, Windows Explorer doesn't allow me to create this type of file patterns. How can I overcome this problem?
In the File Explorer, the trick is to call your file .gitignore. and it will remove the ending .
A strange behavior but, hey!, it works 😅
Or create it from a text editor...
Windows Explorer doesn't allow you to create files that consist essentially of a file extension only. This is because Windows Explorer has the option to hide file extensions, leaving you with a file you cannot see (see Why doesn’t Explorer let you create a file whose name begins with a dot?). This is not a restriction of Windows itself, or the file system in use, though.
To create a file named .gitignore, you will have to use another tool to create it. A common solution is to create a text file (e.g. test.txt), open it in Notepad, and select Save As... to rename the file to .gitignore.
The Windows command interpreter also allows you to create files without imposing the additional restrictions of Windows Explorer. A more direct solution would then be to create the file from the command line. This can be done using the following command:
copy NUL .gitignore
Note: When dealing with files that don't have a name, it's helpful to disable the option "Hide extensions for known file types" in Windows Explorer. Otherwise Windows Explorer might show files with no names, or hide them altogether.
In cmd, just type
echo. 2>.name_you_want
or
. 2>.name_you_want
to create a file.
If creating a directory, just type
mkdir .folder_name_you_want
Use command line instead.
I was also having the same error. The problem was . at the start of file or folder name.
So I created it by command line.
You can do this with command prompt for folder creation:
mkdir .folder_name

Set global working directory alias in Git bash (Windows)

I've been trying for literally hours to set a global alias that I can use when I open Git bash on my Windows machine to cd to a specific location.
I want to be able to simply type the alias to get to the location. I've tried every which way. The attempt that got me closest was based on this: https://superuser.com/questions/602872/how-do-i-modify-my-git-bash-profile-in-windows
...but it seems that to get it to work upon relaunching of bash, I have to use source .bashrc, which I don't want to do. Help appreciated.
I just jury rigged a solution with a simple shell script that acts like a global alias. If someone has a better solution, please do tell.
Opened text editor and wrote the following two lines:
#!/bin/bash
cd blah/blep/directory_of_choice
Saved it as a text file with a descriptive name (like dirjump) somewhere and copied it.
In file explorer, navigated to the bin folder in the MinGW64 installation, e.g. "C:\Program Files\Git\mingw64\bin"
Pasted the file into this bin folder.
While viewing the contents of the bin folder referenced above in Windows file explorer, from the menu bar selected "view > options", which opened the "folder options" dialog. Selected the "view" tab here and unchecked "Hide extensions for known file types" and clicked ok.
Deleted the ".txt" extension from the file copied into the bin folder.
To call this shell script that has the same result as a global alias, typed the following in Git bash:
. dirjump (the space between the dot and the dirjump MUST be included)

Vim Can't Save File (E212)

Sometimes when I create a file using vim some/path/newfile, vim lets me edit it, only to complain when I attempt to save my changes.
E212 Can't open file for writing.
This appears to happen only when the new file is located in a system directory.
:w! does not override this error.
How can I write the current buffer, without having to save it to a temporary location, exit, then rename it using sudo?
This will ask you for the root password, then save your changes as you requested:
:w !sudo tee %
Then type (L)oad at the prompt, to re-load the file after it is saved.
You can mkdir first, then save it.
Add this line to your .vimrc:
cmap w!! %!sudo tee > /dev/null
and then you can do
:w!!
when you get into this position, and it will write the file using sudo. Very handy.
You can avoid this problem by using "sudo" to start the editing session.
sudo vi name-of-file
If you want a robust, easy-to-remember solution and don't mind installing a plugin, try SudoEdit.vim - Edit Files using sudo or su or any other tool.
If this is the case in Windows 7 or later editions, run the VI editor as Administrator. Right Click of the application and select "Run as Administrator". This issue will be resolved. Moreover, the error is due to Administrative Privileges.
vim some/path/newfile
you can try to do it in two steps,first create the folder 'some' and 'path' by use mkdir ~ ;second you go into the 'path' folder,use the command:sudo vim newfile.then save it
Make sure the directory where you are trying to save the file exists and that you have permission to edit the file.
You can type :help message in Vim to get more information on this and other error messages. Try searching by typing /E212 once the docs come up. You can also view the documentation online at http://vimdoc.sourceforge.net/htmldoc/message.html and CTRL-F to find it.
For what it's worth, you may also want to ensure you have sufficient storage in the partition where you're attempting to save the file. I had to free up some space in my /home drive and that resolved the issue.
I know this is an old question, but this is what fixed it for me. Your file might be set to immutable meaning that you can't edit it.
You can check this with lsattr /path/to/file.txt
If it is use
chattr -i /etc/resolv.conf to make it no longer immutable.
Just had this issue outside of system directory.
When I tried to open a file vim src/help/tips.c. Turns out help directory did not exist, the directory was named differently and it was one of those very rare occasions that I did not auto-complete with Tab.
So, in conclusion, if this happens for a file that is not at a place where you may have permission issues, look if the path leading up to the file is a valid one.
I have experienced this in Kali!! The default account requires escalation to root with "sudo" in order for the file to be editable.
e.g: sudo vim / at this point all standard expectations appear to follow.

How can I view the User/Library/LaunchDaemons folder within the finder?

Within the finder I can view the contents of User/Library and can see many folders there, however I cannot see a folder called LaunchDaemons.
However if I navigate to the Library folder from the terminal command line then LaunchDaemons is visible.
How can I make it appear in the Finder?
I've tried this command but it didn't have any effect
defaults write com.apple.Finder AppleShowAllFiles YES
There is (at least by default) no LaunchDaemons folder in the user Library. You may be navigating to one of the other Library folders in Terminal. You can check this with the commands pwd (which prints the full path to the current folder -- if it doesn't start with /Users/youraccountname/Library, you aren't in your user Library) and open . (which opens the current folder in the Finder -- and again, I'm pretty sure it won't be inside your user Library).

Resources