I am trying to create an alias in my zsh aliases to open Chrome with localhost:9292 being the URL. How would I go about adding the localhost and the port? I have it working where it adds the application for my alias, but won't open correctly. Here is what I have:
/Applications/Google\ Chrome.app/Contents/MacOs/Google\ Chrome --port=9292
When I do this I get an error
segmentation fault
Could someone who has done this before help me to understand how I can run my alias
alias devdocs="/Applications/Google\ Chrome.app/Contents/MacOs/Google\ Chrome"
along with the localhost and port being loaded?
Thank you,
Rob
open http://localhost:9292 if chrome is your default browser or
open http://localhost:9292 -a /Applications/Google\ Chrome.app if not.
Or write a function that takes a port
function lh() {
if [ $# -eq 0 ]; then
open http://localhost:3000
else
open http://localhost:$1
fi
}
you can use one of the following:
i) open http://localhost:9292 on an already opened chrome window
alias devdocs='open -a "Google Chrome" http://localhost:9292'
ii) open http://localhost:9292 on a new window
alias devdocs='open -a "Google Chrome" --args --new-window http://localhost:9292'
iii) if chrome is your default web browser
alias devdocs='open http://localhost:9292'
Check out this article for more information.
Related
I want to load the temporary extension when you open the browser.
But the command for Microsoft Edge does not work.
"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --load-extension="C:\Users\Administrator\Desktop\autoLogin"
The command for Chrome works.
C:\Users\Administrator\AppData\Local\Google\Chrome\Application\chrome.exe --load-extension="C:\Users\Administrator\Desktop\autoLogin"
What should i do?
I have tested further on my side and found that the below command loads the extension to the Edge browser.
start msedge --load-extension="<Extension-path>"
Output:
Note: Make sure to close all the instances of the Edge browser before running this command.
I'm using VSCode and the official remote-ssh extension.
I would like to be able to write code /path/to/file in an ssh terminal or in the vscode integrated terminal in a remote window in order to open a file/folder in vscode remote.
I am aware that I can use code --folder-uri=vscode-remote://ssh-remote+ADDRESS/path/to/file from the local machine's terminal, but I want to be able to run a command from within the integrated vscode terminal and any other terminal session where I've ssh'd into the remote machine)
Currently, if I run code from a remote terminal it opens up a new vscode window on the remote machine.
To achieve this goal, in the past I've used the following alias on the remote machine:
alias code="${VSCODE_GIT_ASKPASS_NODE%/*}/bin/code"
Which looks for the code executable in ~/.vscode-server/bin/<COMMIT_ID>/bin before defaulting to the local /bin/code.
I got that alias from this related stackoverflow question.
However, this doesn't seem to work right now.
Upon closer inspection, it appears that there is no code executable in the vscode-server directory.
How can I fix this?
Both machines are running MacOS and visual studio code version f80445acd5a3dadef24aa209168452a3d97cc326, if that's relevant.
I also wanted to be able to run code from the integrated terminal when running VSCode with the "remote ssh" extension. In my case, the "remote" is a Linux box (named "aorus" below), and I want to use VSCode from a laptop running macOS (named "mbp").
As for you, I used to use the VSCODE_GIT_ASKPASS_NODE trick. Recently, I had to change the alias since code (or code-insiders in my case) wasn't available in bin/ anymore. It seems it has been moved to bin/remote-cli. The correct alias (tested with vscode 1.64.2):
alias code="${VSCODE_GIT_ASKPASS_NODE%/*}/bin/remote-cli/code"
If you also want this to work from other ssh sessions (not just inside the integrated terminal), you can create a short script that I called coder (r for "remote") which I have in ~/bin on my remote ("aorus"). Note that you need to be able to reach the local machine from your remote (I do that with Tailscale). The script looks like this:
#! /bin/bash
set -ex
remotehost=$(hostname)
localhost=mbp
cmd="code"
while [ $# -gt 0 ]; do
if [ -f "$1" ]; then
cmd+=" --file-uri \"vscode-remote://ssh-remote+$remotehost$(readlink -f "$1")\""
elif [ -d "$1" ]; then
cmd+=" --folder-uri \"vscode-remote://ssh-remote+$remotehost$(readlink -f "$1")\""
else
cmd+=" $1"
fi
shift
done
exec ssh $localhost -q -t -x "exec bash -l -c '$cmd'"
On my Mac, when running VSCode connected remotely to my Linux box, I can type this in the integrated terminal to open the file main.go present on my remote Linux box:
coder main.go
The reason I have to wrap code in bash -l is due to the fact that ssh, by default, runs in a non-login shell, which means that the ~/.bashrc on my Mac isn't picked up, meaning code isn't in the PATH. The error message looks like this:
bash:1: command not found: code
Another note: there is a shorter syntax documented here:
ssh -q -t -x mbp bash -l -c "code --remote=ssh-remote+aorus main.go"
I don't use this syntax is because this method isn't able to know whether you are opening just a single file (which should be open in the most recent VSCode remote session) or a folder (which should be open as a new VSCode remote session).
Finally, if you are using VSCode Insiders, you can create a symlink so that the command code works on your local machine (in my case, on my Mac):
sudo ln -sf /usr/local/bin/code-insiders /usr/local/bin/code
As already explained by maelvls the path has been changed.
But if you use it outside integrated terminal you will got message
Command is only available in WSL or inside a Visual Studio Code terminal
To avoid this you need to export VSCODE_IPC_HOOK_CLI in your .bashrc .
Use this script in your .bashrc
export VSCODE_IPC_HOOK_CLI=`ls -t /run/user/1012/vscode-ipc-* | head -n1`
alias code="~/.vscode-server/bin/*/bin/remote-cli/code"
If you want to open your file in your current visual studio use -r option.
code -r tes.txt
Note :
I can't call VSCODE_GIT_ASKPASS_NODE so I use full path, it is working well
I don't know if VSCODE_IPC_HOOK_CLI will show in different location, just check it in your integrated terminal visual studio code
tested on remote server Centos 7
local macOS Monterey version 12.2
Visual Studio Code Version: 1.64.2 (Universal)
Commit: f80445acd5a3dadef24aa209168452a3d97cc326
extension : remote-ssh
While watching the YouTube development video, I used the command (code . -r) in the cmd window in vscode. What is this function? vscode turned on, but what does -r mean?
The help says:
-r --reuse-window Force to open a file or folder in an already opened window.
Full help is available to you:
$ code -h
code 1.55.2
Usage: code [options][paths...]
To read from stdin, append '-' (e.g. 'ps aux | grep code | code -')
Options
-d --diff <file> <file> Compare two files with each other.
-a --add <folder> Add folder(s) to the last active window.
-g --goto <file:line[:character]> Open a file at the path on the specified line and character position.
-n --new-window Force to open a new window.
-r --reuse-window Force to open a file or folder in an already opened window.
-w --wait Wait for the files to be closed before returning.
--locale <locale> The locale to use (e.g. en-US or zh-TW).
-h --help Print usage.
Extensions Management
--list-extensions List the installed extensions.
--show-versions Show versions of installed extensions, when using
--list-extensions.
--category Filters installed extensions by provided category, when
using --list-extensions.
--install-extension <extension-id[#version] | path-to-vsix> Installs or updates the extension. The identifier of an
extension is always `${publisher}.${name}`. Use
`--force` argument to update to latest version. To
install a specific version provide `#${version}`. For
example: 'vscode.csharp#1.2.3'.
--uninstall-extension <extension-id> Uninstalls an extension.
--enable-proposed-api <extension-id> Enables proposed API features for extensions. Can receive
one or more extension IDs to enable individually.
Troubleshooting
-v --version Print version.
--verbose Print verbose output (implies --wait).
--log <level> Log level to use. Default is 'info'. Allowed values are 'critical', 'error',
'warn', 'info', 'debug', 'trace', 'off'.
-s --status Print process usage and diagnostics information.
--prof-startup Run CPU profiler during startup
--disable-extensions Disable all installed extensions.
--disable-extension <extension-id> Disable an extension.
--sync <on> <off> Turn sync on or off
--inspect-extensions <port> Allow debugging and profiling of extensions. Check the developer tools for the
connection URI.
--inspect-brk-extensions <port> Allow debugging and profiling of extensions with the extension host being paused
after start. Check the developer tools for the connection URI.
--disable-gpu Disable GPU hardware acceleration.
--max-memory Max memory size for a window (in Mbytes).
From the official documentation:
-r or --reuse-window Forces opening a file or folder in the last active window.
IE, it doesn't launches a new instance of VSC, but opens a new tab in the existing opened instance, if it exists.
I'm trying to use command line arguments for vscode, but it treats those arguments as if it were a directory
steps that are already done:
1- ran Shell Command: Install 'code' command in PATH from vs code
2- machine restarted for PATH to take effect
code command line syntax: code [path] [arguments], in the following case -h refers to help
refer to https://code.visualstudio.com/docs/editor/command-line
e.g.
code -h
gives:
The file /Users/dshamim/-h does not exist.
running "where code" gives:
code () {
if [[ $# = 0 ]]
then
open -a "Visual Studio Code"
else
local argPath="$1"
[[ $1 = /* ]] && argPath="$1" || argPath="$PWD/${1#./}"
open -a "Visual Studio Code" "$argPath"
fi
}
/usr/local/bin/code
/usr/local/bin/code
any one experienced this or how to get the command line arguments to work ? I need to export the list of extensions by code --list-extensions
Looks like you have a function code defined somewhere in your .bashrc (or .zshrc, depending on what shell you are using). It overrides the script /usr/local/bin/code.
The function itself is incorrect. open -a "app name" does not allow to pass arguments to the application and open -a "Visual Studio Code" "$argPath" passes the argument as if it was some location.
You need to find that function and remove it. Then you need to close the window with the CLI and open a new one.
Also, if you just want to pass --list-extensions, you can try doing this
ELECTRON_RUN_AS_NODE=1 /Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron /Applications/Visual\ Studio\ Code.app/Contents/Resources/app/out/cli.js --list-extensions
I am using the following lines in a perl script to open a browser using Selenium. :
my $sel = Test::WWW::Selenium->new( host => "localhost",
port => 4444,
browser => "*firefox",
browser_url => "https://$ARGV[0]/" );
Here in browser => "*firefox", how do i specify a specific firefox Profile that should be opened. I've already tried :
browser => "*firefox C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe -P \"Selenium\" "
and
browser => " C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe -P \"Selenium\" ".
I also tired creating a Firefox shortcut with its target as
C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe -P "Selenium"
and then giving the path of this shortcut as the browser. I havent got anything to work so far.
Am i doing something wrong here. Or is there any other way to accomplish this?
The WWW::Selenium documentation indicates that it uses a different profile to the main firefox profile already:
Automatically launch a new Firefox process using a custom Firefox profile. This profile will be automatically configured to use the Selenium Server as a proxy and to have all annoying prompts ("save your password?" "forms are insecure" "make Firefox your default browser?" disabled.
If you load that profile in your main browser then you can customise the profile (such as accepting self signed certificates).
If you have Firefox already running, you need to add a "--no-remote" option. Without it, Firefox will open a new window for the same browser process.
As Matthew says, WWW::Selenium opens a custom profile when you use the *firefox option
Instead of editting the existing one, I made a new profile, set it up how I wanted it and then copied that into the .jar file in the customProfileDirCUSTFFCHROME folder.
The only tricky bit is that you need to also include the extensions that were originally in the customProfileDirCUSTFFCHROME folder that allows selenium to control firefox.