How to batch open txt files and save each with Sublime in linux command line? - save

How to command Sublime from linux command line?
I know how to open file in background but not how to call save function?
I have some character issues which Sublime seems to fix and therefore I'd like to run a batch of files through Sublime.

So the available commands are listed on the reference section of docs:
https://docs.sublimetext.io/reference/commands.html

Related

How to run 'rails credentials:edit' on Windows 10 without installing a Linux Subsystem

I am trying to run the following command on my Rails app on my Windows 10 machine:
rails credentials:edit
But I get the following error message:
No $EDITOR to open file in. Assign one like this:
EDITOR="mate --wait" bin/rails credentials:edit
For editors that fork and exit immediately, it's important to pass a
wait flag, otherwise the credentials will be saved immediately with no
chance to edit.
I did some research, and I understand that most people who want to run such aforementioned command on Windows 10 will need to install a Linux Subsystem on their Windows machines. However, such option is not available for me because I don't have admin rights on my machine. I have attempted installing a Linux subsystem by using resources like the one here without luck.
I'm using VS Code and Powershell within VS Code, and this works for me:
> $env:EDITOR="code --wait"
> rails credentials:edit
Credit goes to this article https://flexpoint.tech/2020/05/16/editing-rails-6-0-credentials-on-windows/ by J. Pablo Fernández
I didn't find any of the answers above worked for me. Notepad complained about the directory being incorrect and gave me a blank file.
I got it to work with Notepad++ by doing the following:
SET EDITOR="C:\Program Files\Notepad++\notepad++.exe"
rails credentials:edit
I didn't need to use the --wait flag.
I would suggest you switch to non-windows based system if you're trying to do any rails development as I used to work on a windows machine until I caved in and switched entirely to Mate Linux. It would be so much easier to develop Rails application on Linux platform since you would see almost all gems compiling without any issue and all the rails terminal commands are working without further setup.
However, if you would like to edit your credentials, you need a text editor (Usually vim on Linux) setup before running credentials:edit.
First run SET EDITOR="notepad_path" and then try running rails credentials:edit
You can change notepad_path to any other text editor you prefer. However, some editors like Atom was giving weird issues for me.
find your pathing to your local text editor (for windows its Notepad) you can search notepad and right-click and open the file location
right-click notepad and open properties then copy the Target:(EX.( "%windir%\system32\notepad.exe"))
now paste the target in SET EDITOR="target_path"
EX. SET EDITOR="%windir%\system32\notepad.exe"
now you can run bundle exec rails credentials:edit and notepad should come up with the decrypted info
If you are in a Windows environment, I highly recommend to use the classic notepad. In my experience using Notepad++, sometimes it opened correctly but didn't save, instead it works perfect with the classic notepad.
Also to run those mentioned commands, better use the classic cmd shell console, it might not work properly in PS (Power Shell) console. Good luck!
No $EDITOR to open file in. Assign one like this:
EDITOR="mate --wait" bin/rails credentials:edit
For editors that fork and exit immediately, it's important to pass a wait flag,
otherwise the credentials will be saved immediately with no chance to edit.
solution:
$env:EDITOR="notepad"
rails credentials:edit
I'm using windows 10 and here are the steps that I took:
make sure you have the path of your text editor in environment variables PATH
to do that, copy the file location of your text editor
right click on my computer(This PC) > select properties > advanced system settings > environment variables
on System variable box, click for "Path" > click edit > new > paste text editor file location
restart command line then try to open text editor using the command line. I'm using sublime and entering "subl" will open sublime text editor
cd to your project folder then run the following command:
set EDITOR=subl --wait
where subl is the executable file of the text editor
also without double or single quote, this will work since subl is an executable file and was registered on environment variable (if using notepad use: notepad).
Without the --wait flag, your credentials.yml.enc will be saved immediately without giving you the chance to edit.
alternatively you can directly set EDITOR similar to this:
set EDITOR="C:\filepath\to\your\editor --wait"
this time with quotes
Finally run:
rails credentials:edit
[Windows 8.1]
I'm using SET EDITOR="C:\Program Files (x86)\Notepad++\notepad++.exe" -multiInst -notabbar -nosession -noPlugin command to set the editor and it works.
Next, just run rails credentials:edit command. Then you can edit the credentials.yml file. Save it and close the Notepad++ windows. Then the credentials is encrypted and saved automatically.
Got it working (using PowerShell) with
$env:EDITOR="notepad"
then
bundle exec rails credentials:edit

erlang from windows command line

Anyone knows how to open the Erlang shell from windows command line?
In official tutorial recommended to write "werl" to the command prompt but this command doesn't work.
P.S. I have installed erlang to my PC.
You have 2 simple ways to start an erlang shell on windows.
1) you can open a terminal directly into the folder that contains werl.exe you want. Use Shift + right click and choose "open terminal here". Then type "werl.exe"
2) you can go into that folder using "cd path", then type "werl.exe"
Also if you use werl.exe, a new window will open. If you want to stay with your windows terminal you should use erl.exe
werl uses the wxwidget library. Everything is installed automatically if you use the windows binary file.
If you have installed from source, then wxwidget must be installed separately.
It is possible to start the erlang shell in a dos window: start a command window with cmd, and start the erlang shell from this window using erl.
I guess that you already checked that werl exe is in the search path.

Sublime Text 3 LaTeXTools plugin won't compile on Debian

When doing Ctrl+B on SublimeText3, the following error is output:
[Compiling first.tex]
TraditionalBuilder: Invoking latexmk...
COULD NOT COMPILE!
Attempted command:latexmk -cd -e $pdflatex='pdflatex -interaction=nonstopmode -synctex=1 %S %O' -f -pdf first.tex
Build engine: Traditional Builder
Running the exact same command compiles a pdf file just fine.
This answer does not solve the problem, as I've
Removed spaces around "="
Done a "Reconfigure LaTeXTools and migrate settings".
Made sure pdflatex is installed.
Made sure the path for texpath is correct.
If your command runs on terminal then most likely there is an issue either with the path or with the command itself (in the file). There has been some update to the README file by the developer:
some distros do not want a space before and after the = in $pdflatex = %E. But some do want the space there (sigh!)
sometimes latexmk is not on the PATH, or the path is not correctly picked up by ST. In this case, instead of "latexmk", use "/usr/bin/latexmk" or wherever latexmk is in your system.
some distros require quoting the $pdflatex assignment, as in "$pdflatex = \"'%E -interaction=nonstopmode -synctex=1 %S %O'\""
So it might take a while but you'll find it eventually in the settings or the traditionalbuilder.py file.
Also when I tried putting /usr/bin/latexmk, latex did not produce the correct pdf (I checked it with few changes and it just opened the old pdf) but in your case it might work.
Also, at least in Arch Linux I can't run sublime with sublime-text but instead with subl so I changed that too in the settings (I don't know if it actually matters) and I needed to change the permissions for the files because user-run sublime could not access my settings files!

Command line modification using Smultron instead of Textmate for mate commands

I'm going through the railstutorial.org Chapter 3 tutorial and the instructor asked us to create a new html file with the command:
$ mate public/hello.html
However, I'm not using Textmate in this case, but rather Smultron as my text editor. That said, I receive the error message:
-bash: mate: command not found
Do you know what word I should replace "mate" with to properly communicate with Smultron?
When Textmate is installed, it puts a mate executable in /usr/local/bin/. If you're not using Textmate, you won't have that command.
Older versions of Smultron placed a smultron executable in the path. I don't imagine that's changed, but I don't have the lastest version of Smultron to confirm that. I also don't remember if you have to provide any kind of command line switches when creating a new file.
Edit: To get command-line support in Smultron 4, download this: http://www.peterborgapps.com/wp-content/uploads/2011/07/smultron-commandlineutility4.zip

"rails" command on windows

So I installed Ruby On Rails using the Windows Installer.
Now the startup guides says I have to start up an Terminal and run the Rails command to make a project. I don't have a terminal, so how do I execute a Rails command and make a project??
The CMD command line in Windows does not recognize "rails"
I don't think it is an PATH problem, because when I'm in the "Bin" directory, there is "rails.bat" and "rails" with no extension. If I run Rails.bat I get "The filename, directory name, or volume label syntax is incorrect."
I get that message with whatever Argument I pass to it.
It seems to be a bug in the rails.bat file because of double-quotes, like:
#"ruby.exe"" "%~dpn0" %*
Remove the double quotes:
http://sepitfalls.blogspot.com/2008/12/updateing-rubygems-broke-gem-command.html
To get a terminal
Start > Run... or Windows key + R
Type "cmd" and hit enter.
To add a folder to the command line's path
On Windows XP (Vista is similar)
Start > Control Panel > System
Click the "Advanced" tab
Click "Environmental Variables"
Under "System Variables" double click on Path and edit accordingly.
You will need to open a new command line in order to get the updated path to take affect. With XP, I've had to reboot to force it to take affect but it shouldn't be necessary.
The Path variable is a semi-colon seperated list of folders in which the Command Line or "terminal" looks for commands.
You'll probably have to find the rails command yourself. I would try looking for a rails.bat or rails.cmd file.
I think they mean the command window. Try running it from a command line.
I dont know where the Windows Ruby on Rails intaller places its files, but the ultimately solution is that you need to make sure that the "rails" command is is your PATH - which you can view/modify by right-clicking My Computer, selecting Properties, going to the Advanced tab and then clicking on "Environment Variables" and then scrolling down until you see "PATH" and adjusting it accordingly. You probably need to find the directory where the "rails" command lives and append to the end of the existing PATH entry, inserting a ";" before you enter the new path to append it to the existing PATH.
So find where "rails" is and add its directory to your PATH.
You probably have to change your PATH in Windows to point to wherever the rails executable has been installed.
The PATH environment variable is used to determine where Windows looks for stuff; when you type, for instance, 'calc' Windows will hunt through its PATH and eventually find and run C:\Windows\calc.exe. In your case, the PATH doesn't include the directory you need, so Windows isn't searching in that directory for rails.exe when you type "rails."
To fix this, right click on "My Computer" -> "Properties" -> "Advanced" -> "Environment Variables" and then modify the PATH one to include the directory your rails.exe is in.
I recommend using cygwin for Rails development on windows - far too much of the community is using *nix. If you install the development tools package you'll automatically have svn, git and other doo-dads that you'll eventually need relating to various rails plugin installation. If you want to deploy using capistrano the installation is identical to all the instructions you find. Plus other tips and tricks people will reference will work exactly the same for you as it does for them, whereas some things are different for native windows and all the accessory tools have to be installed separately.

Resources