Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Bash Open Command Windows

I'm extremely new to the command line and just programming in general. I use windows, and I'm doing prep work for viking code school. In one of the lessons it asks us to use the 'open' command in Git Bash (we were to download Git Bash if we weren't on Linux or Mac) which will not work for me. When I type it, I get the error "bash: open: command not found", how can I fix this or work around it? Thank you

like image 835
Branden Kennedy Avatar asked Sep 26 '15 04:09

Branden Kennedy


8 Answers

No you can't use open on windows. I think the closest to open in windows will be explorer, which will open the file using default associated windows programs.

like image 167
lalthomas Avatar answered Sep 21 '22 18:09

lalthomas


open isn't a shell command or a program name, it is a system call.

On Unix, Unix-like and other POSIX-compliant operating systems, popular system calls are open, read, write, close, wait, exec, fork, exit, and kill.

Git for Windows is based on mingw64, and open() is not a system call on Windows. Simply calls an editor or a bash command to open the file.

cat file.txt
more file.txt
/path/to/editor.exe file.txt # like sublimeText.exe

Julix adds an example illustrating a Windows path:

/c/WINDOWS/system32/notepad.exe file.txt(<- change that to your file)
like image 29
VonC Avatar answered Sep 21 '22 18:09

VonC


I found two kinds of command lines would work same as open in Mac.

start filename
explorer filename
like image 28
Yvonne.D Avatar answered Sep 21 '22 18:09

Yvonne.D


I'm also a complete beginner, but it seems that the command you want is start (at least when applied to a program or program-file-pair).

like image 40
Jessica B Avatar answered Sep 22 '22 18:09

Jessica B


If you are using GIT BASH on Windows PC - then to open a text file, type start notepad.txt

where start will 'open' your file, make sure to add the file extension also.

You can use start for opening images too.

start favicon.png or start readme.md
for example.

(If you want to add text to that .txt file using BASH then type, echo "type something with quotations" >> yourtextfile.txt)

like image 29
TheNuggitMan Avatar answered Sep 19 '22 18:09

TheNuggitMan


For Git Bash on Windows, type the .exe name of your editor, for example, Visual Studio Code exe is Code.exe followed by space and dot. So you write Code ., and it will open all files with your editor.

like image 26
Pavlin Avatar answered Sep 18 '22 18:09

Pavlin


"open" cannot be used on windows. The closest to open in windows will be the "explorer" (to open the default explorer) or "explorer ." (to open the current directly).

like image 20
Bunny Avatar answered Sep 20 '22 18:09

Bunny


start command works for me on Windows machine as a replacement for the open command.

like image 41
Rachel Unclebach Avatar answered Sep 21 '22 18:09

Rachel Unclebach