Score:0

Open vscode from script in ubuntu

cn flag
sky

I am trying to create script to open VSCode in the current directory but I am not abe to do it for folder consist of spaces.

For example if location is 'home/documents/code'. it is able to open correctly, but if location is 'home/documents/code folder' it does not open the 'code folder' in vscode.

Command that I am using

code -n $PWD

This command works fine if folder does not have spaces I have tried to enter the $PWD in double quotes but on executing the script it does not opens the folder in the location

code -n \"$PWD\"  
Someone avatar
my flag
Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Score:0
br flag

if you dont use \ before " you can open it
you need to write code -n "$PWD"
i tested on my terminal and my pwd was /home/aazerra/Untitled Folder and worked

if you read link you can see this

If you enclose the text in quotation marks (“…”), this prevents Bash from acting on most of the special characters, and they just print. One notable exception, though, is the dollar sign ($). It still functions as the character for variable expressions, so you can include the values from variables in your output.

sky avatar
cn flag
sky
Thanks it worked
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.