#!/usr/bin/env python
import signal, time
def handler(signum, time):
print("\nI got a SIGINT, but I am not stopping")
signal.signal(signal.SIGINT, handler)
i = 0
while True:
time.sleep(.1)
print("\r{}".format(i), end="")
i += 1
$ python sigint.py
24^C
I got a SIGINT, but I am not stopping
26^C
I got a SIGINT, but I am not stopping
30^\[1] 39913 quit python sigint.py
# 创建常用命令的缩写
alias ll="ls -lh"
# 能够少输入很多
alias gs="git status"
alias gc="git commit"
alias v="vim"
# 手误打错命令也没关系
alias sl=ls
# 重新定义一些命令行的默认行为
alias mv="mv -i" # -i prompts before overwrite
alias mkdir="mkdir -p" # -p make parent dirs as needed
alias df="df -h" # -h prints human readable format
# 别名可以组合使用
alias la="ls -A"
alias lla="la -l"
# 在忽略某个别名
\ls
# 或者禁用别名
unalias la
# 获取别名的定义
alias ll
# 会打印 ll='ls -lh'
bash-5.0$ PS1="> "
> exit
if [[ "$(uname)" == "Linux" ]]; then {do_sth}; fi
# 使用和 shell 相关的配置时先检查当前 shell 类型
if [[ "$SHELL" == "zsh" ]]; then {do_sth}; fi
# 针对特定设备进行配置
if [[ "$(hostname)" == "myServer" ]]; then {do_sth}; fi
[include]
path = ~/.gitconfig_local
# Test if ~/.aliases exists and source it
if [ -f ~/.aliases ]; then
source ~/.aliases
fi
ssh foo@bar.mit.edu
ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519
alias my_server="ssh -i ~/.id_ed25519 --port 2222 -L 9999:localhost:8888 foobar@remote_server"
Host vm
User foobar
HostName 172.16.174.141
Port 2222
IdentityFile ~/.ssh/id_ed25519
LocalForward 9999 localhost:8888
# 在配置文件中也可以使用通配符
Host *.mit.edu
User foobar
-a Include process ancestors in the match list. By default, the current pgrep or pkill process and all of its ancestors are excluded (unless -v is used).
包含匹配列表中的父进程。默认为目前执行 pgrep 或 pkill 命令的进程以及其所有父进程(除非使用了 -v)
-f Match against full argument lists. The default is to match against process names.
匹配所有参数列表。默认只匹配进程名称。
pkill -af sleep
sleep 60 &
pgrep sleep | wait; ls
#!/bin/bash
pidwait()
{
while kill -0 $1
do
sleep 1
done
ls
}
sleep 60 & pidwait $(pgrep sleep 60)
[1] 554
[1] + 554 done sleep 60
pidwait:kill:2: kill 554 failed: no such process
buggy.sh debug_for.sh html_root out.log
debug.sh html.zip marco.sh
alias dc=cd
mkdir ~/dotfiles
git init ~/dotfiles
#!/bin/bash
files="bashrc vimrc "
for file in $files; do
ln -s ~/dotfiles/$file ~/.$file
done
Host vm
User username_goes_here
HostName ip_goes_here
IdentityFile ~/.ssh/id_ed25519
LocalForward 9999 localhost:8888
-N Do not execute a remote command. This is useful for just forwarding ports.
-f Requests ssh to go to background just before command execution. This is useful if ssh is going to ask for passwords or passphrases, but the user wants it in the background. This implies -n. The recommended way to start X11 programs at a remote site is with something like ssh -f host xterm.
If the ExitOnForwardFailure configuration option is set to ``yes'', then a client started with -f will wait for all remote port forwards to be successfully established before placing itself in the background.