How to launch and edit a file from Git using Notepad++? - ruby-on-rails

I have set up Notepad++ as my default editor as in this topic:
How can I set up an editor to work with Git on Windows?
with this command:
git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"
Now, I'm working through a Ruby on Rails tutorial. On one step, the author uses the command:
$mate README.markdown to launch his TextMate editor and edit the readme file.
My question is, now that I have set up Notepad++ as my default editor, what is the equivalent command that I should use to launch Notepad++ and edit the file?
Note: I'm a beginner with this Git and Ruby on Rails. Please go easy on me! Thanks in advance.

C:/Program Files/Notepad++/notepad++.exe README.markdown
And since you'll probably want to use notepad++ a lot from the command line, you may want to alter your PATH to include its root directory, so you don't need to write the full path each time.

Add notepad++.exe to your Windows path enviromental variable( the whole path), this option is in computer, right click, advance system setting enviromental variables.
After from command promp just do:
notepad++ markdown.README
You could also just use the whole path to notepad.exe everytime but that gets old, just learn how to edit your enviromental variables in windows.

You must first add Notepad++ as the main program. On Git Bash
git config --global core.editor "'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Notepad.lnk' -multiInst -notabbar -nosession -noPlugin
And then you will be able to create the file by writting
start notepad README.md
start notepad++ README.md

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

Where is the .bashrc file on Windows? (Daniel Kehoe's learn-rails tutorial book)

I previously asked a similar question with regards to cloud9, but I am now trying to do the same project in parallel on my windows 10 machine because I will not have internet access to use cloud9. I am trying to set up the configuration in preparation for following Daniel Kehoe's learn-rails tutorial book, but I am having trouble setting up the environment variables. The book seems to explain how to do it on Mac but I can not find the file in the atom editor. the book says to type the command:
atom ~/.bash_profile
However this just creates a new file that is not part of my rails app project directory. i have also tried
atom ~/.bashrc
which is the alternative but with the same result. It just creates a file unrelated to my project. The file is supposed to already exist somewhere.
I am supposed to put the environment variables into a file called ".bashrc" but I don't know where to find this file as it is hidden. How can I locate and open this file with Atom text editor?
.bashrc , .bash_profile are used in unix based operating systems for the terminal. In windows you set environment variables differently. In windows 10, search for environment variables in start menu, and select Edit the system environment variables and set them from there.
PS: You can have .bashrc if you have installed something like git bash, cygwin bash or bash for windows 10 or something else. And all 3 handle .bashrc differently.
Typing echo ~ in the Git Bash terminal will tell you where that folder is which contains the .bashrc file

How do I name the .bowerrc file?

This MEAN-stack tutorial describes using Bower to install AngularJS in your public folder. One of the steps describes creating a file called ".bowerrc" in your test-app folder. However, Windows won't let you create a file without a name. How do I accomplish this on a Windows system?
on the command line (make sure to cd into your working directory), issue this command:
touch .bowerrc
This will also work for other files common to webdev like .htaccess and .gitignore
Note: If you haven't installed git bash for windows, you may not have support for the touch command. In that case (as mentioned in one of the comments here), the easiest way to accomplish this is via the cli with:
echo "" > .bowerrc
To create a file that starts with a "." in Windows, you just need to add a trailing ".".
So, simply name your file ".bowerrc." instead of ".bowerrc".
See https://superuser.com/questions/64471/create-rename-a-file-folder-that-begins-with-a-dot-in-windows for more information and more detailed solution if this doesn't work for you.
Another way to accomplish this is through Notepad++.
Create the file in Notepad++
Set the encoding to "Encoding in ANSI" (click "Encoding" in the menu bar)
Save the file as .bowerrc (change the "Save as type:" to . which is one list item up from *.txt)
Simply rename the file you created:
C:\project> ren bowerrc .bowerrc

its about what to do if you didn't install sublime when using ruby on rails tutorial

I did not install sublime. I'm at the point in the Ruby on Rails Tutorial by Hartl where he has you set up a branch for the first time. So I can't figure out what to do where his instructions are
$ git mv README.rdoc README.md
$ subl README.md
Should I create a file like the one in his book and then replace the original README.rdoc document and skip these commands? Should I create the new README.md file and put it in the main project folder but keep leave the old file there? If I do one of these can I then just continue with the rest of the commands after these? Should I do one of the above and then run just the first command above? The book doesn't seem to give a clue really about what is necessary here. It doesn't even actually tell you to create the new file. Honestly I'm lost here.
The only thing I think I understand is that the first command above renames the old file. If that is true then can I just run that command and then edit the original file in a text editor. Would I then skip the second command. Could I then continue with the rest of the commands.
By the way I working on a laptop running Windows 7.
$ git mv README.rdoc README.md
That is going to rename the file. Nothing more.
$ subl README.md
That is going to open the renamed file in Sublime (a text editor).
If you want to achieve those two steps, just rename the file however you like and open the file in any text editor.

What would be the alternate command for mate gemfile for some other editor in windows?

I started with rails tutorial but there was the use of mate editor in that which is for apple OS but i m using windows and have installed a recommended editor komodo edit.
What can be the alternative to this for komodo edit?
$ mate Gemfile
Not sure if I follow but mate Gemfile is no different to just opening any editor and doing File -> Open and selecting the file Gemfile. It's just an alias for opening the application TextMate and opening the file Gemfile
Instead of using Mate command on Windows, you must first add Notepad (or any other editor you'd like) as the main program
git config --global core.editor "'C:\ProgramData\...notepad location' -multiInst -notabbar -nosession -noPlugin
And then you will be able to create the file by writting
start notepad README.md

Resources