V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
ioiioi
V2EX  ›  问与答

请问如何在 powershell 命令中自动加上" | out-host -paging"

  •  
  •   ioiioi · 2015-02-27 16:40:20 +08:00 · 2031 次点击
    这是一个创建于 3347 天前的主题,其中的信息可能已经有所发展或是发生改变。
    能实现linux的alias效果吗?

    比如说
    vim ~/.bashrc
    ...
    alias ls='ls $LS_OPTIONS -ah | more'
    ...
    3 条回复    2016-12-12 15:51:26 +08:00
    ioiioi
        2
    ioiioi  
    OP
       2015-02-27 23:10:20 +08:00
    似乎无法实现,我想将out-host -paging替代成less
    set-alias less "out-host -paging"

    然后
    get-alias | less

    并不成功。

    错误是
    找不到参数名称与"-paging"匹配的参数。

    pS:我接触powershell不过两天。
    leohxj
        3
    leohxj  
       2016-12-12 15:51:26 +08:00
    使用函数定义,比如

    ```
    function cnpm {
    npm $args
    }
    ```
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2715 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 00:31 · PVG 08:31 · LAX 17:31 · JFK 20:31
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.