Usually when I type cd in my terminal, it will return $
and if i type cd any file, it will turn to filename/ $
but now, it keeps on saying the file does not exist when the file does seem to exist.. how do i get it to work as per normal?
enter image description here
and if i type cd any file, it will turn to filename/ $
but now, it keeps on saying the file does not exist when the file does seem to exist..
Looks like you are in an other directory then you want to be. cd is working it just doesn't find your folder because it is in another folder/directory that you are currently in. If that's the case try one of the following:
on the left at you files go to "birthdays"-folder make right-click and say "open in Terminal". Your terminal should have the correct folder then.
type "ls" if you are in the wrong folder or don't see your folders do "cd .." this will get you to the next folder up in the hierarchy. Then do "ls" again and try to find a way to your Project folder.
Close VScode completely and open it using the VScode shortcut on your desktop(or somewhere else) then open your project using the open folder function. It should have the right folder selected then.
I want to open all files under /var/log/my_program/ in my current open workspace. To be clear, I want to open the files from this directory while keeping the files that are already open in my current workspace open as well.
e.g. if I have ~/hello-world.html open, I would like to open /var/log/my_program/error.log and /var/log/my_program/access.log in the workspace as well, having a total of 3 files open at the same time in the same window/workspace.
if I run code /var/log/my_program/* it will open up a new window with all of the files open from that directory. i.e. hello-world.html will be in one window and error.log and access.log will be in a new window
if I run code -r /var/log/my_program/* it will overwrite my current workspace with the files from that directory. i.e. hello-world.html will no longer be open in any window, and error.log and access.log will be open in my original workspace window.
I want to be able to keep the state of my current workspace AND open the files from the /var/log/my_program/ directory. i.e. I would like hello-world.html to stay open in the workspace AND have error.log and access.log open as well.
I would like to add that this is just a simplified example of what I am trying to do. I understand it would be easy enough to just open these two files easily in the command line, but the actual files in the dir I want to open could be several and all with timestamps in their names, so I cant easily open them by name
Is this possible? Thanks for any help!
EDIT:
I am really looking for a solution using the CLI. I am running a command similar to rm /var/log/my_program/*; systemctl restart my_program; code /var/log/my_program/*. This is so the dir doesnt get full of old log files, and I can see the new log files opened after I have restarted the process for my_program
The reasoning for all of this is to make my debugging routine less cumbersome, e.g. without mouse clicks or gui interaction
In VS CODE itself there is a keyboard shortcut that might be helpful:
ctrl + r
Which will open a drop down of folders.
Once you arrow down/up to the desired folder, you have two options:
Click enter to open the new folder instead of the current workspace, or
ctrl + enter to open a new folder in addition to the current open workspace
If I understand what you are trying to do correctly, you want to use the --add argument. You can run code --reuse-window --add <path> to open the folder at <path> in the current workspace. The shortened version would be code -r -a <path>.
The steps for modifying this variable permanently for all terminal sessions are machine-specific. Typically you add a line to a file that is executed whenever you open a new window. For example:
Determine the directory where you placed the Flutter SDK. You will need this in Step 3.
Open (or create) $HOME/.bash_profile. The file path and filename might be different on your machine.
Add the following line and change [PATH_TO_FLUTTER_GIT_DIRECTORY] to be the path where you cloned Flutter’s git repo:
$ export PATH="$PATH:[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin"
Run source $HOME/.bash_profile to refresh the current window.
Verify that the flutter/bin directory is now in your PATH by running:
echo $PATH
In mac, you should add it as follows in ".zshrc":
export PATH="$PATH:/Users/matteo/Documents/flutter/bin"
After you have updated the ".zshrc" file, run this command to ensure changes have been notified to OS
source ~/.zshrc
Reference: https://flutter.dev/docs/get-started/install/macos
A similar concept is for Linux system using bash files
I tried a lot of methods but this one permanent solution worked for me like a charm:
open Terminal in your Mac: type:
sudo nano /echo/paths
Add the code to the file:
/users/yourUserName/flutter/bin
Save the file using Control+X and Press Y and Enter
Hope this helps! :)
It appears that VSCode always opens a folder in with the last UI state it had.
I'm looking for something like Sublime's remember_open_files: false, or in other words, I would like VSCode to open up with a clean UI state regardless of what state the UI was in the last time the folder was open.
What's happening now:
cd my-project-folder/
code .
# VSCode opens folder with saved UI state
What I want:
cd my-project-folder/
code .
# VSCode opens folder with fresh UI state
I tried to do it through command line using the command
code -n .
which should have opened VS code in current folder with a new session but it does not seem to work at all. I believe that code . seems to ignore the -n new session option and restores the previous session for the folder. So this feature is probably not implemented in VS code.
(Refer here for the commandline options for VS code.)
this is the command that works for me on windows
code -r .
From inside VS Code built-in terminal, cd into your project folder/directory and enter command:
code -a .
Note period at end.
This will open your current directory/project folder without opening a new window.
Part of the answer on this thread worked for me. Basically, make sure VSC is in the Applications folder. Then open the Command Palette (F1 or ⇧⌘P on Mac) and type shell command to find the Shell Command: Install 'code' command in PATH command.
Restart Visual Studio Code if it's open. In terminal, navigate to the folder you want to open in VSC, and type code .. Hopefully it should work for you.
If you are using a Mac, you need to first install the VSCode command amongst the shell command list.
Do this:
Open VSCode
press CMD + SHIFT + P
type shell command
select Install code command in path
navigate to any project from the terminal and type code .
code . opens VS Code at the current terminal folder
If you are using VS Code [Version: 1.50.0] then open your command prompt and go to your project's directory and just run the command:
code -a .
i.e. [Also can see the photo]
[1]: https://i.stack.imgur.com/sMmkH.png
$ code . --user-data-dir=.
This will open Visual Studio Code in current working directory. I use Bash with Ubuntu 16.04LTS.
I am using VS Code Version 1.24.1 (As of the time of original posting).
If you want to open a folder through the terminal, you can execute the command:
code -n name_of_your_folder/
or
code -n path_to your_folder/
Same thing goes for a file, and these open VS Code in a new window.
Also, note that you should have VS Code installed.
You're welcome!
I checked through all of the settings available in the VSCode preferences for me, and I don't think there is a way to do this.
There are some settings related to what VSCode window instance that folders will open into, but nothing that seems similar to Sublime Text's remember_open_files setting.
The closest thing I found was running code --user-data-dir . (feel free to replace . with some other directory so you don't pollute your current working directory) from the terminal to specify that VSCode shouldn't remember ANY previous settings, but this seems like overkill for what you're trying to accomplish (as VSCode will literally run as if it's the first time it's being run after a fresh install).
EDIT: I just discovered a View: Close All Editors command in the command palette (CMD + SHIFT + P). The keyboard shortcut for OSX is CMD + K, CMD + W, and this will close all the files you have opened!
I have the same problem on Mac.
I solved it in the following steps:
I opened the "Command Pallete" on the VSCode. This can be done by CMD + SHIFT + P
Type "shell"
Click on 'Install code command in path'
Give an administrator password
You will get a message that it has been installed
Now run "code ."
NB: Make sure you already cd into the folder you want to open before you run code .
If you want to open folder with vscode, you just go to folder ( you can user terminal or file explorer) with terminal, and do "code ."
To get the right folder in VS Code v 1.50.1 Terminal I tried a lot of options which didn't work for me. At the end I found very easy solution. I went to File->Open Workspace and found that my Workspace had the wrong folders inside it, which I simply deleted (from Workspace only!). Then I opened the folder I needed in my Workspace, opened Terminal->New Terminal, and everything worked perfectly well. Please let me know if this will work for someone else.
This command works to open a specific folder in VS code using terminal
code -r Documents/VS/C++/
here -r switch is used to open a file or a folder in an already opened VS code window
and then you specify the path of the file or folder you want to open
if you want to open it in a new window use -n switch instead of -r
This works for me with VSCode on Linux:
cd path/to/project
codium .
I tried every mentioned answers, what's work from me is this:-
I created a shell script to open folders.
$ sudo nano /usr/local/sbin/code2
/usr/bin/code-oss -n --user-data-dir '/home/myusername/.config/Code - OSS2/' -a $#
$ sudo chmod +x /usr/local/sbin/code2
You can remove --user-data-dir '/home/myusername/.config/Code - OSS2/' from the script if you want to use default code-oss config folder.
When I want to open a folder, I use the command like this :-
$ code2 .
I add this command code2 to open with option thunar to open folders directly from files manger.
Go to the directory in the command pallet on your computer the navigate to the the specific folder using cd
the type code . and that will open the folder and the files in it inside vs code. works like a charm.
If Visual Studio Code is installed using flatpak then a bash alias can help launch the application from the terminal.
alias code="flatpak run com.visualstudio.code"
I did it a simpler way just by three steps. I am currently in a project folder and want to open another folder in vs code using the cli or terminal. What I first did is navigated in the folder which I wanna open in vs code inside the terminal. Once I m inside that particular directory or folder I simply typed the command :
start code .
This will open that directory or folder in a new vs code window.
The complete process is :
open the terminal is vs code
navigate to the folder u want to open
once u r inside that particular folder type the command :
start code .
The documentation says this file is here
/etc/mongorc.js
Some other resources say that this file is under home directory.
I was not able to find this file in both places. Please help!
Note that my OS is Ubuntu 14.04
Files beginning with . are hidden files. If you are viewing nautilus, in home folder:
ctrl+h
will show you the hiddenfiles.
If you are viewing in command line, try in home folder
ls -a | less
or
ls .mon*
If there is no file, you can create it in the home folder and start using it with the name .mongorc.js in the home folder.