Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
antSword
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
HuangJunbo
antSword
Commits
12ac8d61
Commit
12ac8d61
authored
Apr 05, 2019
by
Medicean
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(Enhance:Terminal) 新增 PowerShell 模式, 可指定 powershell 作为命令解释器
parent
6d2b0724
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
2 deletions
+43
-2
CHANGELOG.md
CHANGELOG.md
+10
-0
en.js
source/language/en.js
+5
-0
zh.js
source/language/zh.js
+5
-0
index.js
source/modules/terminal/index.js
+23
-2
No files found.
CHANGELOG.md
View file @
12ac8d61
...
...
@@ -17,6 +17,16 @@


*
新增自定义命令
`aspowershell [on|off]`
, 开启/关闭 PowerShell 模式
> 如果`ascmd`命令指定的PowerShell解释器文件名中包函`powershell`关键字, 会自动启用 PowerShell 模式, 如下图:

> 如果指定的 PowerShell 解释器文件名中不包含 `powershell` 关键字, 则需要手动使用该命令,启用 PowerShell 模式。如果关闭了 PowerShell 模式,则会执行出错,如下图:

### 其它
*
修复默认设置保存时导致 bookmarks 清空的问题
...
...
source/language/en.js
View file @
12ac8d61
...
...
@@ -204,6 +204,7 @@ module.exports = {
ashelp
:
`Usage:
ascmd file\t\tExecute the command with file, eg: ascmd /bin/bash
aslistcmd\t\tList available command interpreters
aspowershell [on|off]\t\tEnable/Disable PowerShell mode, eg: aspowershell on
quit\t\tClose terminal
exit\t\tClose terminal
...
...
@@ -214,6 +215,10 @@ Hot Keys:
Ctrl U\t\tClear the current row
`
,
ascmd
:
(
cmd
)
=>
antSword
.
noxss
(
`Will execute the command with
${
cmd
}
.`
),
aspowershell
:
{
on
:
"Powershell mode enabled"
,
off
:
"Powershell mode disabled"
,
},
},
},
filemanager
:
{
...
...
source/language/zh.js
View file @
12ac8d61
...
...
@@ -205,6 +205,7 @@ module.exports = {
ashelp
:
`使用帮助:
ascmd file\t\t指定file来执行命令, eg: ascmd /bin/bash
aslistcmd\t\t列出可使用的命令解释器
aspowershell [on|off]\t\t启用/关闭PowerShell模式, eg: aspowershell on
quit\t\t关闭终端
exit\t\t关闭终端
...
...
@@ -215,6 +216,10 @@ module.exports = {
Ctrl U\t\t清除当前行
`
,
ascmd
:
(
cmd
)
=>
antSword
.
noxss
(
`将使用
${
cmd
}
执行命令.`
),
aspowershell
:
{
on
:
"已启用Powershell模式"
,
off
:
"已关闭Powershell模式"
,
},
},
},
filemanager
:
{
...
...
source/modules/terminal/index.js
View file @
12ac8d61
...
...
@@ -40,7 +40,9 @@ class Terminal {
this
.
term
=
null
;
this
.
cell
=
cell
;
this
.
isWin
=
true
;
this
.
isPowershell
=
false
;
this
.
sessbin
=
null
;
this
.
sess_powershell
=
null
;
this
.
core
=
new
antSword
[
'core'
][
opts
[
'type'
]](
opts
);
this
.
cache
=
new
antSword
[
'CacheManager'
](
this
.
opts
[
'_id'
]);
...
...
@@ -202,6 +204,17 @@ class Terminal {
}
return
;
}
if
(
cmd
.
substr
(
0
,
12
)
===
'aspowershell'
)
{
var
_switch
=
cmd
.
substr
(
12
).
trim
().
toLowerCase
();
if
(
_switch
===
"on"
)
{
self
.
sess_powershell
=
true
;
term
.
echo
(
LANG
[
'ascmd'
][
'aspowershell'
][
"on"
]);
}
else
{
self
.
sess_powershell
=
false
;
term
.
echo
(
LANG
[
'ascmd'
][
'aspowershell'
][
"off"
]);
}
return
;
}
term
.
pause
();
// 是否有缓存
let
cacheTag
=
'command-'
+
new
Buffer
(
this
.
path
+
cmd
).
toString
(
'base64'
);
...
...
@@ -221,6 +234,14 @@ class Terminal {
if
(
self
.
sessbin
!==
null
)
{
_bin
=
self
.
sessbin
;
}
if
(
self
.
isWin
&&
_bin
.
indexOf
(
"powershell"
)
>
-
1
)
{
self
.
isPowershell
=
true
}
else
{
self
.
isPowershell
=
false
}
if
(
self
.
sess_powershell
!==
null
)
{
self
.
isPowershell
=
self
.
sess_powershell
;
}
// 开始执行命令
this
.
core
.
request
(
this
.
core
.
command
.
exec
({
...
...
@@ -272,7 +293,7 @@ class Terminal {
// < 1.0.0 时使用3个参数 completion: (term, value, callback) => {}
completion
:
(
value
,
callback
)
=>
{
callback
([
'ashelp'
,
'ascmd'
,
'aslistcmd'
,
'quit'
,
'exit'
'ashelp'
,
'ascmd'
,
'aslistcmd'
,
'
aspowershell'
,
'
quit'
,
'exit'
].
concat
(
this
.
isWin
?
[
'dir'
,
'whoami'
,
'net'
,
'ipconfig'
,
'netstat'
,
'cls'
,
...
...
@@ -328,7 +349,7 @@ class Terminal {
parseCmd
(
cmd
,
path
)
{
path
=
path
.
replace
(
/
\\\\
/g
,
'
\
\'
).replace(/"/g, '
\\
"').replace(/
\\
/g, '
\\\\
');
return (this.isWin
? `cd /d "
$
{
path
}
"&${cmd}&echo [S]&cd&echo [E]`
?
this.isPowershell? `cd "
$
{
path
}
";${cmd};echo [S];(pwd).path;echo [E]`:
`cd /d "
$
{
path
}
"&${cmd}&echo [S]&cd&echo [E]`
: `cd "
$
{
path
}
";${cmd};echo [S];pwd;echo [E]`
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment