[新软件] atuin 云端同步保持terminal命令的历史

date
Feb 24, 2024
slug
newsoftware-atuin-command-history
status
Published
summary
新软件-
tags
software
type
Post
URL
 
 

Summary

安装过程

Own Server

cat > .env <<EOF
ATUIN_DB_NAME=atuin
ATUIN_DB_USERNAME=atuin
# Choose your own secure password
ATUIN_DB_PASSWORD=Really-insecure
EOF

export DOCKER_PROJ=atuin
export DOCKER_PROJ_DOMAIN=$DOCKER_PROJ.riyu.org

mkdir -p /data/$DOCKER_PROJ
cd /data/$DOCKER_PROJ
mkdir config database

cat > docker-compose.yml <<EOF
version: '3.5'
services:
  atuin:
    restart: always
    #image: ghcr.io/atuinsh/atuin:<LATEST TAGGED RELEASE>
    # https://github.com/atuinsh/atuin/pkgs/container/atuin
    image: ghcr.io/atuinsh/atuin:248213b
    command: server start
    volumes:
      - "./config:/config"
    links:
      - postgresql:db
    #ports:
    #  - 8888:8888
    networks:
      - atuin_network
      - npm_nginx_proxy_manager-network
    environment:
      ATUIN_HOST: "0.0.0.0"
      ATUIN_OPEN_REGISTRATION: "true"
      ATUIN_DB_URI: postgres://$ATUIN_DB_USERNAME:$ATUIN_DB_PASSWORD@db/atuin
      RUST_LOG: info,atuin_server=debug
  postgresql:
    image: postgres:14
    restart: unless-stopped
    volumes: # Don't remove permanent storage for index database files!
      - "./database:/var/lib/postgresql/data/"
    environment:
      POSTGRES_USER: ${ATUIN_DB_USERNAME}
      POSTGRES_PASSWORD: ${ATUIN_DB_PASSWORD}
      POSTGRES_DB: ${ATUIN_DB_NAME}
    networks:
      - atuin_network
networks:
  atuin_network:
  npm_nginx_proxy_manager-network:
    external: true
EOF

docker-compose down; docker-compose up -d; sleep 1s; docker-compose logs -f

Mac https://github.com/atuinsh/atuin?tab=readme-ov-file#install

brew install atuin
echo 'eval "$(atuin init zsh)"' >> ~/.zshrc

# https://docs.atuin.sh/self-hosting/usage/
### restart terminal session

### config
export DOCKER_PROJ=atuin
export DOCKER_PROJ_DOMAIN=$DOCKER_PROJ.xxx.xxx
cat >> ~/.config/atuin/config.toml <<EOF
auto_sync = true
sync_address = "$DOCKER_PROJ_DOMAIN"
sync_frequency = "5m" #10s,20m,1h
EOF


# only do it first time
atuin register -u <USERNAME> -e <EMAIL> -p <PASSWORD>

# get your key
atuin key

# loing from any new machine
atuin login -u <USERNAME> -p <PASSWORD> -k <KEY>
# or just
atuin login -u <USERNAME> 

atuin import auto
# 手动触发同步
atuin sync
# if you see missing data, force a full sync with:
atuin sync -f

# 
atuin logout

Linux

# 不要以root身份运行,如果需要的话,会要求root。
bash <(curl https://raw.githubusercontent.com/ellie/atuin/main/install.sh)
echo 'eval "$(atuin init zsh)"' >> ~/.zshrc

export DOCKER_PROJ=atuin
export DOCKER_PROJ_DOMAIN=$DOCKER_PROJ.xxx.xxx
cat >> ~/.config/atuin/config.toml <<EOF
auto_sync = true
sync_address = "$DOCKER_PROJ_DOMAIN"
sync_frequency = "5m" #10s,20m,1h
EOF

atuin login -u <USERNAME> 
atuin import auto
async sync -f

常见命令

 
# 打开交互式搜索 TUI  
atuin search -i
# 打开预装了查询的交互式搜索 TUI
atuin search -i atuin
# 搜索所有以 cargo 开头且成功退出的命令。
atuin search --exit 0 cargo
# 从当前目录中搜索所有在202141日之前运行且失败的命令。
atuin search --exclude-exit 0 --before 01/04/2021 --cwd .
#搜索所有以 cargo 开头,成功退出且是在昨天下午3点之后运行的命令。
atuin search --exit 0 --after "yesterday 3pm" cargo



键位绑定https://github.com/atuinsh/atuin/blob/main/docs/zh-CN/key-binding.md

notion image

© Ying Bun 2021 - 2024