zoukankan      html  css  js  c++  java
  • Emacs助力PowerShell

    阅读目录

    1 下载安装Emacs windows版本

    2 下载el文件和配置Emacs加载PowerShell

    3 体验用Emacs来执行和编辑PowerShell脚本

    1 安装Emacs windows版本

    到Emacs官方站点下载(http://www.gnu.org/software/emacs/#Obtaining)最新的适合windows的版本emacs-24.3-bin-i386.zip    

    ~20W$}$2K74UL05}4P22Z]E

    此为绿色软件,解压缩即可使用。我解压的路径为D:Program FilesGreenSoftwares

    2 下载el文件和配置Emacs加载PowerShell

    2.1 下载两个el文件:

    文件名字 作用 下载地址
    Powershell.el 直接交互使用PowerShell命令 http://www.emacswiki.org/emacs/Powershell.el
    PowerShell-Mode.el 对PowerShell文件语法着色 http://www.emacswiki.org/emacs/PowerShell-Mode.el

    2.2 设置Windows下Emacs配置文件路径

    在Windows下,Emacs一般不会自动建立配置文件。因此,在Windows下,Emacs的默认配置文件目录可以在Emacs中通过C-x C-f后键入~,这时你所看到的目录就是Emacs配置文件默认的目录(C:UsersusernameAppDataRoaming.emacs.d,其中username为当前登录计算机的用户名)。

    因此我们将配置文件拷贝到这个目录_emacs(.emacs或_emacs,推荐是_emacs,因为在windows下.emacs是无法建立的)下。

    下面我们通过设置注册表将默认配置文件目录更改为D:Program FilesGreenSoftwaresemacs-24.3\_emacs

    注册表执行文件RegEmacs.reg

    REGEDIT4

    [HKEY_CURRENT_USERSoftwareGNUEmacs]
    "HOME"="D:Program FilesGreenSoftwaresemacs-24.3\_emacs"

    以上代码有点问题,请在执行完后手工创建HOME值类型,并设置对应的路径。

    然后重新启动Emacs(D:Program FilesGreenSoftwaresemacs-24.3in unemacs.exe),系统会自动在_emacs文件夹下生成.emacs.d文件夹和.emacs。

    2.3 拷贝下载的el文件到.emacs.d文件夹下。

    2.4 配置Emacs初始化文件.emacs(D:Program FilesGreenSoftwaresemacs-24.3\_emacs)

    依次添加以下lisp代码

    (put 'dired-find-alternate-file 'disabled nil)
    ;; add the dir to load path
    (add-to-list 'load-path "~/.emacs.d/")

    ;; autoload powershell interactive shell
    (autoload 'powershell "powershell" "Start a interactive shell of PowerShell." t)

    ;; add dir to load path (add-to-list 'load-path "~/.emacs.d/")

    ;; powershell-mode (autoload 'powershell-mode "powershell-mode" "A editing mode for Microsoft PowerShell." t) (add-to-list 'auto-mode-alist '("\.ps1\'" . powershell-mode)) ; PowerShell script

    这样在启动Emacs时,将加载Powershell.el和PowerShell-Mode.el

    3 体验用Emacs来执行和编辑PowerShell脚本

    3.1 执行PowerShell命令

    启动Emacs后,输入M-x powershell来使用Powershell命令。我们来执行简单的命令Get-Host

    image

    输入M-x shell来使用windows shell命令。

    M-x即Ctrl+x键。

    3.2  通过语法着色查看PowerShell脚本

    image

    参考资料:

    http://xahlee.info/powershell/emacs_powershell_mode.html

  • 相关阅读:
    CF258D
    CF662C
    CF1295F
    CF1406E
    CF1270F
    CF1278F
    CF1523E
    CF1554E
    算法第四章上机实践报告
    LCA RMQ+ST表学习笔记
  • 原文地址:https://www.cnblogs.com/mingle/p/PS1_Emacs.html
Copyright © 2011-2022 走看看