aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHsieh Chin Fan <typebrook@gmail.com>2022-04-17 11:20:02 +0800
committerHsieh Chin Fan <typebrook@gmail.com>2022-04-17 11:20:02 +0800
commit0ba215bd0f5f7dd160783e3782d40cbfc249a0fd (patch)
tree4ec7a4366d662dc8b52fa0df2cc52e01ada399b7
parent7554b23b59bfe3b57ba46726b17063c17b052567 (diff)
parent38a86b051449b1004e8e098c8c831ae974e5102b (diff)
Merge remote-tracking branch 'origin/dev' into dev
-rw-r--r--alias18
-rw-r--r--misc/openbox/rc.xml6
-rwxr-xr-xtools/init/sync.sh3
-rwxr-xr-xtools/unix/fdswap41
-rw-r--r--zsh/_wi.sh6
-rw-r--r--zsh/_ww.sh6
6 files changed, 73 insertions, 7 deletions
diff --git a/alias b/alias
index 96c6984..4148b61 100644
--- a/alias
+++ b/alias
@@ -75,10 +75,11 @@ alias ports='sudo lsof -i -Pn | grep LISTEN'
75.() { 75.() {
76 source ${@:-$HOME/.$(basename $SHELL)rc} 76 source ${@:-$HOME/.$(basename $SHELL)rc}
77} 77}
78alias ll='ls -alh' 78alias ll='ls -lh'
79alias lla='ls -lha'
79llw() { which $1 | xargs ls -alh; } 80llw() { which $1 | xargs ls -alh; }
80alias hg='history | grep' 81alias hg='history | grep'
81alias rmrf='[[ `pwd` =~ ^$HOME.* ]] && [[ ! $PATH =~ `pwd` ]] && rm -rf' 82alias rmrf='[[ `pwd` =~ ^$HOME.* ]] && rm -rf'
82alias rr='_move_to_tmp' 83alias rr='_move_to_tmp'
83alias sound="echo -ne '\a'" 84alias sound="echo -ne '\a'"
84alias pst="pstree -ps $$" 85alias pst="pstree -ps $$"
@@ -250,7 +251,7 @@ cdss() {
250# about vimwiki 251# about vimwiki
251alias cdw='cd ~/vimwiki' 252alias cdw='cd ~/vimwiki'
252alias chw='tig -C ~/vimwiki' 253alias chw='tig -C ~/vimwiki'
253alias today='vim ~/vimwiki/diary/`date +'%Y-%m-%d'`.md' 254alias today='vim -c Goyo ~/vimwiki/diary/`date +'%Y-%m-%d'`.md'
254alias to='today' 255alias to='today'
255ww() { entry="${1:-guideline}"; vim ~/vimwiki/${entry%%.md}.md; } 256ww() { entry="${1:-guideline}"; vim ~/vimwiki/${entry%%.md}.md; }
256wg() { grep -r "$@" --exclude-dir=logseq/ ~/vimwiki; } 257wg() { grep -r "$@" --exclude-dir=logseq/ ~/vimwiki; }
@@ -276,14 +277,21 @@ alias df='df -h'
276 277
277# docker 278# docker
278alias dk='docker' 279alias dk='docker'
279alias dps='docker ps'
280alias dis='docker images'
281alias dc='docker-compose' 280alias dc='docker-compose'
281alias dis='docker images'
282alias dps='docker ps'
283alias dpsa='docker ps -a'
282alias drm='docker rm `docker ps -aq`' 284alias drm='docker rm `docker ps -aq`'
285<<<<<<< HEAD
283alias dr='docker run --rm -it' 286alias dr='docker run --rm -it'
284drsh() { docker run --rm -it --entrypoint /bin/sh $@; } 287drsh() { docker run --rm -it --entrypoint /bin/sh $@; }
285drbash() { docker run --rm -it --entrypoint /bin/bash $@; } 288drbash() { docker run --rm -it --entrypoint /bin/bash $@; }
286docker.tags() { curl -s -S "https://registry.hub.docker.com/v2/repositories/$@/tags/" | jq '.results[]["name"]' | sort; } 289docker.tags() { curl -s -S "https://registry.hub.docker.com/v2/repositories/$@/tags/" | jq '.results[]["name"]' | sort; }
290alias drsh='docker run --rm -it --entrypoint /bin/sh $@'
291alias drbash='docker run --rm -it --entrypoint /bin/bash $@'
292docker.tags() {
293 curl -s -S "https://registry.hub.docker.com/v2/repositories/$@/tags/" | jq '.results[]["name"]' | sort
294}
287 295
288# Android 296# Android
289alias debug='./gradlew app:installDebug && adb shell am start -n com.geothings.geobingan/.MainActivity_' 297alias debug='./gradlew app:installDebug && adb shell am start -n com.geothings.geobingan/.MainActivity_'
diff --git a/misc/openbox/rc.xml b/misc/openbox/rc.xml
index 4584121..d0ab52e 100644
--- a/misc/openbox/rc.xml
+++ b/misc/openbox/rc.xml
@@ -930,6 +930,12 @@
930 <y>center</y> 930 <y>center</y>
931 </position> 931 </position>
932 </application> 932 </application>
933 <application title="alacritty">
934 <position force="yes">
935 <x>center</x>
936 <y>center</y>
937 </position>
938 </application>
933 <!-- 939 <!--
934 # this is an example with comments through out. use these to make your 940 # this is an example with comments through out. use these to make your
935 # own rules, but without the comments of course. 941 # own rules, but without the comments of course.
diff --git a/tools/init/sync.sh b/tools/init/sync.sh
index 04af87e..ebed33a 100755
--- a/tools/init/sync.sh
+++ b/tools/init/sync.sh
@@ -1,5 +1,8 @@
1#!/bin/bash 1#!/bin/bash
2 2
3# If git is working in other process, then don't sync again
4! pidof git && exit 0
5
3# my repo 6# my repo
4sync() { 7sync() {
5 { cd $1 && [[ -n $(git remote -v) ]] || return ; } 2>/dev/null 8 { cd $1 && [[ -n $(git remote -v) ]] || return ; } 2>/dev/null
diff --git a/tools/unix/fdswap b/tools/unix/fdswap
new file mode 100755
index 0000000..251cdea
--- /dev/null
+++ b/tools/unix/fdswap
@@ -0,0 +1,41 @@
1#!/bin/bash
2#
3# fdswap
4#
5# Orignal author: ingvarha
6# ref: https://ingvarha.wordpress.com/2010/07/10/changing-a-process-file-descriptor-on-the-fly/
7
8if [ "$2" = "" ]; then
9<<HELP cat
10Usage: ${0##*/} /path/to/oldfile /path/to/newfile [pids]
11Example: ${0##*/} /var/log/daemon.log /var/log/newvolume/daemon.log 1234
12Example: ${0##*/} /dev/pts/53 /dev/null 2345
13HELP
14 exit 0
15fi
16
17if ! gdb --version &>/dev/null; then
18 echo "Unable to find gdb."
19 exit 1
20fi
21
22src="$1"; dst="$2"; shift; shift
23pids=$*
24
25for pid in ${pids:=$( /sbin/fuser $src | cut -d ':' -f 2 )};
26do
27 echo "src=$src, dst=$dst"
28 echo "$src has $pid using it"
29 cmd=$(mktemp)
30 {
31 echo "attach $pid"
32 echo 'call (int)open("'$dst'", 66, 0666)'
33 for ufd in $(LANG=C ls -l /proc/$pid/fd | \
34 grep "$src"\$ | awk ' { print $9; } ');
35 do echo 'call (int)dup2($1,'"$ufd"')'; done
36 echo 'call (int)close($1)'
37 echo 'detach'; echo 'quit'
38 sleep 5
39 } | tee /dev/tty >$cmd
40 gdb -x $cmd
41done
diff --git a/zsh/_wi.sh b/zsh/_wi.sh
index d99518b..f33d0ae 100644
--- a/zsh/_wi.sh
+++ b/zsh/_wi.sh
@@ -1,7 +1,11 @@
1#compdef wi 1#compdef wi
2 2
3function _wi() { 3function _wi() {
4 compadd -S '' $(cd ~/vimwiki && find -not -path "./logseq/*" -name '*.md' -printf "%f\n" | sed -E '/^[0-9]{4}-[0-9]{2}-[0-9]{2}/d') 4 compadd -S '' $(
5 cd ~/vimwiki && \
6 find -not -path "./logseq/*" -name '*.md' -printf "%f\n" | \
7 sed -E '/^[0-9]{4}-[0-9]{2}-[0-9]{2}/d; s/.md$//'
8 )
5} 9}
6 10
7_wi 11_wi
diff --git a/zsh/_ww.sh b/zsh/_ww.sh
index d998099..2a1e323 100644
--- a/zsh/_ww.sh
+++ b/zsh/_ww.sh
@@ -1,7 +1,11 @@
1#compdef ww 1#compdef ww
2 2
3function _ww() { 3function _ww() {
4 compadd -S '' $(cd ~/vimwiki && find -not -path "./logseq/*" -name '*.md' -printf "%f\n" | sed -E '/^[0-9]{4}-[0-9]{2}-[0-9]{2}/d') 4 compadd -S '' $(
5 cd ~/vimwiki && \
6 find -not -path "./logseq/*" -name '*.md' -printf "%f\n" | \
7 sed -E '/^[0-9]{4}-[0-9]{2}-[0-9]{2}/d; s/.md$//'
8 )
5} 9}
6 10
7_ww 11_ww