termuxã§Nimè¨èªã®ç°å¢æ§ç¯
ã¯ããã«
ããã¯Nim Advent Calendar 2019 25æ¥ç®ã®è¨äºã§ãã
ç®æ¬¡
termuxã¨ã¯
Android
ä¸ã®ä¸ã§æµè¡ã£ã¦ãã¹ããï¼ãã®ä¸ã®Androidã£ã¦ãçµå±ã¯Linuxã®ãã£ã¹ããªãã¥ã¼ã·ã§ã³ã®ä¸ã¤ãªããã§â¦
ã¨ãããã¨ã¯ãç°å¢ãç¨æãã¦ãããã°Linuxã§è¡ããCUIã®æä½ãã¹ããã§ãã§ããâ¦
åºæ¥ãããæ°è»½ã«ã³ã¼ãã®ç·´ç¿ãã§ããã¨ï¼æé«ï¼
ã£ã¦ããã§ãã®ç°å¢ãå®ç¾ãã¦ãããtermuxãç¨ãã¦ãã¹ããã§Nimè¨èªãåããã¦ã¿ããã¨ããããã§ãã
termuxã¨ã¯
termuxã¨ã¯Androiâ ¾ç¨ã®ã¿ã¼ããã«ã¨ãã¥ã¬ã¼ã¿ã¨ãªãã¾ããããããAndroiâ ¾ã®ãã¼ãã¦ã§ã¢ã«å¯¾ããã¢ã¯ã»ã¹ã®å¶éã¨ããç¹æ§ä¸ã管çè 権éãå©ç¨ããã³ãã³ãã®ä½¿ç¨ãã§ããªãããã§ãã
ããã±ã¼ã¸ç®¡çã«ã¯ãpkgã¨ããããã¼ã¸ã£ã¼ãããã¾ããã§ãããpkgã¯aptã®ã©ããã¼ãªã®ã§ãå®éã®ããã±ã¼ã¸ç®¡çããã¼ã¸ã£ã¼ã¯aptã¨ãªãã¾ãï¼ã§ãã®ã§autoremovesçã¯aptã³ãã³ããç¨ãã¦è¡ãã¾ãï¼ãä»ã«ãdpkgãå©ç¨ãããã¨ãå¯è½ã§ãï¼äºææ§ã®åé¡ã§åºæ¬ã¯åããªãï¼ã
ã¾ããè¤éã§ããArchLinuxã®pacmanã«ãããã¨ãã§ãã¾ãã
termuxã®ããã±ã¼ã¸ç®¡çã«é¢ãã¦
ã¡ãªã¿ã«â¦
https://wiki.termux.com/wiki/FAQ#Can_I_do_hacking_with_Termux.3F
ãªãã¨ã³ãã§ãã¡ããã¨ããããï¼
ä»ã«ãã¡ã¤ã³ãã¼ã¸ã®ã¢ããªã³ã®æ¬ãè¦ã¦ãããã°ããããã¨æãã¾ãããAPIã追å ãããã¨ã§Wi-Fiã®æä½ããããã¨ãã§ããããHomeç»é¢ããã·ã§ã«ã¹ã¯ãªããçãå®è¡ãããã¨ã®ã§ããã¦ã£ã¸ã§ãããé ç½®ãããã¨ãå¯è½ãªããã§ãã
ä»ã«ãããããã«ãã£ã¦ã¯ãX11ãå ¥ãã¦ä½¿ç¨ãããã¨ãã§ããã¿ããã§ããã
ã¤ã³ã¹ãã¼ã«æ¹æ³
ãã¼ãã¼ãã¯ããã©ã«ãã®ã ã¨ããã使ãã«ããã®ã§ãHacker's Keyboardããããããã¾ãããã®ãã¼ãã¼ãã使ãã¨ä¿®é£¾ãã¼ãç°¡åã«ä½¿ç¨ã§ãã¾ãã
ã¾ãããã¾ãæ¥æ¬èªã§æã¤ãã¨ã¯ãªãã¨æãã®ã§ãããGoogle æ¥æ¬èªå ¥åã使ãã¨æ¥æ¬èªå ¥åãã§ãã¾ãã
ãã¨ã¯ããã¤ãã¬ã¼ã·ã§ã³ããã£ã¨ããããªãã®ã§ãã¦ã¼ã¶è£å©âãã¤ãã¬ã¼ã·ã§ã³âã¿ããæä½æã®ãã¤ãã¬ã¼ã·ã§ã³
ãOFFã«ãã¦ãããæ¹ãããã§ãã
ã§ã¯ãtermuxæ¬ä½ã®ã¤ã³ã¹ãã¼ã«æ¹æ³ã«ç§»ãã¾ãã
GooglePlay
ã¤ã³ã¹ãã¼ã«å¾ã«ãèªåçã«å種è¨å®ã¯è¡ãããã®ã§èµ·åããã¦ã§ãæ®éã«ä½¿ç¨ãããã¨ãã§ãã¾ãã
èµ·åå¾ã¯ãããªæã
ããããå ±æãã©ã«ãã«ã¯ã¾ã ã¢ã¯ã»ã¹ã§ãã¾ããã
ãã®éã«ãå·¦å´ããå³å´ã«ããªãããã¦ã¿ãã¨ç½ãç»é¢ã£ã½ãã®ãåºã¦ããã¨æãã¾ãã
ããããã»ãã·ã§ã³ã®åå²ã¨ãã¼ãã¼ããé表示ã®éã«ãå度表示ãã¦ããã¾ãã
ã¾ãã¯ãpkgã®ã¢ãããã¼ãçããã¾ãã
pkg update && pkg upgade
ããã«ããããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ããæºåãæ´ãã¾ããã
次ã«ãã¹ãã¬ã¼ã¸ã«ã¢ã¯ã»ã¹ããè¨å®ããã¾ãããã®æä½ã¯ãAndoroid6.0以éã§ãªãã¨ä½¿ç¨ã§ããªãããã§ãã
termux-setup-storage
ãã®å¾ã«ãã¹ãã¬ã¼ã¸ã¢ã¯ã»ã¹è¨±å¯ãæ±ãããã¾ãã
許å¯ãè¡ããls
ã¨æã¤ã¨ã
ã¨ã§ãããã«ãªãã¾ãã
ãã®storage
ã®ä¸ã«ã¯ãå種ã¹ãã¬ã¼ã¸ã¸ã®ã·ã³ããªãã¯ãªã³ã¯ãè²¼ããã¦ãã¾ãã
~/storage/shared
å
±æãã©ã«ã(sdcard)ã¸ã®ã·ã³ããªãã¯ãªã³ã¯
~/storage/downloads
ã·ã¹ãã ãã©ã¦ã¶çãããã¦ã³ãã¼ããããã¼ã¿ãç½®ãã¦ãããã£ã¬ã¯ããª
~/storage/dcim
å
èµã®ã«ã¡ã©ã§æ®å½±ãããã®åççãç½®ããããã£ã¬ã¯ããª
~/storage/pictures
é常ãç»åãã¡ã¤ã«ã管çãã¦ãããã£ã¬ã¯ããª
~/storage/music
é常ãé³æ¥½ãã¡ã¤ã«ãé
ç½®ãã¦ãããã£ã¬ã¯ããª
~/storage/movies
é常ãåç»ãã¡ã¤ã«ãé
ç½®ãã¦ãããã£ã¬ã¯ããª
~/storage/external
å¤é¨ã¹ãã¬ã¼ã¸ã®termuxãã©ã¤ãã¼ããã©ã«ãï¼ç§ã¯å¤é¨ã¹ãã¬ã¼ã¸ã使ç¨ãã¦ããªãã®ã§æªç¢ºèªï¼
ã»ãã®ãã£ã¬ã¯ããªã¯rootåããªãã¨ã¢ã¯ã»ã¹ã¯å³ããã§ãã
storageã«é¢ãã¦
https://wiki.termux.com/wiki/Termux-setup-storage
Nimè¨èªã¨ã¨ãã£ã¿ã®ã¤ã³ã¹ãã¼ã«
ã¾ãã¯Nimè¨èª
pkg install nim
é¢é£ããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ããã®ã§ãªããªãæéããããã¾ãã
nimbleã®ã©ã¤ãã©ãªã®ã¢ãããã¼ã
nimble refresh
ã次ã¯ãã¨ãã£ã¿
Vimã®å ´å
pkg install vim
emacsã®å ´å
pkg install emacs
ä¸å¿nanoã¨ãã£ã¿ããããï¼
pkg install nano
HelloWorld
èªåã¯vimããã³ãã³ããåãããªãã®ã§ãvimã§ç·¨éãã¾ãã
vimã®è¨å®ã¯ãããä¸ã«ãã£ã±ã転ãã£ã¦ããã®ã§å²æãã§ãé·æ¼ãã§ã³ããã§ããã®ã§ãã¡ããã¡ã楽ãªã¯ãã§ãã
ããã¦ä½æ¥ç¨ãã£ã¬ã¯ããªãä½ã£ã¦ãhello.nim
ãä½ã
mkdir work cd work vim hello.nim
echo "hello"
ã¨å ¥åããä¿åå®è¡ããã¨...
nim c -r hello.nim
æåï¼
çµããã«
ä»åã¯ãvimã®ãã©ã°ã¤ã³ã¾ã§å
¥ãããã¨èãã¦ããã®ã§ããããªããªããã¾ããããªãã£ãããä»å¾è¿½è¨ãããã¨ã«ãã¾ã(termuxãåã¤ã³ã¹ãã¼ã«ããã¯ãã«ãªã£ã...)ã
ãããããã§ã§ããã¨ããæ¹ãããããæãã¦ããããã¨å¬ããã§ãã
ç»é¢ã¯çããå
¥åãã¥ããã¨ããæ¬ ç¹ã¯ããã¾ããï¼ã¢ãã¿ã¼ã¨æ¥ç¶ãæºå¸¯ãã¼ãã¼ãç解決æ³ã¯ããã¨æãï¼ã¹ããã§Nimè¨èªã®ç·´ç¿ãã§ããã£ã½ãï¼
ã¨ãã話ã§ããã