Change Windows command prompt to show only current folder - windows

Instead of showing
C:\Users\test_user\Documents\Folder\etc
show
\etc
or if possible limit it to a certain number
\Document\Folder\etc

If you check in help prompt /? there are two options that can either show the current drive or full path.
I would suggest to use new line option along with the Drive so that you will get more space to view/type the command using below combination.
prompt $P$_$G
With this you will be able to see the Path in the line above the prompt.

In short, can't see a simple way of doing it.
In order to change the prompt options you can use the prompt command. The configuration you're looking for isn't listed.
The available options can be viewed by
prompt /? in the command window.
https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/prompt.mspx?mfr=true

The following is a simple batch script which can set the prompt to include only the current folder. Note that it does not work on directory names with certain characters such as parenthesis and spaces. I named it cdd.bat.
#echo off
cd %1
for %%i in (%CD%) do set NEWDIR=%%~ni
PROMPT %NEWDIR%$G

Like others pointed out, you can use the command - prompt to set the text that is shown in cmd.
While you cannot dynamically set the path to just the parent folder, you can manually set it using:
prompt {text}
So in your case, you can set it as:
prompt etc\$G
This will result in:
etc\>
$G adds an arrow sign. You can refer the documentation for detailed explanation.

Here is a .ps1 file i use to do this for myself.
<#
FileName: promptPsShort.ps1
To set the prompt to the last folder name in the path:
> function prompt {$l=Get-Location; $p="$l".split("\")[-1]; "PS $p> "}
# works at cmd prompt, BUT NOT DIREECTLY from a .ps1 file.
RESEARCH
1. google: powershell 7 copy text into clipboard
[How to copy text from PowerShell](https://superuser.com/q/302032/236556)
[Set-Clipboard](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/?view=powershell-7)
2. google: powershell escape double quote
[Escaping in PowerShell](http://www.rlmueller.net/PowerShellEscape.htm)
3. google: powershell raw string
[About Quoting Rules](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_quoting_rules?view=powershell-7)
4. Usage example: powershell
PS C:\flutter_beta\flutter\examples\catalog\android\app\src\main> pwd
Path
----
C:\flutter_beta\flutter\examples\catalog\android\app\src\main
PS C:\flutter_beta\flutter\examples\catalog\android\app\src\main> promptPsShort.ps1
Paste the current Clipboard contents into the Powershell Command Line and press Enter.
PS C:\flutter_beta\flutter\examples\catalog\android\app\src\main> function prompt {$l=Get-Location; $p="$l".split("\")[-1]; "PS $p> "}
PS main>
PS main>
PS main>
#>
$shortPromptCmdStr = #'
function prompt {$l=Get-Location; $p="$l".split("\")[-1]; "PS $p> "}
'#
Set-Clipboard -Value $shortPromptCmdStr
write-host "Paste the current Clipboard contents into the Powershell Command Line and press Enter."
Love and peace,
Joe

Related

short path of current directory in cmd windows

I wish there's a way to show a shortened directory path in windows CMD, I searched the internet and found this command:
for %I in (.) do %~nxI
if you enter this command in cmd and press enter it would show the current dir name. suppose I was standing in my desktop it will print:
Desktop
thats enough for me. but not yet, I tried to save this command in a environment system variable then pass that variable to cmd line, but this way it would print the command itself instead of the result.
created a variable named PROMPT then value is:
%username%$s$p$s$d$t$_-$g$s
result is:
my_username full_path_to_current_dir date time newline dash greater_than_mark(>)
Mahdi c:\Users\Mahdi\Desktop 23/02/2020 19:27:38.93
->this is an screenshot of what Ihave: (https://i.stack.imgur.com/Auicf.png)
This is not a feature avaible in the standard prompt.
You potentially could hack it using echo off and doskeys,
but I would instead suggest checking out one of the many alternatives such as cmder or Zoc
Is this what you wanted?
For /F "Tokens=1*Delims=|" %I In (""%UserName%"|"%CD%"") Do #Prompt %~I$s%~nxJ$s$d$t$_-$g$s
Alternatively, if you wanted it setting to a variable, run the prompt command inside another for loop, and capture the output of that with the Set command.

cmd exited with error code 1

I am trying to search a file on remote PC using PSEXEC, however I am getting the above mentioned error.
Can any please suggest any change in the command or some thing else, that can assist in making it work.
Online search suggests that this isn't the issue of PSEXEC, instead is caused by explorer.exe on remote host.
I have added picture of my result. I have tried the command with quotes on file name and without. both have same error.
This command dir exists with code 1 and message "File Not Found".
Because you run cmd with param /c than it return same error code like dir and it is equal 1.
It is correct behaviour.
If you want to find a file, than use command where /r c:\ d.txt. This command was added in Windows 7.
Or use dir /S /P "d.txt" for older OS
Open Registry Editor by pressing windows+r
then type regedit and press enter
now in the search bar paste the below line
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\
If you can see in the picture using the link
Underlined mark is important don't insert any other value in the data of that particular registry.
Here if you filed many registry values then delete all of them except the default one as they are the main reason for the error code 1 shown by the command prompt.
So after removing all of them.
Edit the default registry value and in 'data' insert cmd and save it
Your problem is solved!!
if not then clear the data of the default registry.
It is also easy to use PowerShell and not need psexec.
Invoke-Command HOST01 { & cmd.exe /C dir D:\Users\lit\d.txt }
It should be written in .ps1 scripts with parameter names specified.
Invoke-Command -ComputerName HOST01 -ScriptBlock { & cmd.exe /C dir D:\Users\lit\d.txt }
See also:
help Enable-PSRemoting
help about_Remote
help about_Remote_FAQ

Problems Executing Powershell from .cmd file

I am attempting to run a build task from a .cmd file where Powershell extracts a zip file, which helps bypass a problem with Visual Studio's limit on the number of directory characters. However, I am having problems getting the Powershell command to execute correctly. I've tried a number of variations with the quotations, and I either get a termination error, or the Powershell command outputs as a string with the zip file not extracted. Below is an example of my current .cmd file:
//%1% is a passed in command line argument for the absolute path, e.g. C:\path\to\dir
set Source=%1%directory.zip
set Destination=%1%directory
powershell -Command $pscmd = '{Add-Type -assembly "system.io.compression.filesystem";[io.compression.zipfile]::ExtractToDirectory("%Source%", "%Destination%");}'; Write-Host $pscmd;
I'm very open to a number of variations that can get this to work, provided that this task runs on the command line, uses Powershell, and can be executed from a .cmd file, which is triggered by our app's build process. I'll be happy to provide additional information if needed. Thanks!
This was a strange one. Your code above has some sort of hidden character in it. I took the code and opened it in notepad, saved as ANSI, and when you type it to command line or open it again in a new instance of notepad you can see the error.
Neither add-type nor ExtractToDirectory give output, so I removed your pscmd var.
I would open your existing script, save as ansi as a new file name, delete the original, rename the new one back to the original name.
Here is what I came up with to troubleshoot your script, and it works on my machine.
I named my script L:\util\unzip.cmd
setlocal
//%1% is a passed in command line argument for the absolute path, e.g. C:\path\to\dir
set _Source='%1\directory.zip'
set _Destination='%1\directory'
echo _Source=%_Source%
echo _Destination=%_Destination%
set _c1=Add-Type -assembly system.io.compression.filesystem;
set _c2=[io.compression.zipfile]::ExtractToDirectory(%_Source%, %_Destination%)
echo _c1=%_c1%
echo _c2=%_c2%
set _Command=^& {%_c1% %_c2%};
: to echo, use double quotes or cmd thinks text after & is another command
echo _Command="%_Command%"
pause
powershell -Command "%_Command%"
endlocal
I ran it like this, and it worked: unzip.cmd L:\util
I'll bet this this info, you are good to go.

How do I display a text file content in CMD?

I want to display the content of a text file in a CMD window. In addition, I want to see the new lines that added to file, like tail -f command in Unix.
You can use the more command. For example:
more filename.txt
Take a look at GNU utilities for Win32 or download it:
We can use the 'type' command to see file contents in cmd.
Example -
type abc.txt
More information can be found HERE.
I don't think there is a built-in function for that
xxxx.txt > con
This opens the files in the default text editor in windows...
type xxxx.txt
This displays the file in the current window. Maybe this has params you can use...
There is a similar question here: CMD.EXE batch script to display last 10 lines from a txt file
So there is a "more" command to display a file from the given line, or you can use the GNU Utilities for Win32 what bryanph suggested in his link.
To show content of a file:
type file.txt - cmd
cat file.txt - bash/powershell
You can use the 'more' command to see the content of the file:
more filename.txt
Using a single PowerShell command to retrieve the file ending:
powershell -nologo "& "Get-Content -Wait c:\logFile.log -Tail 10"
It applies to PowerShell 3.0 and newer.
Another option is to create a file called TAIL.CMD with this code:
powershell -nologo "& "Get-Content -Wait %1 -Tail %2"
To do this, you can use Microsoft's more advanced command-line shell called "Windows PowerShell." It should come standard on the latest versions of Windows, but you can download it from Microsoft if you don't already have it installed.
To get the last five lines in the text file simply read the file using Get-Content, then have Select-Object pick out the last five items/lines for you:
Get-Content c:\scripts\test.txt | Select-Object -last 5
Source: Using the Get-Content Cmdlet
You can do that in some methods:
One is the type command: type filename
Another is the more command: more filename
With more you can also do that: type filename | more
The last option is using a for
for /f "usebackq delims=" %%A in (filename) do (echo.%%A)
This will go for each line and display it's content. This is an equivalent of the type command, but it's another method of reading the content.
If you are asking what to use, use the more command as it will make a pause.
If you want it to display the content of the file live, and update when the file is altered, just use this script:
#echo off
:start
cls
type myfile.txt
goto start
That will repeat forever until you close the cmd window.
There is no built in option available with Windows. To constantly monitor logs you can use this free application BareTailPro.
You can get the TAIL utility from the Windows Server 2003 Resource Kit Tools.
Here are additional details -- Tail command for Windows (CMD).
If you want to display for example all .config (or .ini) file name and file content into one doc for user reference (and by this I mean user not knowing shell command i.e. 95% of them), you can try this :
FORFILES /M *myFile.ini /C "cmd /c echo File name : #file >> %temp%\stdout.txt && type #path >> %temp%\stdout.txt && echo. >> %temp%\stdout.txt" | type %temp%\stdout.txt
Explanation :
ForFiles : loop on a directory (and child, etc) each file meeting criteria
able to return the current file name being process (#file)
able to return the full path file being process (#path)
Type : Output the file content
Ps : The last pipe command is pointing the %temp% file and output the aggregate content. If you wish to copy/paste in some documentation, just open the stdout.txt file in textpad.
You can use either more filename.[extension] or type filename.[extension]
tail -3 d:\text_file.txt
tail -1 d:\text_file.txt
I assume this was added to Windows cmd.exe at some point.

Sublime Text from Command Line

I installed Sublime Text and wanted to know how to open rb files in it from the terminal. I saw What is the command to make Sublime Text my core editor? and I see that I can make Sublime my core editor, but I want to be able to type
sublime file.rb
How do I do this in Windows?
Windows Command Prompt
For Windows cmd.exe you could just add the sublime text installation directory to your PATH environment variable, this would allow you to type:
sublime_text file.rb
Personally, I add a doskey (in a .bat file set to autorun with cmd) so I can type subl file.rb:
> doskey subl="C:\Program Files\Sublime Text 2\sublime_text.exe" $*
Cygwin
For the default bash shell add an alias to your ~/.bashrc file, e.g:
$ echo 'alias subl="/cygdrive/c/Program\ Files/Sublime\ Text\ 2/sublime_text.exe"' >> ~/.bashrc
From build 3065 (Release Date: 29 August 2014) onwards Sublime text includes a command line helper, nameley subl.exe. It is at sublime's installation folder: copy it in to a folder included in the system path.
For example, in my case I copied it
from C:\Program Files\Sublime Text 3
to C:\Windows\System32
You may then use in your terminal/console subl as a command to open whatever file, such as in your example:
subl file.rb
Or you may as well modify your system PATH variable to include sublime's instalation folder, but I believe that is much more involved.
I added this to my PowerShell profile:
Set-Alias subl 'c:\Program Files\Sublime Text\subl.exe'
Modify this as needed for Sublime Text 3 (or any future versions).
You also may read about profiles in built-in help:
Get-Help about_Profiles
Another idea would be to include C:\Program Files\Sublime Text 2\ in your PATH, and then run an administrator command prompt:
cd "C:\Program Files\Sublime Text 2\"
mklink sublime.exe sublime_text.exe
That will make a symbolic link with the new name. And now you can use it freely:
sublime hello.txt
Update: After having a chance to use this trick and update Sublime Text 2, I'm happy to say that updating to a new build doesn't affect the symbolic link.
Add the installation folder to windows path and you will be able to open Sublime by typing the name of the executable file, which is by default "subl".
To include the Sublime installation folder in windows path,
Open command prompt and type sysdm.cpl
In Advanced tab, select Environment variables
Under system variables, select variable named "Path" and click Edit.
Add "C:\Program Files\Sublime Text;" to the end of the existing string.
Save the changes and restart command prompt.
I've created subl.bat in C:\Program Files\Sublime Text 2 with contents:
start sublime_text.exe %*
Now that I have C:\Program Files\Sublime Text 2 in PATH, I can simply type 'subl folder' and it works wonderfully without having to add anything to autostart.
I think that is more easy set the Environment variable in Windows.
Then just add a new System variable called SUBLIME_HOME with value "C:\Program Files\Sublime Text 2\" (without quotes) after edit the variable Path adding in the end this value ";%SUBLIME_HOME%" (without quotes).
Restart the git BASH and enjoy, using like this:
$ sublime_text mi-new-file
(where sublime_text is the command)
Note: Also works now for cmd of Windows.
I know this thread is a bit old, but I recently came up with this solution and thought I would share it...
If you use Cygwin, you can create a bash script that will convert the unix pathnames to windows paths and pass them to sublime. Paste the following into a new file:
#!/bin/bash
/cygdrive/c/Program\ Files/Sublime\ Text\ 2/sublime_text.exe `cygpath -w $#` &
Save it in /usr/bin/subl (or wherever you want so long as the location is in your $PATH) and make it executable ($ chmod a+x /usr/bin/subl)
With this script, you can use both UNIX and Windows style paths (/cygdrive/c/ or C:/) because the cygpath utility converts the / and ~ path aliases to their windows equivalents.
Now, you can use $ subl file1.txt file2.md ~/file3.txt to open those files in sublime!
The accepted answer doesn't seem to work, at least for Sublime Text 3 on Windows 7. Copying the file directly into C:\Windows\System32 allows subl to resolve fine from the shell, but when I run it, nothing happens.
I've had more success with a hardlink:
mklink /h c:\windows\system32\subl.exe "c:\Program Files\Sublime Text 3\subl.exe"
With that, subl <file.txt> and subl <directory> both work fine.
I'm trying out ruby on rails in windows and include the PATH C:\Program Files\Sublime Text 2\,then change the name sublime.exe to subl.exe.
worked fine in regular cmd and "command prompt with ruby and rails" cmd
I just ran the Command Prompt program as an Administrator, and executed the following command.
Simple, but works for me.
echo "c:\Program Files\Sublime Text 3\subl.exe" %1 > %systemroot%\system32\subl.bat
Of course, you can call the bat file whatever you want. From then on, as any user you can simply use:
subl myfile.txt
I created a simple batch file (s.bat) in the windows directory to start sublime text
This is the code I put in the batch file to start Sublime Text 2
#start "sublime" "%ProgramW6432%\Sublime Text 2\sublime_text.exe" %*
I call sublime by typing
s
I directly open a file using
s filename.ext
If your using Cmder, you can add the alias to your aliases file, which is located wherever you installed cmder to, then config\aliases
You can then add ( this is for sublime text 3 )
subl="C:\Program Files\Sublime Text 3\sublime_text.exe" $1
From within Cmder, you can then open any directory in sublime via
subl="C:\Program Files\Sublime Text 3\sublime_text.exe" $1
try this:
alias subl='"/c/Program Files/Sublime Text 2/sublime_text.exe"'
make sure that the sublime install which directory.
It will create the alias for sublime then type:
subl file.rb
Going off the most accepted answer, but whose author unfortunately said modifying the PATH is "hard" - it's not at all. It's very easy. I just did it, and you can too!
Here's what to do:
Navigate to your sublime text directory in Windows Explorer and copy the full path from the path bar.
For example, I have a few development tools set up as portable applications in Dropbox, so I copied the path:
C:\Users\username\Dropbox\Programs\Sublime Text Build 3114 x64
Go to Control panel-> System-> Advanced System Settings-> Environment Variables
In the resulting window, navigate to "path" in the bottom window, highlight it and click "Edit".
In the window that appears, click "New", paste in your Sublime Text path, and click "OK".
Now open CMD or Powershell and type subl
Sublime Text window should open. Enjoy!
Note: I noticed someone else answered this in a similar fashion, but used a fixed location for Sublime Text. That may work for some people, but for others the directions will be erroneous. The fact is, the Sublime Text location can be anywhere on the drive, and knowing where it is and copying that particular location is one of the most important parts of assigning the PATH variable.
I wanted to start a new instance of Sublime Text from the command-line.. The following page helped me, even though it only says OSX: http://www.sublimetext.com/docs/3/osx_command_line.html.
So, I use a batch file in my user path to launch 'sublime'. Here is basically what I use (**the batch file contents):
#start "sublime" "%~dp0Sublime Text\sublime_text.exe" --new-window %*
(my batch file %~-dp0 is located one folder above the Sublime Text installation path.)
I know this is an old thread, but I thought I'd add what I was looking for (and found). It might help someone else!
Set the path for sublime:
My computer >> properties >> advanced setting >> environment variables >> path variable >> Add>> C:\Program Files\Sublime Text 3
Just go to directory where sublime is installed and rename sublime_text to sublime.
Open command prompt and type sublime.
You can simply install Notepad Replacer http://www.binaryfortress.com/NotepadReplacer/
what it will do is make sublime your default notepad in Windows and then you can simply use the commands that you generally use to open inbuilt notepad in windows. for example
`//to open test.txt, just type
notepad test.txt
//to open sublime, Type
notepad`
add Sublime's installation folder to your path.
#set PATH=C:\Program Files\Sublime Text 3;%PATH%
or
To set an environment variable permanently in Windows (so that it is available to all the Windows' processes),
start the "Control Panel" ⇒ "System" ⇒ (Vista/7/8) "Advanced system settings" ⇒ Switch to "Advanced" tab ⇒ "Environment variables" ⇒ Choose "System Variables" (for all users) or "User Variables" (for this login user only) ⇒ Choose "Edit" (for modifying an existing variable) or "New" (to create a new variable) ⇒ Enter the variable "Name" and "Value".
in that case prepend C:\Program Files\Sublime Text 3 to the path.
Now, can make a copy of 'sublime_text.exe' as 'sublime.exe'
Then in any command prompt you may be able to run a file.txt file by
C:\Users\MyUsername>sublime filename.txt
In the Environmental variable I added %SUBLIME_HOME% variable to the path variable as well
Then made a symbolic link from my Command terminal
mklink sb sublime_text.exe
create in registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\sublime.exe
update value of default parameter (REG_SZ) to:
C:\Program Files\Sublime Text 2\sublime_text.exe
This powershell allows me to pipe to the edit function (or to use it in the normal way)
function edit
{
param( [Parameter(ValueFromPipeline=$true,Position=0)] $file )
begin { set-alias EDITOR 'W:\tools\sublime_text.bat' }
process { EDITOR $file }
}
here is the sublime_text.bat which for some reason seems necessary (anyone know why?)
START "Sublime Text 2" "C:\Program Files\Sublime Text 2\sublime_text.exe" %*
Hollow every one.
I build a very easy way to do this.
project github page
just download "install.bat"
and right click on install.bat -> click "run as administrator"
If you don't want to change your path you can associate files with sublime. So right click on the file, click properties, then click opens with sublime text.
From the command line:
myFile.py
Will open the file in sublime. I suppose this saves you about five keystrokes.
#echo off
:: File: TextFiles.Starter.DESKTOP-M175NUE.cmd v1.1.0 docs at the end
:: this just an iso-8601 wrapper for windows:
:: src: http://www.cs.tut.fi/~jkorpela/iso8601.html
call GetNiceTime.cmd
:: go the run dir
cd %~dp0z
:: this is the dir containing the batch file
set _MyDir=%CD%
:: look around , set vars
for %%A in (%0) do set _MyDriveLetter=%%~dA
for %%A in (%0) do set _MyPath=%%~pA
for %%A in (%0) do set _MyName=%%~nA
for %%A in (%0) do set _MyEtxtension=%%~xA
:: contains absolute file paths of the files to open like this
set _ListFile=%_MyDir%\%_MyName%.lst
:: example of lines in the list file - take out the ::space
:: C:\Users\ysg\Desktop\TextFiles.Starter.DESKTOP-M175NUE.cmd
:: C:\Users\ysg\Desktop\TextFiles.Starter.DESKTOP-M175NUE.lst
:: set _Program="C:\Program Files\TextPad 8\TextPad.exe"
set _Program="C:\Program Files\Sublime Text 3\sublime_text.exe"
set _
:: DEBUG PAUSE
:: sleep 2
ping -n 2 www.google.com > NUL
:: for each line of the cat file do open
:: for TextPad , obs note the quoting
:: for /f "tokens=*" %%i in ('type "%_ListFile%"') do ^
:: cmd /c "%_Program% "%%i""
:: for sublime, obs note the quoting
for /f "tokens=*" %%i in ('type "%_ListFile%"') do ^
cmd /c "%_Program% -t "%%i""
:: DEBUG PAUSE
:: Purpose:
:: to start a list of non-binary files from a list file on Windows 10
:: Tested on Windows 10, should work on Win7 too
::
:: Requirements:
:: TextPad 8 or Sublime
::
::
:: Usage:
:: copy this file onto your Desktop, list the absolute paths in to the list file
:: change the program name in the _Program if if you want other editor
::
:: VersionHistory:
:: 1.1.0 --- 2017-10-06 09:42:54 --- ysg --- added sublime
:: 1.0.1 --- 2013-04-15 08:19:10 --- ysg --- added - todo-%today%.txt file opening
:: 1.0.0 --- 2012-05-23 09:08:57 --- ysg -- Initial creation
Here is what worked for me in PowerShell:
# CHECK IF YOUR ALIAS FOR SUBLIME TEXT 3 EXISTS
Get-Alias subl
# REMOVE YOUR ALIAS FOR SUBLIME TEXT 3 IF IT EXISTS
# REF 1
Remove-Item alias:subl
# SET YOUR ALIAS FOR SUBLIME TEXT 3
Set-Alias subl -Value "C:\Program Files\Sublime Text 3\sublime_text.exe"
# CREATE A TEST FILE ON YOUR Desktop
# REF 2
echo "Testing`nNew`nFile`n." > $HOME\Desktop\TestFile.txt
# TEST YOUR NEW ALIAS
subl $HOME\Desktop\TestFile.txt
This is the easiest way to set and test the alias. If you want to keep this against your profile try this:
# TO PERMANENTLY KEEP EVERYTIME YOU OPEN POWERSHELL PLEASE ADD TO YOUR PROFILE. BUT FIRST VERIFY YOUR PROFILE `FILE` EXISTS, IF NOT THEN THIS WILL CREATE IT.
# REF 3 & 4
if (!(Test-Path -Path $PROFILE.CurrentUserAllHosts)) {New-Item -ItemType File -Path $PROFILE.CurrentUserAllHosts -Force}
# open powershell PROFILE
ise $PROFILE.CurrentUserAllHosts
# Add the Set-Alias to your file
Set-Alias subl -Value "C:\Program Files\Sublime Text 3\sublime_text.exe"
REF 1 Remove-Alias: https://superuser.com/q/883914/247728
REF 2 Newline: https://stackoverflow.com/a/36738723/1896134
REF 3 https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-5.1
REF 4 https://devblogs.microsoft.com/scripting/understanding-the-six-powershell-profiles/
Operating System (OS): Windows 10 Pro
Windows ONLY: How to open -a “Sublime Text” in windows?
Assuming your Sublime Text 3 was located in the "C:\Program Files\Sublime Text 3" directory
In Git Bash copy paste and run:
echo 'alias subl="/C/Program\ Files/Sublime\ Text\ 3/sublime_text.exe"' >> ~/.bashrc
Close Git Bash and Open it again.
In Git bash type:
subl
go to enviroment and add sublime text folder to system path directory , dont add anything to system 32 directory it's just making a mess ,after that you can type
''' subl mytext.txt ''' in cmd.
Add the installation folder to windows path.
- Click on windows button
- Type advance system settings in search box
- Click on the result (View Advance System Setting)
- Click on the Environment Variable Button at the Bottom right
- Go to System Variable Section Second
- Search for Path
- Click on Path and Click on Edit Button
- Click on New on right sidebar
- Copy the Folder Path of Sublime Text Editor Sample(C:\Program Files\Sublime Text 3)
- Paste on New Line on Environment Variable
- Click on OK on Every Dialog Box
- All Set Now Follow below Steps
Close the CMD if Open or just start new CMD.
Go to your project folder.
Click on the Address line in Windows File Explorer.
Select all and type CMD.
It will open the project folder in CMD.
Then just type subl . //don't forget to add the
dot (.) after (subl) ex (subl .)
All done, it will open the project in sublime text editor.
After trying for a long time, the following steps worked for me.
Create a PowerShell profile
Use the following command:
if (!(Test-Path -Path )) {
New-Item -ItemType File -Path $PROFILE.CurentUserAllHosts -Force
}
Edit the profile
You can open any PowerShell profile in a text editor, such as Notepad.
To open the profile of the current user in the current PowerShell host
application in Notepad, type:
>notepad $PROFILE.CurentUserAllHosts
On notepad, paste the following command in the profile file
Set-Alias subl -Value "C:<the path of the sublime_text.exe on your PC"
To apply the changes, save the profile file, and then restart PowerShell.
Now on Powershell, cd the directory of your choice and type:
subl .
e.g,
$newfile subl .

Resources