Last active
May 12, 2019 20:14
-
-
Save panta82/ed6b13ec377016a74cd8ff3f56bc34ba to your computer and use it in GitHub Desktop.
Command line launcher for JetBrains tools on Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal | |
rem // ensure user supplied a filename with a .lnk extension | |
if /i "%~x1" neq ".lnk" ( | |
echo usage: %~nx0 shortcut.lnk | |
goto :EOF | |
) | |
rem // set filename to the fully qualified path + filename | |
set "filename=%~f1" | |
rem // get target | |
for /f "delims=" %%I in ( | |
'wmic path win32_shortcutfile where "name='%filename:\=\\%'" get target /value' | |
) do for /f "delims=" %%# in ("%%~I") do set "%%~#" | |
rem // preserve ampersands | |
setlocal enabledelayedexpansion | |
echo(!target! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# NOTE: This shortcut is for webstorm, but it should be trivial to add command line launchers to other IDE-s (just change path to the Shortcut). | |
# Both these files should be saved in a directory that is in PATH. | |
SHORTCUT_PATH="C:\Users\panta\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\JetBrains Toolbox\WebStorm.lnk" | |
[[ $( uname ) =~ 'MSYS' ]] && MSYS=true || MSYS=false | |
if $MSYS ; then | |
# If we are in MSYS2, call the cmd directly | |
TARGET=$( get-shortcut-target.cmd "$SHORTCUT_PATH" ) | |
else | |
# If we are in WSL, need to wrap the call in cmd.exe | |
TARGET=$( cmd.exe /c get-shortcut-target.cmd "$SHORTCUT_PATH" ) | |
# Convert path to WSL path | |
TARGET=$( wslpath "$TARGET" ) | |
fi | |
# Trim whitespace | |
TARGET="${TARGET#"${TARGET%%[![:space:]]*}"}" | |
TARGET="${TARGET%"${TARGET##*[![:space:]]}"}" | |
"$TARGET" $@ 2>&1 >/dev/null & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment