갈루아의 반서재

 


asciinema 는 터미널 세션을 녹화하고 웹상으로 공유할 수 있게 해주는 오픈소스 솔루션이다. 간단히 녹화가 가능하고, 플레이어를 멈추고 터미널 상의 코드를 복사 및 붙여넣기가 가능하다. 손쉽게 블로그 등의 포스팅에 플레이어를 넣을 수도 있다.


Installation

pip 를 이용해 다음과 같이 설치할 수 있다. 

https://pypi.org/project/asciinema/

(cooke) founder@casey:~$ pip install asciinema
Collecting asciinema
  Downloading https://files.pythonhosted.org/packages/a7/71/771c859795e02c71c187546f34f7535487b97425bc1dad1e5f6ad2651357/asciinema-2.0.2.tar.gz
Building wheels for collected packages: asciinema
  Building wheel for asciinema (setup.py) ... done
  Stored in directory: /home/founder/.cache/pip/wheels/a1/0e/6f/eee91a25b1da0134ae37d503142c7e0218e02a93ac42d3672b
Successfully built asciinema
Installing collected packages: asciinema
Successfully installed asciinema-2.0.2

(cooke) founder@casey:~$ pip list
Package              Version
-------------------- --------------------
absl-py              0.7.1
asciinema            2.0.2
astor                0.7.1

 

녹화 및 재생에 앞서 회원가입을 해두면 여러모로 편리하다. 녹화된 영상을 asciinema 사이트에 올려 손쉽게 공유할 수 있다. 회원가입을 해보자. 홈페이지 우측 상단의 Log in/Sign up 메뉴에서 진행한다. 

로그인 후 Settings > Recorder tokens 메뉴에서 다음과 같이 토큰 정보를 연동시킨다.  

(cooke) founder@casey:~$ asciinema auth
Open the following URL in a web browser to link your install ID with your asciinema.org user account:

https://asciinema.org/connect/dhidhikdji-c74f-406f-93a6-ee78799djdu9

This will associate all recordings uploaded from this machine (past and future ones) to your account, and allow you to manage them (change title/theme, delete) at asciinema.org.

등록이 완료되었다. 이후 녹화된 세션은 별도의 인증과정없이 asciinema 사이트에 업로딩된다.


그러면 세션을 녹화해보자. 다음과 같이 asciinema rec 라고 입력해주면 된다. 

(cooke) founder@casey:~$ asciinema rec
asciinema: recording asciicast to /tmp/tmpx0_veydv-ascii.cast
asciinema: press <ctrl-d> or type "exit" when you're done

asciinema rec test.cast 와 같이 파일이름을 지정할 수도 있다.

(cooke) founder@casey:~$ asciinema rec test.cast
asciinema: recording asciicast to test.cast
asciinema: press <ctrl-d> or type "exit" when you're done

녹화를 끝낼 때는 exit 를 타이핑하거나 Ctrl+d 를 누르면 된다. <enter> 를 치면 asciinema.org 사이트에 업로드되고, ctrl+c 를 누르면 로컬에 저장된다.

founder@casey:~/mandart$ exit
asciinema: recording finished
asciinema: press <enter> to upload to asciinema.org, <ctrl-c> to save locally
asciinema: asciicast saved to /tmp/tmpx0_veydv-ascii.cast

앞서와 같이 토큰 정보를 등록해놓은 경우 다음과 같이 <enter>를 치면 바로 업로드된다. 

founder@casey:~/mandart/gutenberg$ exit
asciinema: recording finished
asciinema: press <enter> to upload to asciinema.org, <ctrl-c> to save locally

View the recording at:

    https://asciinema.org/a/3bb8gtyk5zt6WfGmIuD5qV7Uv


손쉽게 블로그 포스팅에 넣을 수도 있다. 아래와 같이 업로드된 상태에서 share 버튼을 누른다.

다음과 같이 링크 공유, 이미지 넣기, 플레이어 넣기 등이 가능하다.


플레이어를 넣은 모습이다.

참고사이트 

https://linuxconfig.org/record-and-replay-terminal-session-with-asciinema-on-linux