Return to Bash and PowerShell command correspondence table
Bash
$alias alias name="Command name Argument 1 Argument 2...Argument N"
As an example, I would like to list an alias for tmux.
#Create alias "ton"
$ alias ton='tmux set-window-option synchronize-panes on'
#Create alias "toff"
$ alias toff='clear; tmux set-window-option synchronize-panes off'
By the way, see the URL below for the meanings of these aliases (
ton
andtoff
). Run commands on multiple panes at the same time with tmux [Simultaneous operation of multiple servers with tmux](https://tech.naviplus.co.jp/2014/01/09/tmux%E3%81%A7%E8%A4%87%E6%95%B0%E3 % 82% B5% E3% 83% BC% E3% 83% 90% E3% 81% AE% E5% 90% 8C% E6% 99% 82% E3% 82% AA% E3% 83% 9A% E3% 83 % AC% E3% 83% BC% E3% 82% B7% E3% 83% A7% E3% 83% B3 /)
PowerShell
does not exist </ font>. Create your own alias with arguments.
The format of the self-made alias function with arguments is quite sloppy, and it is written as follows.
powershell:Microsoft.PowerShell_profile.ps1
function alias name() {
Command name Argument 1 Argument 2...Argument N
}
However, it will not be valid as an alias unless it is described in the file Microsoft.PowerShell_profile.ps1
. </ b> </ font>
The location of Microsoft.PowerShell_profile.ps1
is one shot with the following command.
> echo $profile
C:\Users\User name\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
If you don't have WindowsPowerShell \ Microsoft.PowerShell_profile.ps1
under the Documents
folder, you can create your own ** folder </ font>.
As an example, I would like to list an alias that launches Word from PowerShell.
powershell:Microsoft.PowerShell_profile.ps1
#Open word
function word() {
$WORD_PATH = "C:\Program Files\Microsoft Office\root\Office16\WINWORD.EXE"
if ( $args ) {
#If you have a file you want to open
Start-Process $WORD_PATH $args
}
else {
#If you just want to start Word
Start-Process $WORD_PATH
}
}
After creating the alias, load Microsoft.PowerShell_profile.ps1
with. (Dot)
.
$ Profile
isMicrosoft.PowerShell_profile.ps1
! !!
> . $profile # 「.Read with (dot) "
If you can create the alias properly, just execute word
in PowerShell and Word will start.
powershell_aliases.ps1
under the same folder as Microsoft.PowerShell_profile.ps1
.Microsoft.PowerShell_profile.ps1
.> vim $profile
#If you don't have vim, open it with "notepad"! !!
> notepad.exe $profile
Microsoft.PowerShell_profile.ps1
load the alias-only file powershell_aliases.ps1
. powershell:Microsoft.PowerShell_profile.ps1
#Reading an alias-only file
$ALIASES = "C:\Users\User name\Documents\WindowsPowerShell\powershell_aliases.ps1"
. $ALIASES # 「.Read with (dot) "
powershell_aliases.ps1
.> vim "C:\Users\User name\Documents\WindowsPowerShell\powershell_aliases.ps1"
#Or open with notepad
> notepad.exe "C:\Users\User name\Documents\WindowsPowerShell\powershell_aliases.ps1"
Microsoft.PowerShell_profile.ps1
with. (Dot)
to reflect the alias. Microsoft.PowerShell_profile.ps1
instead of powershell_aliases.ps1
.> . $profile # 「.Read with (dot) "
the end.
Recommended Posts