iOS Files app’s copy function won’t copy dot files or folders like .gitignore and .git
pre
you can copy files and folders in the iOS built-in Files app.
issue
But I found it won’t copy the dot files like .gitignore files, .git folders, which will cause some promlems.
For example, I have a git repository Repo_ain another root git repository Repo_A. I have a workflow about checking the Repo_a status and the execute git add --all in it, in the Repo_A I always use git add -u to avoid adding untracked files into the index. However when I copy the Repo_a into Repo_A, then try the workflow, I found the whole untracked files in the Repo_A has been add to the index as the execution results ought to have only work inside the Repo_a, because there is no .git folder in the Repo_a and it’s not recongnised as a git repository due to the copy function in Files app didn’t copy the .git folder.
Solution
So be careful with it, if you want copy the dot files in a folder in the Files app, maybe you could do it after zipping it.
simplify ssh key authorization using ssh-copy-id
Pre
Using ssh to login remote machine is a very common operation, but if you are tierd of being prompted for pass-phrases, you can use authorization key.
Issue
copy your public key under(usually it’s in ~/.ssh/id_rsa.pub), and append it to the target machine’s ~/.ssh/authorized_keys file, then the prompt for pass-phrases won’t block you.
but the operation can be very unconvinient, you have to copy it into your system clipboard and login target first to paste into the file. Especially when you are working on a pure tty, you don’t really have a system-wild clipboard to do the operation between local and the target machine, but you could still use tools like tmux to achieve it, they have a shared clipboard to sync everything across terminals.
Solution
I used to use tmux to do it until I found the ssh-copy-id. it can easily do the copy automatically.
Steps
you can add it to the authorized_keys to avoid being repeatedly prompted for pass-phrasesssh-copy-id root@192.168.199.240
note that you should operate on the current, not the remote target machine.
tip: ssh-copy-id will use default_ID_file, basically it won’t have any problems, but if you have multiple public key files that matches id*.pub in your ~/.ssh/, the key being used may not the one you want, solve it refering to the following:
The default_ID_file is the most recent file that matches:
~/.ssh/id*.pub, (excluding those that match~/.ssh/*-cert.pub) so if you create a key that is not the one you want ssh-copy-id to use, just use touch(1) on your preferred key’s.pubfile to reinstate it as the most recent.
mount files on remote server on MacOS using sshfs
Pre
Sometimes we want mount files on the remote machine to our local. It’s a little bit like webDav, but actually based on another protocol ssh.
Issue
Tried brew install sshfs, indeed there’s a package there, but according to its description, it requires the linux system, which MacOS is not satisfied(though it’s an Unix-like one) the requirement, and actually the installation will fail.
Solution
Searching on the internet, found there is a sshfs from the osxfuse(it’s now macfuse which can let write to the ntfs format harddisk). there is an sshfs in its github repository.
and you could download the package from macFUSEinstead of compiling it yourself.
Steps
- download the package from macFUSE and install it. You need to do the priviledge permission to
sshfsand the restart mac. - mount
1
2mkdir ~/mnt
sshfs root@192.168.1.101: ~/mnt - umountsometimes if encounter an error try
1
umount ~/mnt
1
umount -f ~/mnt
Config right click to paste from system paste board in tmux on MacOS
Pre
if you use powerline on Windows, then you may be familiar with the “right click to paste from system board” feature.
Issue
on Unix-like system, I’d rather tmux in my workflow in which I found right click doesn’t behave like what it does on Windows.
Slolution
Luckily, we could config it.
Steps
1 | # ~/.tmux.conf |
-Tindicates that we only change the keybinding under the rootKey Table(you can check it byprefix+:customize mode)
no need to use the following repository, but found useful tmux config for pasting from system pasteboard here
ref: tmux-MacOSX-pasteboard
cursor style issue in tmux/vim when using archlinux console
pre
when using a tty console on archlinux, we can’t set the cursor style (like underline or block for example) in a intuitive way like in the GUI based OS where we’re allowed to do the tweak by simply change the setting in the console emulator.
luckily we could use the command echo to achieve the goal.
like the following:
1 | echo -e '\e[?6c' |
issue
but when running applications like vim or tmux, the cursor reverts back to being a blinking gray underscore.
solution
after searching I found something on the stackexchange.
Most apps use the cnorm capability to set the cursor back to the “normal” state. By default this is the blinking underline. But you can override this in your terminfo. This should fix most applications (vim, tmux, etc.). Issue
ref: How to change cursor shape, color, and blinkrate of Linux Console?
steps
The following should create ~/.terminfo/l/linux which should be picked up by most of the terminal apps.
the following will generate a file which we can use to modify the ~/.terminfo/l/linux later in the current working directory.
1 | infocmp -A /usr/share/terminfo linux > linux |
according to the following, modify the file.
1 | --- a/linux |
apply the change to the ~/.terminfo/l/linux
1 | tic linux |
install tetris in archlinux tty
Pre
vitetris is a Virtual terminal tetris clone, you could play it in the tty, it even support two palyers at the same time.
in macOS the installation goes fine with homebrew, while the situation is not good at the archlinux.
you can install it using yay which is a package manager based on the AUR(Archlinux User Repository), bucause it’s not included in the official pacman.
Issue
but the sources in the aur has some problem, you may can’t pass the comilation and building.
Solution
searching on the aur, and found the vitetris’s PKGBUILD has some problems blocking build steps.
It seems like printf needs a string format, so I add this line to the end of prepare() in PKGBUILD. It successfully builds with this fix.
sed -i 's|ctime(&t)|"%s", &|' src/netw/gameserver.c
ref: vitetris in aur
so fix it in PKGBUILD, and rebuild it, then install it.
Step
fix the PKGBUILD
fix it in PKGBUILD
1 | # ~/.cache/yay/vitetris |
rebuild & install it.
1 | makepkg -si |
play
run it with vitetris
stuck when try Ctrl-s to i-search command history in GNU Readline
Pre
Sometimes we use Ctrl-s to do a i-search command history when use GNU Readline in some programs like mysql and python.
but when I try it on a linux machine it stuck and freeze the program.
Solution
After searching on the Internet, I found the keystroke Ctrl-s has some special meaning in the linux, it is not the keybind conflict on the term of your shell or GNU Readline, it’s an issue on the term of OS.
how-to-unfreeze-after-accidentally-pressing-ctrl-s-in-a-terminal
This stop/start scheme is software flow control, which is implemented by the OS’s terminal device driver rather than the shell or terminal emulator. It can be configured with the stty command.
To disable it altogether, put stty -ixon in a shell startup script such as ~/.bashrc or ~/.zshrc. To instead just allow any key to get things flowing again, use stty ixany.
Step
with the following setting, it should work.
1 | # ~/.zshrc |
customize keybinding in mysql cli GNU Readline
pre
when use mysql in linux, the keybinding doesn’t behave like what it does in the common zsh.
in zsh, I customize some keybinding, like use C-j/k two move between word.
1 | bindkey "^K" forward-word |
however I found it breaks in the mysql.
and, actually it breaks in many applications, like python cli.
solution
then I found the ~/.inputrc
it will affect all applications that use GNU Readline library.
which mysql cli is of course be affected by this.
1 | vim `~/.inputrc` |
村网通:apple remote
pre
有线音箱连接在PC上,平时想把播放音乐时会使用PC。但是有时候想要切歌或调整音量时,如果并没有在操作pc就不得不专程去手动操作一下,很麻烦。
有没有一个iOS app可以遥控pc端的音乐播放呢。
solution
然后我发现了apple官方的一个app apple remote。
与pc上的itunes配对后,就可以在iOS端实现播放控制:音量调节,切换歌曲,更换编辑歌单等。
pros
- 免费。很多类似的remote app都对此类操作升级收费。
- 播放音乐和手机操作和互不干扰,音源在pc上,没有传输的问题,播放高码率文件时候有优势。
- 不需要额外购置蓝牙音箱,高品质蓝牙音箱价格不菲。
- 只在需要操作的时候发生交互。
- apple自家的产品,交互和功能都很舒适。
cons
- 不如
airplay或蓝牙音箱方便,可以直接播放手机上内容。 - 需要多一台电脑开着。