成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

在Windows系統和Linux系統中,如何打造一個好終端?

開發 前端
在十多年的開發生涯中,筆者熱衷于使用shell。命令永遠不變,筆者可以創建可靠、快捷的自定義快捷方式,但默認值欠佳。閱讀本文將帶你了解如何在系統上獲得很棒的shell +終端。

本文轉載自公眾號“讀芯術”(ID:AI_Discovery)。

在十多年的開發生涯中,筆者熱衷于使用shell。命令永遠不變,筆者可以創建可靠、快捷的自定義快捷方式,但默認值欠佳。閱讀本文將帶你了解如何在系統上獲得很棒的shell +終端。

術語

在Windows系統和Linux系統中,如何打造一個好終端?

shell用于執行命令。終端(terminal)是運行shell的包裝器。在終端上可以設置字體、字體大小、配色方案以及支持多個選項卡。終端仿真器的示例包括GNOME終端、KDE的Konsole,Terminator和XTerm。對于Linux系統,筆者建議保留默認值。Windows適用Windows Terminal;Mac適用iTerm2。

圖源:MartinThoma)

(Linux上的四個終端仿真器(Gnome Terminal、Konsole、XTerm、Terminator)。XTerm不直接支持標簽。其他的打開了2個選項卡。它們都運行Bash shell。

系統的Shell包括ZSH、Bash、fish。Windows系統典型的shell是PowerShell。可以通過執行echo $ 0來查看正在運行的shell。Linux系統使用更多的是Bash shell。

 

在Windows系統和Linux系統中,如何打造一個好終端?

 

 圖源:Martin Thoma

(在Gnome終端中的三個Linux shell(ZSH、Bash、fish),ZSH shell經過了大量更改;Bash shell和fish shell顯示默認值。可見,fish shell具有其他兩個shell缺少的內聯自動提示功能。)

每個shell都有提示符(prompt)。提示符是光標之前寫入的內容。它表示可以輸入指令并提供有用的背景信息。在上面的示例中,提示符包含用戶名moose,當前計算機pc08 ,當前工作目錄 ~/GitHub/MartinThoma/flake8-simplify,活躍git分支feature/19以及進行了±修改的事實。

字體

無論選擇哪個,字體都很重要。你可能想要一個等寬字體,相信我一定要安裝powerline字體。powerline字體能使shell使用像圖像的字符。它可以使提示符效果更好。筆者比較喜歡UbuntuMono和DroidSans Mono:

在Windows系統和Linux系統中,如何打造一個好終端?

上面一行是Ubuntu Mono,下面是Droid Sans Mono。二者都不錯,Ubuntu Mono略勝一籌。| 圖源:Martin Thoma

也有Fira Code、Jetbrains Mono 這樣的“編程字體”。筆者不喜歡它們,因為很難識別所寫內容。

Windows終端

首先確保已安裝Windows終端。啟動終端并找到設置。它是這個指下的“小箭頭”:

在Windows系統和Linux系統中,如何打造一個好終端?

點擊“Settings”。| 圖源:MartinThoma

可以選擇JSON文件隨自己喜好而更改。如下:

  1. // This file was initially generated byWindows Terminal 1.2.2381.0 
  2.           // It should still be usable in newerversions, but newer versions might have additional 
  3.           // settings, help text, or changes thatyou will not see unless you clear this file 
  4.           // and let us generate a new one foryou. 
  5.              // To view thedefault settings, hold "alt" while clicking onthe "Settings" button. 
  6.           // For documentation on thesesettings, see: https://aka.ms/terminal-documentation 
  7.           { 
  8.               "$schema": "https://aka.ms/terminal-profiles-schema", 
  9.                  "defaultProfile": "{2c4de342-38b7-51cf-b940-2309a097f518}", 
  10.              "initialCols":  120, 
  11.              "initialRows":  30, 
  12.                  //Youcanaddmoreglobalapplicationsettingshere. 
  13.              //Tolearnmoreaboutglobalsettings,visithttps://aka.ms/terminal-global-settings 
  14.                  //Ifenabled, selectionsareautomaticallycopiedtoyourclipboard. 
  15.              "copyOnSelect": false, 
  16.                  //Ifenabled,formatteddataisalsocopiedtoyourclipboard 
  17.              "copyFormatting": false, 
  18.                  //Aprofilespecifiesacommandtoexecutepairedwithinformationabouthowitshouldlookandfeel. 
  19.              //Eachoneofthemwillappearinthe NewTab dropdown, 
  20.              //   andcanbeinvokedfromthecommandlinewith`wt.exe-pxxx` 
  21.              //Tolearnmoreaboutprofiles,visithttps://aka.ms/terminal-profile-settings 
  22.              "profiles": 
  23.              { 
  24.                  "defaults": 
  25.                  { 
  26.                       //Putsettingsherethatyouwanttoapplytoallprofiles. 
  27.                  }, 
  28.                  "list": 
  29.                  [ 
  30.                       { 
  31.                           //Makechangesheretothepowershell.exeprofile. 
  32.                           "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", 
  33.                           "name": "WindowsPowerShell", 
  34.                           "commandline": "powershell.exe", 
  35.                           "hidden": false, 
  36.                           "fontFace": "DejaVuSans Mono for Powerline" 
  37.                       }, 
  38.                       { 
  39.                           //Makechangesheretothecmd.exeprofile. 
  40.                           "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}", 
  41.                           "name": "CommandPrompt", 
  42.                           "commandline": "cmd.exe", 
  43.                           "hidden": false 
  44.                       }, 
  45.                       { 
  46.                           "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}", 
  47.                           "hidden": false, 
  48.                           "name": "Ubuntu", 
  49.                           "source": "Windows.Terminal.Wsl", 
  50.                           "fontFace": "DejaVuSans Mono for Powerline", 
  51.                           "colorScheme":  "Solarized Dark", 
  52.                       }, 
  53.                       { 
  54.                           "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}", 
  55.                           "hidden": false, 
  56.                           "name": "AzureCloud Shell", 
  57.                           "source": "Windows.Terminal.Azure" 
  58.                       } 
  59.                  ] 
  60.              }, 
  61.                  //Addcustomcolorschemestothisarray. 
  62.              //Tolearnmoreaboutcolorschemes,visithttps://aka.ms/terminal-color-schemes 
  63.              "schemes": [ 
  64.                               { 
  65.                                   "background":  "#073642", 
  66.                                   "black":  "#073642", 
  67.                                   "blue":  "#268BD2", 
  68.                                   "brightBlack":  "#002B36", 
  69.                                   "brightBlue":  "#839496", 
  70.                                   "brightCyan":  "#93A1A1", 
  71.                                   "brightGreen":  "#586E75", 
  72.                                  "brightPurple":  "#6C71C4", 
  73.                                   "brightRed":  "#CB4B16", 
  74.                                   "brightWhite":  "#FDF6E3", 
  75.                                   "brightYellow":  "#657B83", 
  76.                                   "cyan":  "#2AA198", 
  77.                                   "foreground":  "#FDF6E3", 
  78.                                   "green":  "#859900", 
  79.                                   "name":  "Solarized Dark", 
  80.                                   "purple":  "#D33682", 
  81.                                   "red":  "#D30102", 
  82.                                   "white":  "#EEE8D5", 
  83.                                   "yellow":  "#B58900" 
  84.                               }, 
  85.                               { 
  86.                                   "background":  "#FDF6E3", 
  87.                                   "black":  "#073642", 
  88.                                   "blue":  "#268BD2", 
  89.                                   "brightBlack":  "#002B36", 
  90.                                   "brightBlue":  "#839496", 
  91.                                   "brightCyan":  "#93A1A1", 
  92.                                   "brightGreen":  "#586E75", 
  93.                                   "brightPurple":  "#6C71C4", 
  94.                                   "brightRed":  "#CB4B16", 
  95.                                   "brightWhite":  "#FDF6E3", 
  96.                                   "brightYellow":  "#657B83", 
  97.                                   "cyan":  "#2AA198", 
  98.                                   "foreground":  "#073642", 
  99.                                   "green":  "#859900", 
  100.                                   "name":  "Solarized Light", 
  101.                                   "purple":  "#D33682", 
  102.                                   "red":  "#D30102", 
  103.                                   "white":  "#EEE8D5", 
  104.                                   "yellow":  "#B58900" 
  105.                               }, 
  106.              ], 
  107.                  //Addcustomkeybindingstothisarray. 
  108.              //Tounbindakeycombinationfromyourdefaults.json,setthecommandto"unbound". 
  109.              //Tolearnmoreaboutkeybindings,visithttps://aka.ms/terminal-keybindings 
  110.              "keybindings": 
  111.              [ 
  112.                  //CopyandpasteareboundtoCtrl+Shift+CandCtrl+Shift+Vinyourdefaults.json. 
  113.                  //ThesetwolinesadditionallybindthemtoCtrl+CandCtrl+V. 
  114.                  //Tolearnmoreaboutselection, visithttps://aka.ms/terminal-selection 
  115.                  { "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" }, 
  116.                  { "command": "paste", "keys": "ctrl+v" }, 
  117.     
  118.   
  119.                              //PressCtrl+Shift+Ftoopenthesearchbox 
  120.                  { "command": "find", "keys": "ctrl+shift+f" }, 
  121.     
  122.   
  123.                              //PressAlt+Shift+Dtoopenanewpane. 
  124.                  //-"split":"auto"makesthispaneopeninthedirectionthatprovidesthemostsurfacearea. 
  125.                  //-"splitMode":"duplicate"makesthenewpaneusethefocusedpane sprofile. 
  126.                  //Tolearnmoreaboutpanes, visithttps://aka.ms/terminal-panes 
  127.                  { "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, 
  128.                     "keys": "alt+shift+d" }, 
  129.                  {"command": "closeTab", "keys": "ctrl+w"}, 
  130.                  {"command": "newTab", "keys": "ctrl+t"} 
  131.              ] 
  132.           } 

下載并安裝所有4種“ DejaVu Sans Mono Powerline”字體。在已知的所有系統上,字體安裝都是一個流程:雙擊字體,然后跳出一個有“安裝”按鈕的窗口。

Linux和Windows終端:Aminal

Aminal是用Go語言編寫的終端仿真器。可用于Linux、Windows和Mac。它允許通過配置文件完成顏色、鍵盤快捷鍵等配置。首先需要在系統中安裝并配置Go語言。Ubuntu的示例如下:

  1. $ sudo apt-get install golang libgl1-mesa-dev xorg-dev 
  2. $ export GOPATH="$HOME/go" 
  3. $ export GOBIN=$(go env GOPATH)/bin 

接著就可以安裝并運行aminal了:

  1. $ go get -u github.com/liamg/aminal 
  2. $ aminal 

Linux系統:Gnome終端

可以通過編輯文件來自定義Gnome終端。這里筆者用12號字設置了Ubuntu Mono衍生的powerline常規字體。

在Windows系統和Linux系統中,如何打造一個好終端?

圖源:Martin Thoma

命令是為了zsh而設置,因為這是筆者最喜歡的shell。

在Windows系統和Linux系統中,如何打造一個好終端?

圖源:Martin Thoma

顏色設置為solarized dark(從左到右、從上到下)

  • 背景: #2e3436 / #555753
  • 深紅: #cc0000 / 淺紅: ef2929
  • 深綠: #4e9a06 / 淺綠: #8ae234
  • 深黃: #c4a000 / 淺黃: #fce94f
  • 深藍: #3465a4 / 淺藍: #729fcf
  • 深紫: #75507b / 淺紫: #ad7fa8
  • 深藍綠: #06989a / 淺藍綠: #34e2e2
  • 深灰: #d3d7cf /淺灰: #eeeeec

在Windows系統和Linux系統中,如何打造一個好終端?

Linux系統:fish shell

安裝fish shell:

  1. sudo apt-get install fish 

更改終端仿真器的默認shell為fish。在Gnome終端叫做“自定義命令”

接著安裝“Oh My Fish”:

  1. curl -L https://get.oh-my.fish | fish 

然后將主題設置為agnoster:

  1. omf install agnoster 
  2. omf theme agnoster 

別名

要使終端表現出色,核心部分的命令就要簡短。因此為命令創建一個別名,即簡短版的原命令。最常見是將目錄更改為上一級。假如是在 /home/user/foo/bar中,則要轉到 /home/user/foo。大多數shell都必須輸入cd .. 。我喜歡將其縮寫為 ..。所以別名就是alias ..='cd ..' 。

語法可能不同,具體取決于shell。對于Bash、ZSH和fish:

  1. alias shortlong  

在bash中要插入到 ~/.bashrc,ZSH中則是 ~/.zshrc,fish中也不相同。一些別名如下:

  1. # Shorten things 
  2. alias ..cd ..  
  3. alias ...cd ../../  
  4. alias llls -alF  
  5. alias lals -A  
  6. alias lls -CF  
  7. alias cclear # If your terminal supports colors, use them! 
  8. alias lsls= ls --color=auto  
  9. alias grepgrep= grep --color=auto  
  10. alias fgrepfgrep= fgrep --color=auto  
  11. alias egrepegrep= egrep --color=auto  
  12. alias diffcolordiff # Works only if you have notify-send 
  13. alias alertnotify-send --urgency=low -i "$([ $? = 0 ] && echoterminal || echo error)" "$(history|tail -n1|sed -e   s/^s*[0-9]+s*//;s/[;&|]s*alert$//   )"  

總結一下:

  • 使用不錯的終端仿真器。建議Linux系統使用Gnome終端,Mac系統使用iTerm 2,Windows系統使用Windows終端。
  • 安裝比較好的powerline字體,比如Ubuntu Mono Powerline。
  • 在終端仿真器中按照喜好調整字體、字號以及顏色。
  • 安裝一個好的shell。建議Linux系統使用fish shell,Windows系統使用PowerShell。
  • 按需調整shell的提示符。筆者個人喜歡agnoster主題。

 

責任編輯:趙寧寧 來源: 讀芯術
相關推薦

2021-09-14 12:34:33

LinuxLinux終端

2019-06-19 13:50:21

NeofetchLinux

2017-05-25 11:24:18

達觀數據NER系統

2021-07-19 09:37:59

Windows 操作系統Linux

2016-07-05 15:09:44

2022-07-20 09:38:31

Python語音合成代碼

2021-08-24 16:20:38

Linux終端

2019-11-11 10:45:44

LinuxWindows 10Debian 10

2021-08-11 14:06:43

服務器WindowsLinux

2024-04-01 11:52:46

2012-11-20 09:33:02

2020-09-14 10:50:24

WindowsWSL 2Linux

2009-02-20 19:56:26

WindowsLinux雙系統

2018-11-01 09:45:40

2017-03-15 19:24:29

Windows 10Windows時鐘

2011-03-15 16:07:33

Windows AzuWCF

2021-08-01 08:12:55

Windows 微軟WSL

2023-11-06 14:28:11

Linux海底世界

2022-05-02 18:15:04

KubernetesLinux開源

2018-09-18 09:38:11

RPC遠程調用網絡通信
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 国偷自产av一区二区三区 | 欧美天堂 | 中文字幕 在线观看 | 精品1区2区 | 成在线人视频免费视频 | www.亚洲一区 | 一区二区三区四区电影 | 久久伊人操| 国产精品免费视频一区 | 天天看天天操 | 91婷婷韩国欧美一区二区 | 91丨国产 | 国产亚洲一区二区三区在线观看 | 国产精品1区2区3区 一区中文字幕 | 国产精品视频在线播放 | 狠狠久久| 久久国产高清 | 国产探花在线精品一区二区 | 日本不卡免费新一二三区 | 91久久精品视频 | 久草色视频 | 欧美日韩久久精品 | 久久精品一区二区三区四区 | 综合伊人| 男女精品久久 | 亚洲国产一区在线 | 91免费福利视频 | 日韩在线视频一区 | 蜜桃一区二区三区在线 | 欧美激情视频网站 | 欧美一区二区三区在线观看视频 | www.日韩| 日日夜夜天天 | 久久国产精品久久久久久久久久 | 成人免费在线 | 国产一区二区三区四区 | 欧美一区二区二区 | 精品香蕉一区二区三区 | 欧美在线观看一区 | 免费午夜电影 | 久久久www成人免费精品张筱雨 |