sublime 調用shell


在 Linux 下做 Flask web 開發時,開始全面學習使用 sublime 這款編輯器。

由於需要在 shell 下執行命令 python run.py runserver ,就必須要能在 sublime 中調出 shell 執行該條指令。

最終通過安裝 sublimerepl 插件解決了問題。

一、安裝SublimeREPL

  1. 調用ctrl+shift+p,輸入:sublimerepl選擇並安裝;(如果找不到這個sublimerepl,后來輸入install package才調出來)
  2. 然后tools –sublimeREPL–Python你會發現打開了一個python的shell窗口,顯然這個並不是我們想要的;
  3. 繼續往下走,選擇好我們要執行的py文件,選擇Tools -> SublimeREPL -> Python -> RUN current file,這時候已經支持輸入了數據了。

二、設置快捷鍵

最后,由於每次運行程序都要執行:Tools -> SublimeREPL -> Python -> RUN current file 菜單有點麻煩,所以現在可以考慮給他創建個快捷鍵。方法如下:

選擇主菜單上perferences – key bindings user 中粘貼如下代碼:

下面的配置將F5設為運行python文件,F6為顯示Python控制台,F7為顯示Shell控制台,直接加入“Preference-key-binding-user”即可。

[ {"keys":["f5"], "caption": "SublimeREPL: Python - RUN current file", "command": "run_existing_window_command", "args": { "id": "repl_python_run", "file": "config/Python/Main.sublime-menu" } },{"keys":["f6"], "caption": "SublimeREPL: Python", "command": "run_existing_window_command", "args": { "id": "repl_python", "file": "config/Python/Main.sublime-menu" } },{"keys":["f7"], "caption": "SublimeREPL: Shell", "command": "run_existing_window_command", "args": { "id": "repl_shell", "file": "config/Shell/Main.sublime-menu" } } ]


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM