sysprog
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Help
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    9
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    --- tags: sysprog --- # 終端機和 Vim 設定 > 教學影片: ==[快快樂樂學 Vim](https://youtu.be/Y3Libi0SEp8)== ## 自訂終端機命令列 每次打開終端機覺得命令列過長? 或者是顏色單調? 其實這些都是可以調整的! 我們可以到 `~/.bashrc` 下設定 `PS1` 這個變數 (Ubuntu 在第 61 或 62 行) * **自訂命令列顯示字串** * `\u`: 使用者帳號名稱 * `\h`: 主機名稱 * `\w`: 目前位置(完整路徑) * `\W`: 目前位置(只有目前目錄名稱) * `[\t]`: 顯示時間 (`hh:mm:ss`), 更多變化請見參考連結 * **文字顏色** 文字的色彩是靠 ANSI escape code 來指定的 `\e[0;34m`: 顏色指定開始控制碼 `\e[0m`: 結束 * `0` 與 `1`: `0` 是正常亮度,`1` 是高亮度 * `30` 到 `37`: `30 + x` 的值為前景色 * `40` 到 `47`: `40 + x` 的值為背景色 ![x 對應的顏色](https://i.imgur.com/smr2UoL.jpg) :::info 記得重新登入或重開機,以載入上述設定,或執行 source 命令 ```shell $ source ~/.bashrc ``` ::: 改完後不但有美美的顏色,也不會顯示一長串的路徑。 要完整路徑就下 `$pwd` 吧 =w= ![image](https://hackmd.io/_uploads/H1uOIjkoa.png) 延伸閱讀: * [自訂 Linux 的 Bash Shell 命令提示字串 Prompt](https://blog.gtwang.org/linux/how-to-make-a-fancy-and-useful-bash-prompt-in-linux-1/) ## 安裝 Vim `$ sudo apt-get install vim` 幾乎是瞬間 Vim 就裝好啦! ## Vim 設定 :::danger 請在家目錄下,下命令 `$ vim .vimrc` ::: 所有 Vim 的相關設定都在此更改 ### 設定選項 以下列出部分設定,強大的 Vim 還有更多功能可供使用者自行訂定 * `set ai`: - 自動縮排,啟用自動縮排以後,在貼上剪貼簿的資料時排版可能會亂掉,這時可以手動切換至貼上模式 :set paste 再進行貼上 * `syntax on`: 開啟上色模式 * `set background=dark`: 啟用暗色背景模式,字體色調變亮 * `set cursorline`: 啟用行游標提示 * `set enc=utf8`: 文字編碼加入 utf8 * `set hls`: 螢光筆標記關鍵字 * `set number`: 顯示行號 * `map <F4> : set nu!<BAR>set nonu?<CR>`: 按下 F4 可以自由開關行號,複製程式碼時超方便! * `set relativenumber`: 顯示相對行號 * `set ic`: 搜尋不分大小寫 * `set expandtab`: 使用空白取代 Tab * `set tabstop=4`: 控制 Tab 時所需要的空白鍵 (Tab) 字元數,這個例子是用 4 個空白鍵取代 Tab * `set shiftwidth=2`: 自訂縮排所需的空白鍵位元數 參考資訊 * [凍仁的筆記](https://note.drx.tw/2008/01/vimrc-config.html) * [Vim 將 Tab 轉換成 Space](https://blog.wu-boy.com/2010/08/vim-%E5%B0%87-tab-%E8%BD%89%E6%8F%9B%E6%88%90-space/) * [鳥哥的私房菜 vim 程式編輯器](https://linux.vbird.org/linux_basic/centos7/0310vi.php#vi_vim) * [Mapping keys in Vim](https://vim.fandom.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_1)) ### Vim Plugin 網路上有許多工具可以讓工作更有效率! * **plugin manager** plugin 只會愈裝愈多,因此需要一個掌管所有 plugins 的管理者 * [vundle](https://github.com/VundleVim/Vundle.vim) * [Minimalist Vim Plugin Manager](https://github.com/junegunn/vim-plug) 要裝什麼樣的 plugins 就看使用者自己,請參考連結: * [十個必用的 Vim Plugin](https://www.cnblogs.com/UnGeek/p/3318089.html) * [How to Do 90% of What Plugins Do (With Just Vim)](https://youtu.be/XA2WjJbmmoM) * 此講者會進行 Live Demo 跟著做很快就上手 * 連簡報都可用 Vim 展現 ## .vimrc 範例 * 從 `Line1` 到 `Line12` 是使用 [Minimalist Vim Plugin Manager](https://github.com/junegunn/vim-plug) 的設定 * `Line28` 開始設定的是 autocomplete 下拉選單的背景色 ```vim " Specify a directory for plugins (for Neovim: ~/.local/share/nvim/plugged) call plug#begin('~/.vim/plugged') Plug 'Shougo/neocomplcache' Plug 'scrooloose/nerdtree' map <F5> :NERDTreeToggle<CR> call plug#end() let g:neocomplcache_enable_at_startup = 1 let g:neocomplcache_enable_smart_case = 1 inoremap <expr><TAB> pumvisible()?"\<C-n>" : "\<TAB>" syntax on set number set cursorline colorscheme default set bg=dark set tabstop=4 set expandtab set shiftwidth=4 set ai set hlsearch set smartindent map <F4> : set nu!<BAR>set nonu?<CR> " autocomplete dropdown list colorscheme hi Pmenu ctermfg=0 ctermbg=7 hi PmenuSel ctermfg=7 ctermbg=4 ``` ## Vim 也很強大的!! ![image](https://hackmd.io/_uploads/SyMSDskoa.png) ## 管理多終端機視窗工具: ***byobu***+ NERDTree ![image](https://hackmd.io/_uploads/SyjBvoysp.png) 安裝: `$ sudo apt-get install byobu` [byobu](https://www.byobu.org/) 在終端機輸入 byobu,以下是快捷鍵: * `F2` : 新增終端機分頁 * `F3`,`F4` : 在終端機之間切換 * `ctrl`+`F6` : 刪除終端機 * `shift`+`F2` : 新增水平終端機 * `ctrl`+`F2` : 新增垂直終端機 * `shift`+方向鍵 : 切換

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully