---
# System prepended metadata

title: Ubuntu Setup (1)
tags: [dev, ubuntu, setup]

---

Ubuntu Setup (1)
===

###### tags: `ubuntu` `dev` `setup`

---

# ZSH

----

## Current Shell

```shell
$ echo $SHELL
```

----

## Install Zsh

```shell
$ sudo apt install zsh
```

----

## Change Shell

```bash=
$ which zsh
/usr/bin/zsh

# change shell
$ chsh

# restart a new shell
$ echo $SHELL
```

---

# Oh-My-Zsh

----

## Install

```bash=
$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
```

---

# Zsh-Z (Quick Jump to Folder)

----

## Setup

`~/.zshrc`
```shell=
plugins=(
        git
        z
        zsh-autosuggestions
        docker
        dirhistory
)
```


---

# Starship (Cross Shell Prompt)

----

## Install

```shell
$ curl -sS https://starship.rs/install.sh | sudo sh
```

----

## Config

Append lines below to `.zshrc`

```shell
# starship
eval "$(starship init zsh)"
```

----

## Install Font: FiraCode Nerd Font

https://www.nerdfonts.com/font-downloads

Fira Code Regular Nerd Font Complete Mono Windows Compatible.ttf

- WindowsTerminal
    - CMD的設定 => 設定檔 => 預設值 => 外觀 => 字體 => FiraCode NFM
- VS Code
    - 'FiraCode Nerd Font Mono', Consolas, 'Courier New', monospace
    



---

# FZF (Fuzzy Find)

----

## Install

```shell
$ sudo apt update
$ sudo apt install fzf
```

----

## Config

put lines below into `.zshrc`
```shell=
source /usr/share/doc/fzf/examples/key-bindings.zsh
source /usr/share/doc/fzf/examples/completion.zsh
```

----

## 驅動方法
* ** + TAB: 列出與當前位置相關的資訊
* ctrl + t: 同上
* ctrl + r: 列出過去打過的指令
* alt + c: 直接前往選出來的位置

---

# zsh-autosuggestions

----

## Install
```shell=
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
```


## Config

edit your .zshrc
```
plugins=( 
    # other plugins...
    zsh-autosuggestions
)
```
 ---
## 安裝 fnm
* 官方文件:https://github.com/Schniz/fnm
```bash=
$ curl -fsSL https://fnm.vercel.app/install | bash
```

### 安裝 nodejs
```bash=
$ fnm install {版號} // 指定版本
```
* 安裝 nodejs 同時會安裝 npm

### Enable yarn (use corepack)
```bash=
$ corepack enable
```
```bash=
eval "$(fnm env --use-on-cd)"
```

# Bat
## Install
```shell=
sudo apt install bat

ln -s /usr/bin/batcat $HOME/.local/bin/bat

vim ~/.zshrc
export PATH="$PATH:$HOME/.local/bin"
```

# Bat and FZF
```shell=
export FZF_DEFAULT_OPTS="--height 80% --ansi --preview-window 'right:60%' --preview 'bat --color=always --style=numbers,header,grid --line-range=:500 {}'"
```
# Vim-plug
https://blog.csdn.net/weixin_45764245/article/details/126033830

# fzf.vim
https://github.com/junegunn/fzf.vim

# Homebrew
```
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```

# tig
```
brew install tig
```

# ripgrep
```
brew install ripgrep
```