Darwin/macOS
update bash
brew install bash
echo "/usr/local/bin/bash" >> /etc/shells
ln -s /usr/local/bin/bash /usr/local/bin/sh
# for shebang
#!/usr/bin/env sh
Check battery
# power management
pmset -g batt
Windows
Powershell
# exit with Ctrl+D
Set-PSReadlineKeyHandler -Key ctrl+d -Function ViExit
# echo not necessary
$profile # profile location
$env:OneDrive # print out env variable; case insensative
$env:LESS = "-R" # set env variable in $PROFILE
# set XDG
$Env:XDG_CONFIG_HOME = $Env:APPDATA + "\SomeFolder"
## command env var
%APPDATA% # set to roaming
%LOCALAPPDATA% # Local
Get-Alias # list alias
Set-Alias -Name which -Value Get-Command # set alias
## new line symbols use ^v^M to type
## :%s/^M//g
Scoop
scoop which wget # find out which wget is used
scoop reset wget # reset the command
MSYS2 setup
# shell start up
\path\to\msys2\msys2_shell.cmd
args:
-defterm -here -no-start -msys -use-full-path
# installation script
#!/usr/bin/sh
echo 'export MSYS="winsymlinks:lnk"' >> /etc/profile
pacman -S vim zsh grml-zsh-config tree
ln -s $(which vim) /usr/bin/vi
sed -i "s|db_home:.*$|db_home: /c/Users/$USER|" /etc/nsswitch.conf
sed -i 's/LOGINSHELL=bash/LOGINSHELL=zsh/' /msys2_shell.cmd
getent passwd $(id -u) > /etc/passwd
sed -i "/$USER/s/bash/zsh/" /etc/passwd
getent group $(id -G) > /etc/group
with VS Code
"terminal.integrated.shell.windows": "path//to//msys2//msys2_shell.cmd",
"terminal.integrated.shellArgs.windows": ["-defterm", "-msys", "-no-start", "-here", "-use-full-path"],
enable soft symlink
EDIT /etc/profile
export MSYS="winsymlinks:lnk"
getent passwd $(id -u) > /etc/passwd
getent group $(id -G) > /etc/group
Android with Termux
packages
pkg upgrade
pkg install
pkg search
pkg uninstall
pkg autoclean #Remove outdated .deb files from the cache.
pkg clean #Remove all .deb files from the cache.
pkg files <package> #List files installed by specified package.
pkg list-all #List all available packages.
pkg list-installed #List currently installed packages.
pkg reinstall <package> #Re-install specified package.
pkg search <query> #Search package by query.
pkg show <package> #Show information about specific package.
Set up
# allow storage
termux-setup-storage
# env
$PREFIX # /data/data/com.termux/files/usr
$HOME # /data/data/com.termux/files/home
# install package
pkg install zsh openssh vim git
# change shell
chsh -s zsh
# global config file
$PREFIX/etc/zshrc
back up and restore
# back up
termux-setup-storage
cd /data/data/com.termux/files
tar -zcvf /sdcard/termux-backup.tar.gz home usr
# restore
termux-setup-storage
cd /data/data/com.termux/files
tar -zxf /sdcard/termux-backup.tar.gz --recursive-unlink --preserve-permissions
install Linux Distro
pkg install proot-distro
proot-distro install archlinux
proot-distro login archlinux # login as root
exec proot-distro login --user username archlinux # add to .profile
# change $HOME or edit /etc/passwd
usermod -m -d /new/path/to/home username
## other commands
proot-distro list/remove/reset
## install DE within distro
pacman -Syu xcfe tigervnc # tested: lxde, lxqt, cinnamon, mate
vncpasswd
EDIT .vnc/config
session=xfce
geometry=1600x900
localhost
depth=24
vncserver :1
## [Manual insllation of distro](https://github.com/nmilosev/termux-fedora)
### distro iso file
DISTROIMAGE=https://download.fedoraproject.org/pub/fedora/linux/releases/33/Container/aarch64/images/Fedora-Container-Base-33-1.2.aarch64.tar.xz
mkdir ~/fedora
cd ~/fedora
wget $DISTROIMAGE -O fedora.tar.xz
tar xvf fedora.tar.xz --strip-components=1 --exclude json --exclude VERSION
tar xpf layer.tar
chmod +w .
rm layer.tar
rm fedora.tar.xz
# fix DNS
echo "nameserver 8.8.8.8" > ~/fedora/etc/resolv.conf
# make a shortcut
cat > /data/data/com.termux/files/usr/bin/startfedora <<- EOM
#!/data/data/com.termux/files/usr/bin/bash
unset LD_PRELOAD && proot --link2symlink -0 -r ~/fedora -b /dev/ -b /sys/ -b /proc/ -b /storage/ -b $HOME -w $HOME /bin/env -i HOME=/root TERM="$TERM" PS1='[termux@fedora \W]\$ ' LANG=C.UTF-8 PATH=/bin:/usr/bin:/sbin:/usr/sbin /bin/bash --login
EOM
# uninstall
chmod -R 777 ~/fedora
rm -rf ~/fedora
rm -f $PREFIX/startfedora