d_weechat:
cmpignore:
- '*/weechat_fifo'
- '*/script/plugins.xml.gz'
- '*/logs'
dst: ~/.config/weechat
src: .config/weechat
trans: gpg-single "sec.conf"
trans_write: gpg-single "sec.conf"
# A background process started within a loop may compete with | |
# the loop for stdin, which causes the `while read` loop stop | |
# after the 1st round. | |
cat << EOF >| tasklist.txt | |
1 | |
2 | |
3 | |
EOF | |
# catch empty strings into an array using `read` | |
# normal array assignment isn't able to catch emptry string. | |
unset k 2>/dev/null | |
while IFS=$'\n' read -r item; do k+=("$item"); done < <(printf "\n\n\n") | |
echo ${#k[@]} | |
[[ -z ${k[0]} ]] && echo "empty string is catched" | |
f() { |
The main purpose is to determine whether a command exists in PATH
.
Some of the following methods also support determine the existence
of function
s. The comparison focuses on speed, not support coverage.
❯ export TIMEFMT=$'%U user %S system %P cpu %*E total'
❯ time (for i ({1..100}) if (($+commands[tree])); then echo 1 &>/dev/null; fi)
_env_init() {
# init version manager without rehash on startup
local SHELL_NAME="zsh"
local init_args=(- --no-rehash zsh)
local zshrc="$HOME/.zshrc"
# For security on Linux
[[ -n $XDG_RUNTIME_DIR ]] && local TMPDIR="$XDG_RUNTIME_DIR"
function rsync-up {
if ! (($#)); then
echo "No host is provided" >/dev/stderr
return 1
fi
local host="$1"
local local_dir remote_dir cmd git_conf ignore_conf
# https://git-scm.com/docs/gitignore
By default, ZSH hook chpwd
is not triggered on shell startup. The tutorial here provides some ideas to fix this.
We can use a trick to define a function run only once on precmd
and destruct itself automatically.
function _self_destruct_hook {
local f
for f in ${chpwd_functions}; do
"$f"
Create a base class RedisPipeline
, whichever Pipeline inherits it get a redis connection. Access to the redis conn with self.redis_server
.
Dependency: scrapy_redis
.
# defaults.py
REDIS_ENCODING = "utf-8"
REDIS_FAILED_URLS_KEY = "%(spidername)s:failed_urls"
The post was created for the question [How to share config between vim and Neovim][question].
In this solution, we try to symlink ~/.config/nvim
to ~/.vim
, and make the conf compatible with vim
.
# nvim conf dir: ~/.config/nvim
# vim conf dir: ~/.vim
# link the 1st as the 2nd with relative links