Skip to content

Instantly share code, notes, and snippets.

@bengarrett
Last active August 24, 2016 05:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bengarrett/893b506767af611fa530 to your computer and use it in GitHub Desktop.
Save bengarrett/893b506767af611fa530 to your computer and use it in GitHub Desktop.
A collection of Windows command scripts

A collection of Windows command scripts

These should be placed in c:\terminal\cmd-scripts\

  • ~.cmd - A short-cut to jump into the user's home directory
  • edit.cmd - Edit a document using notepad++ from the command prompt
  • ll.cmd - Emulate the Bash ll alias in command prompt, requires Windows port of ls
  • npml.cmd - List global installed Node.js packages from the command prompt
  • pubid.cmd - Displays your public RSA 2 key in terminal, it assumes you have one created by Putty or ssh
  • remote-server.cmd - Template for a batch file to use SSH client to connect to a remote server
  • perl.cmd - Runs a Perl script from the command prompt using Strawberry Perl Portable edition
  • php.cmd - Runs a PHP script from the command prompt using PHP for Window
::File: c:\terminal\cmd-scripts\edit.cmd
@echo off
@setlocal enableextensions enabledelayedexpansion
set text_editor="C:\Program Files (x86)\Notepad++\notepad++.exe"
%text_editor% %*
endlocal
::File: c:\terminal\cmd-scripts\ll.cmd
@echo off
ls --color -A -G -h -l %*
echo 
::File: c:\terminal\cmd-scripts\npml.cmd
@echo off
echo npm list -g packages
npm list -depth 1 -g
::File: c:\terminal\cmd-scripts\perl.cmd
@echo off
@setlocal enableextensions enabledelayedexpansion
set perl=c:\terminal\perl\portableshell.bat
IF [%1]==[] (
%perl% -v
) ELSE (
%perl% %*
)
endlocal
::File: c:\terminal\cmd-scripts\php.cmd
@echo off
@setlocal enableextensions enabledelayedexpansion
set php=c:\terminal\php\php.exe
IF [%1]==[] (
%php% --version
) ELSE (
%php% %*
)
endlocal
::File: c:\terminal\cmd-scripts\pubid.cmd
@setlocal enableextensions enabledelayedexpansion
@echo off
set id_file=id_rsa.pub
set id_path=%home%\.ssh\
echo Display the content of %id_file% in %id_path%
echo 
if exist {%id_path%%id_file%} (
type %id_path%%id_file%
) else (
echo Oops, %id_file% does not exist in %id_path%
)
echo 
endlocal
:: File: c:\terminal\cmd-scripts\remote-server.cmd
@setlocal enableextensions enabledelayedexpansion
@echo off
set title=Remote server name
set server=example.com
set user=ben
c:\terminal\ansicon\x64\ansicon.exe -p
echo Connecting to %title% server @ %server%
ssh %user%@%server%
endlocal
::File: c:\terminal\cmd-scripts\~.cmd
@echo off
cd /D %userprofile%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment