-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bashrc
executable file
·1659 lines (1436 loc) · 57.5 KB
/
.bashrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Fig pre block. Keep at the top of this file.
# [[ -f "$HOME/.fig/shell/bashrc.pre.bash" ]] && builtin source "$HOME/.fig/shell/bashrc.pre.bash"
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
# HISTCONTROL=ignoreboth
export HISTCONTROL='ignoredups:erasedups'
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n 1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
export GIT_SSL_NO_VERIFY=1 # 忽略git认证
alias cdqsdk=svnqsdk
svnqsdk(){
local oldpwd=$(pwd)
while ! [ -d .svn ]; do
cd ../
done
[ -d qsdk ] && cd $(pwd)/qsdk
[ -n $1 ] && eval $@
which zoxide 2>&1 > /dev/null && zoxide add $(pwd)
OLDPWD=${oldpwd}
}
# eval "$(lua /home/wangfuli/git/z.lua/z.lua --init bash once enhanced)" # BASH 初始化
alias sourcebash='source ~/.bashrc'
alias sourcetmux='tmux source-file ~/.tmux.conf'
alias tmux_WB_5G03='tmux attach -t WB_5G03'
alias tmux_FAP680M1='tmux attach -t FAP680-M1'
alias resovl='sudo cp /etc/resolv.conf.bak /etc/resolv.conf'
alias makee='make 2>&1 | tee ./makeerror.log | grep error'
alias makew='make 2>&1 | tee ./makewarn.log | grep warning'
alias makes='make -j`nproc` V=1 QUILT=1'
alias makev='make -j1 V=sc'
# make package/kernel/mac80211 clean ==> /logs/package/kernel/mac80211/compile.txt
alias makekconfig='make -j$(nproc) kernel_menuconfig ' # CONFIG_TARGET=subtarget
alias makekclean='cdqsdk; make -j$(nproc) target/linux/clean;' # rm -rf build_dir/target-*/linux-*
alias makek='cdqsdk; make target/linux/compile; make package/kernel/linux/compile'
alias makekv='cdqsdk; make target/linux/compile -j1 V=scw; make package/kernel/linux/compile -j1 V=scw'
# make target/linux/clean V=s # kernel clean
# make target/linux/prepare V=s # kernel prepare
# make target/linux/refresh V=s # kernel refresh
# make target/linux/compile V=s # kernel compile
# make target/linux/install V=s # kernel install
mkpkg (){
local oldpwd=$(pwd)
cdqsdk;
local dir
dir=$(find -L package/ -type d | grep -v 'files\|patches\|src\|hotplug.d\|config\|.svn\|.git' | fzf -0 -1 +m)
[ -n "$dir" ] && { package=$(basename $dir); make package/$package/{clean,compile} "$@";
echo "make package/$package/{clean,compile} $@;"
}
cd "$oldpwd"
}
mkmod (){
local oldpwd=$(pwd)
cdqsdk;
local dir
dir=$(find -L package/kernel/ -maxdepth 1 -type d | fzf -0 -1 +m)
[ -n "$dir" ] && { module=$(basename $dir); make package/kernel/$module/{clean,compile} "$@";
echo "make package/kernel/$module/{clean,compile} $@";
}
cd "$oldpwd"
}
mkqsdk(){ # reduce fzf interactive
local oldpwd=$(pwd)
cdqsdk;
eval "$@"
cd "$oldpwd"
}
mkuser (){
local oldpwd=$(pwd)
cduser;
local dir
dir=$(find -maxdepth 1 -type d | fzf -0 -1 +m)
[ -n "$dir" ] && ( cd $dir; make "$@"; )
echo "$(basename $dir)"
cd "$oldpwd"
}
mkorig(){ # reduce fzf interactive
local oldpwd=$(pwd)
cduser;
eval "cd $1; make"
cd "$oldpwd"
}
makekm() {
local oldpwd=$(pwd)
local module
[ -z "$1" ] && module=$( cdqsdk; ls package/kernel | fzf; ) || module="$1"
[ -d build_dir ] || cdqsdk
eval ${project_mk_arg} ${project_user_mk_arg}
make package/kernel/$module/{clean,compile} -j1 V=scw
echo "make package/kernel/$module/{clean,compile} -j1 V=scw"
cd $oldpwd
}
makevv(){
local output="make.${RANDOM}"
make -j1 V=scw $@ 2>&1 | tee $output
echo "vim $output"
}
gitc(){
[ -d .git ] && return
git config user.name "wangfuli"
git config user.email "[email protected]"
git init
cp /home/wangfuli/git/gitignore/C.gitignore ./.gitignore
git add *
}
# 删除文件末尾128位签名
# dd if=KF_Image bs=1 count=6408390 of=orig
ubin_orig(){
[ "$#" -ne 0 ] && [ -f $1 ] && {
filesize=$(stat -c "%s" $1)
filesize=$((filesize-128))
dd if=$1 bs=1 count=$filesize of=$1.orig
echo "$1.orig is unsign ubin"
} || {
echo "$# specify filename"
}
}
ubin_digital(){
[ "$#" -ne 0 ] && [ -f $1 ] && {
filesize=$(stat -c "%s" $1)
filesize=$((filesize-128))
dd if=$1 bs=1 skip=$filesize count=128 of=$1.digit
echo "$1.digit is signature information(digital signature)"
} || {
echo "$# specify filename"
}
}
ubin_sign(){
which verSignature >/dev/null 2>&1 || { echo "verSignature command is not exist"; return 1; }
[ -f cakey.pem ] || cp /home/wangfuli/versign/cakey.pem .
if [ "$#" -eq 0 ]; then
for fl in ./*.ubin ; do
cp $fl $fl.orig
verSignature sign $fl /home/wangfuli/versign/cakey.pem
done
else
cp $1 $1.orig
verSignature sign $1 /home/wangfuli/versign/cakey.pem
fi
[ -f cakey.pem ] && rm -f cakey.pem
}
ubin_assert(){
which verSignature >/dev/null 2>&1 || { echo "verSignature command is not exist"; return 1; }
[ -f cakey.pem ] || cp /home/wangfuli/versign/cakey.pem .
if [ "$#" -eq 0 ]; then
for fl in ./*.ubin ; do
verSignature verify $fl /home/wangfuli/versign/pubkey.pem
done
else
cp $1 $1.orig
verSignature verify $1 /home/wangfuli/versign/pubkey.pem
fi
[ -f pubkey.pem ] && rm -f pubkey.pem
}
ubin_bin_step=1
alias ubin_dir='mkdir $(date "+%a")$((ubin_bin_step++))_$(date "+ubin_%Y%m%d_%H%M%S")'
ubin_bin(){
local suffix=$(date "+ubin_%Y%m%d_%H%M%S")
local prefix=$(date "+%a")
bindir="${prefix}$((ubin_bin_step++))_${suffix}"
mkdir $bindir
cp KF_Image $bindir
local newbin=$(ls -dlt *Build* | grep '^d' | head -n 1 | awk '{print $NF}')
mv ${newbin}/* $bindir
rmdir ${newbin}
}
put_ubin(){
local oldpwd=$(pwd)
[ -d images ] && {
newdir=$(ls -dlt images/*Build* | grep '^d' | head -n 1 | awk '{print $NF}')
} || {
stat *-Buildx* > /dev/null 2>&1 || { cdproject; [ -d images ] && cd images; }
newdir=$(ls -dlt *Build* | grep '^d' | head -n 1 | awk '{print $NF}')
}
echo "$newdir"/*.ubin
[ "$(uname)" = "Linux" ] && {
put "$newdir"/*.ubin
} || {
cp "$newdir"/*.ubin /ftptmp
}
cd ${oldpwd}
}
put_rbin(){
local oldpwd=$(pwd)
[ -d images ] && {
newdir=$(ls -dlt images/*Build* | grep '^d' | head -n 1 | awk '{print $NF}')
} || {
stat *-Buildx* > /dev/null 2>&1 || { cdproject; [ -d images ] && cd images; }
newdir=$(ls -dlt *Build* | grep '^d' | head -n 1 | awk '{print $NF}')
}
echo "$newdir"/*.rbin
[ "$(uname)" = "Linux" ] && {
put "$newdir"/*.rbin
} || {
cp "$newdir"/*.rbin /ftptmp
}
cd ${oldpwd}
}
put_KF(){
local oldpwd=$(pwd)
[ -d images ] && {
newdir=$(pwd)/images
} || {
stat *-Buildx* > /dev/null 2>&1 || { cdproject; [ -d images ] && cd images; }
newdir=$(pwd)
}
[ "$(uname)" = "Linux" ] && {
put "$newdir"/KF_Image
} || {
cp "$newdir"/KF_Image /ftptmp
}
cd ${oldpwd}
}
put_img(){
local oldpwd=$(pwd)
cdqsdk
[ -d build_dir ] && {
test -f bin/*/openwrt-*-squashfs-root.img && {
echo bin/*/openwrt-*-squashfs-root.img
put bin/*/openwrt-*-squashfs-root.img
}
find bin/targets/ramips/ -name "*.bin" > /dev/null 2>&1 && {
echo bin/targets/ramips/*/*.bin
put bin/targets/ramips/*/*.bin
}
}
[ -d source ] && {
echo source/linux-*/usr/initramfs_data.cpio.lzma
put source/linux-*/usr/initramfs_data.cpio.lzma
}
cd ${oldpwd}
}
# put pkg include executable file
alias put_bin='put_pkg'
put_pkg(){
local oldpwd=$(pwd)
[ -d build_dir ] || { svnqsdk; }
local cdb_var="$1"
[ "$#" = "0" ] && [ -n "$__last_cdb" ] && { cdb_var=$__last_cdb; }
[ -z "$cdb_var" ] && { cd build_dir; return; }
cd build_dir/target-*/${cdb_var}*
put $(file * 2>&1 | grep linked | awk -F ':' '{print $1}')
export __last_cdb="$cdb_var"
export __last_cdp="$cdb_var"
cd ${oldpwd}
}
# put put_opkg file
put_opkg(){
local oldpwd=$(pwd)
[ -d build_dir ] || { svnqsdk; }
cd bin
put $(fzf)
cd ${oldpwd}
}
putx() {
rm -rf /mnt/hgfs/ftptmp/code/*
putc *.c *.h Makefile
}
getx() {
getc *.c *.h Makefile
rm -rf /mnt/hgfs/ftptmp/code/*
}
makeromfs(){
# export CROSS_COMPILE=/opt/buildroot-gcc463/usr/bin/mipsel-linux-
# export CC=${CROSS_COMPILE}gcc
# in subshell; AR..ROMFSINST are not export
(
export AR="/opt/buildroot-gcc463/usr/bin/mipsel-linux-ar"
export CC="/opt/buildroot-gcc463/usr/bin/mipsel-linux-gcc"
export CPP="/opt/buildroot-gcc463/usr/bin/mipsel-linux-cpp"
export LD="/opt/buildroot-gcc463/usr/bin/mipsel-linux-ld"
export RANLIB="/opt/buildroot-gcc463/usr/bin/mipsel-linux-ranlib"
export STRIP="/opt/buildroot-gcc463/usr/bin/mipsel-linux-strip"
current=$(pwd)
export ROMFSDIR="${current%%user*}/romfs"
export ROMFSINST="${current%%user*}/tools/romfs-inst.sh"
make romfs
)
}
alias cdbin='svnbin'
svnbin(){
local oldpwd=$(pwd)
ls -tld *-ZHCN* > /dev/null 2>&1 && {
cd $(ls -tld *-ZHCN* | head -n 1 | awk '{print $NF}')
OLDPWD=${oldpwd}
}
ls -tld ./images/*-ZHCN* > /dev/null 2>&1 && {
cd $(ls -tld ./images/*-ZHCN* | head -n 1 | awk '{print $NF}')
OLDPWD=${oldpwd}
}
which zoxide 2>&1 > /dev/null && zoxide add $(pwd)
}
alias cdromfs=svnromfs
svnromfs(){
local oldpwd=$(pwd)
while ! [ -d .svn ]; do
cd ../
done
[ -d "$(pwd)/source/romfs/" ] && cd $(pwd)/source/romfs/
[ -n $1 ] && eval $@
OLDPWD=${oldpwd}
which zoxide 2>&1 > /dev/null && zoxide add $(pwd)
}
alias cduser=svnuser
svnuser(){
local oldpwd=$(pwd)
while ! [ -d .svn ]; do
cd ../
done
[ -d "$(pwd)/source/user/" ] && cd $(pwd)/source/user/
[ -n $1 ] && eval $@
OLDPWD=${oldpwd}
which zoxide 2>&1 > /dev/null && zoxide add $(pwd)
}
put_user(){
local oldpwd=$(pwd)
while ! [ -d .svn ]; do
cd ../
done
[ -d "$(pwd)/source/user/" ] && cd $(pwd)/source/user/
local pkgdir=$(find -maxdepth 1 -type d | fzf)
[ -n "$pkgdir" ] && (
cd "$pkgdir"
[ -d src ] && cd src
pwd
put $(file * 2>&1 | grep linked | awk -F ':' '{print $1}')
)
cd "$oldpwd"
OLDPWD=${oldpwd}
}
mkuser(){
local oldpwd=$(pwd)
while ! [ -d .svn ]; do
cd ../
done
[ -d "$(pwd)/source/user/" ] && cd $(pwd)/source/user/
local pkgdir=$(find -maxdepth 1 -type d | fzf)
[ -n "$pkgdir" ] && ( cd "$pkgdir"; make clean; make; )
cd "$oldpwd"
OLDPWD=${oldpwd}
}
alias cdproduct=svnproduct
svnproduct(){
local oldpwd=$(pwd)
while ! [ -d .svn ]; do
cd ../
done
product=$(find $(pwd)/product -type d -maxdepth 1 | fzf)
[ -n "$product" ] && cd "$product"
OLDPWD=${oldpwd}
}
alias _cdproduct=_svnproduct
_svnproduct(){
local oldpwd=$(pwd)
while ! [ -d .svn ]; do
cd ../
done
[ -d "$(pwd)/product" ] && cd $(pwd)/product
OLDPWD=${oldpwd}
which zoxide 2>&1 > /dev/null && zoxide add $(pwd)
}
alias cdroot=svnroot
svnroot(){
local oldpwd=$(pwd)
while ! [ -d .svn ]; do
cd ../
done
[ -n $1 ] && eval $@
OLDPWD=${oldpwd}
which zoxide 2>&1 > /dev/null && zoxide add $(pwd)
}
_gitroot() {
git rev-parse --show-toplevel
}
cdgit() {
cd "$(_gitroot)/${1:-}";
[ -n $1 ] && eval $@
which zoxide 2>&1 > /dev/null && zoxide add $(pwd)
}
alias cdqsdk=svnqsdk
svnqsdk(){
local oldpwd=$(pwd)
while ! [ -d .svn ]; do
cd ../
done
[ -d qsdk ] && cd $(pwd)/qsdk
[ -n $1 ] && eval $@
OLDPWD=${oldpwd}
which zoxide 2>&1 > /dev/null && zoxide add $(pwd)
}
alias cdpackage=svnpackage
alias cdpkg=svnpackage
svnpackage(){
local oldpwd=$(pwd)
while ! [ -d .svn ]; do
cd ../
done
[ -d qsdk ] && cd $(pwd)/qsdk
[ -d package ] && cd package
[ -n $1 ] && eval $@
OLDPWD=${oldpwd}
which zoxide 2>&1 > /dev/null && zoxide add $(pwd)
}
alias project='export __project=$(pwd)'
cdproject(){
local oldpwd=$(pwd)
[ -n "$__project" ] && cd ${__project} || {
_cdproduct
local project_var=$(ls -dlt * | grep '^d' | head -n 1 | awk '{print $NF}')
[ -n "project_var" ] && [ -d "$(pwd)/$project_var" ] && {
cd $(pwd)/$project_var;
}
}
which zoxide 2>&1 > /dev/null && zoxide add $(pwd)
OLDPWD=${oldpwd}
which zoxide 2>&1 > /dev/null && zoxide add $(pwd)
}
export project_user_mk_arg= # '-j1 V=s'
mklast() {
local oldpwd=$(pwd)
[ -d build_dir ] || cdqsdk
[ -n "$1" ] && { __last_cdp="$1"; __last_cdb="$1"; }
eval ${project_mk_arg} ${project_user_mk_arg}
[ -n "$__last_cdp" ] && make package/$__last_cdp/{clean,compile}
cd $oldpwd
}
mklastv(){
local oldpwd=$(pwd)
[ -d build_dir ] || cdqsdk;
[ -n "$1" ] && { __last_cdp="$1"; __last_cdb="$1"; }
eval ${project_mk_arg} ${project_user_mk_arg}
[ -n "$__last_cdp" ] && make package/$__last_cdp/{clean,compile} -j1 V=s
cd $oldpwd
}
# s: stdout+stderr (equal to the old V=99) V=99 OPENWRT_VERBOSE:=s
# c: commands (for build systems that suppress commands by default,e.g. kbuild,cmake)
# w: warnings/errors only (equal to the old V=1) V=1 OPENWRT_VERBOSE:=w
mklaste(){
local oldpwd=$(pwd)
[ -d build_dir ] || cdqsdk;
__last_cdp=$1
shift
method=$(echo -e "compile\nprepare\nconfigure\ninstall\nclean\nrefresh\nupdate\ndownload\ncheck\nkernel_menuconfig\nmenuconfig\nclean\ntargetclean\ndirclean\n" | fzf)
if [ "$method" = "kernel_menuconfig" ]; then
make kernel_menuconfig
elif [ "$method" = "menuconfig" ]; then
make menuconfig
elif [ "$method" = "clean" ]; then
make clean
elif [ "$method" = "targetclean" ]; then
make targetclean
elif [ "$method" = "dirclean" ]; then
make dirclean
else
make package/$__last_cdp/$method -j1 V=scw "$@"
fi
cd $oldpwd
}
project_env(){
local makecmd=$(grep PRODUCT_DIR mkall.sh)
makecmd=${makecmd#*PRODUCT_DIR}
makecmd=PRODUCT_DIR${makecmd}
export project_mk_arg=${makecmd}
}
mkall(){
local oldpwd=$(pwd)
[ -f mkall.sh ] && {
project;
[ "$#" = "0" ] && { ./mkall.sh zh; export PRODUCT_DIR=$(basename $(pwd)); project_env; } || { ./mkall.sh $@; export PRODUCT_DIR=$(basename $(pwd)); project_env; };
cd ${oldpwd};
return;
}
[ -n "$__project" ] && [ -d "$__project" ] && [ "${__project%/product}" = "$__project" ] && {
cd ${__project};
[ "$#" = "0" ] && { ./mkall.sh zh; export PRODUCT_DIR=$(basename $(pwd)); project_env; } || { ./mkall.sh $@; export PRODUCT_DIR=$(basename $(pwd)); project_env; };
cd ${oldpwd};
return;
}
_cdproduct
local project_var=$(ls -dlt * | grep '^d' | head -n 1 | awk '{print $NF}');
[ -n "project_var" ] && [ -d "$(pwd)/$project_var" ] && {
cd $(pwd)/$project_var;
project;
[ "$#" = "0" ] && { ./mkall.sh zh; export PRODUCT_DIR=$(basename $(pwd)); project_env; } || { ./mkall.sh $@; export PRODUCT_DIR=$(basename $(pwd)); project_env; };
}
cd ${oldpwd};
}
alias mkall0='mkall zh 0'
md5k(){ # tftp升级
ls KF_Image > /dev/null 2>&1 && {
md5sum KF_Image
}
cdproject;
ls images/KF_Image > /dev/null 2>&1 && {
md5sum images/KF_Image
}
ls /mnt/hgfs/ftptmp/KF_Image > /dev/null 2>&1 && {
md5sum /mnt/hgfs/ftptmp/KF_Image
}
}
md5u(){ # web升级
ls *.ubin > /dev/null 2>&1 && {
md5sum *.ubin
}
ls /mnt/hgfs/ftptmp/*.ubin > /dev/null 2>&1 && {
md5sum /mnt/hgfs/ftptmp/*.ubin
}
}
md5r(){ # 工厂升级
ls *.rbin > /dev/null 2>&1 && {
md5sum *.rbin
}
ls /mnt/hgfs/ftptmp/*.rbin > /dev/null 2>&1 && {
md5sum /mnt/hgfs/ftptmp/*.rbin
}
}
# default cd to last build_dir feeds
cdb(){
local oldpwd=$(pwd)
[ -d build_dir ] || { svnqsdk; }
local cdb_var="$1"
[ "$#" = "0" ] && [ -n "$__last_cdb" ] && { cdb_var=$__last_cdb; }
[ -z "$cdb_var" ] && { cd build_dir; return; }
cd build_dir/target-*/${cdb_var}*
export __last_cdb="$cdb_var"
export __last_cdp="$cdb_var"
eval xsync
which zoxide 2>&1 > /dev/null && zoxide add $(pwd)
OLDPWD=${oldpwd}
}
# default cd to last package feeds
cdp(){
local oldpwd=$(pwd)
[ -d package ] || { svnqsdk; }
local cdp_var="$1"
[ "$#" = "0" ] && [ -n "$__last_cdp" ] && { cdp_var=$__last_cdp; }
[ -z "$cdp_var" ] && { cd package; return; }
cd package
cd $(find -L -maxdepth 4 -type d -name "*$cdp_var*" | head -n 1)
export __last_cdp="$cdp_var"
export __last_cdb="$cdp_var"
[ -d src ] && { cd src; eval xsync; }
which zoxide 2>&1 > /dev/null && zoxide add $(pwd)
OLDPWD=${oldpwd}
}
# jump file/directory base path
cdf() {
local oldpwd=$(pwd)
local oldpwd=$(pwd)
[ -d package ] || { svnqsdk; }
local cdp_var="$1"
[ "$#" = "0" ] && [ -n "$__last_cdp" ] && { cdp_var=$__last_cdp; }
[ -z "$cdp_var" ] && { cd package; return; }
cd package
cd $(find -L -maxdepth 4 -type d -name "*$cdp_var*" | head -n 1)
export __last_cdp="$cdp_var"
export __last_cdb="$cdp_var"
[ -d src ] && { cd src; eval xsync; }
fzfe
which zoxide 2>&1 > /dev/null && zoxide add $(pwd)
OLDPWD=${oldpwd}
}
cdrootfs(){
local oldpwd=$(pwd)
[ -d build_dir ] || { svnqsdk; }
cd build_dir/target-*/linux-*/base-files/ipkg-*/base-files
[ -n $1 ] && eval $@
which zoxide 2>&1 > /dev/null && zoxide add $(pwd)
OLDPWD=${oldpwd}
}
cross_path_arm(){
local oldpwd=$(pwd)
[ -d build_dir ] || cdqsdk
cd staging_dir/toolchain-aarch*/bin/
local cross_path=$(pwd)
cd -
PATH=${cross_path}:${PATH}
export PATH
ls ${cross_path}
cd $oldpwd
}
cross_path_mips(){
local oldpwd=$(pwd)
[ -d build_dir ] || cdqsdk
cd staging_dir/toolchain-mips*/bin/
local cross_path=$(pwd)
cd -
PATH=${cross_path}:${PATH}
export PATH
ls ${cross_path}
cd $oldpwd
}
export PATH=/snap/bin/:${PATH}
export PATH=/home/wangfuli/.vim/bin/:${PATH}
#
# cdp(){
# local t=$(pwd)
# cd $__old_dir
# export __old_dir=${t}
# }
alias cdftp='cd /mnt/hgfs/ftptmp/'
#[c]
indentlen='wc -L $@'
indentwfl(){
dos2unix $@
indent -kr -i4 -ts4 -sob -ss -sc -npsl -pcs -bs --ignore-newlines -l200 -nut -npro -brf -nbbo $@
}
indentyc(){
for f in $@; do
count=$(wc -L $f | awk '{print $1}')
dos2unix $f
sed -i 's/\s*$//g' $f;
indent -kr -i4 -ts4 -sob -ss -sc -npsl -pcs -bs --ignore-newlines -l${count} -nut -npro -brf -nbbo $f
done
}
indentycc(){
indentyc *.c
indentyc *.h
}
alias exptab="perl -pi -e 's/\t/ q( ) x ( 4 - pos() %4 ) /ge' "
alias cppcheckwfl='cppcheck --std=c99 --enable=warning,style -v '
#[bash]
alias shfmt='shfmt -l -w -i 2 -ci'
alias shfmt2='shfmt -l -w -i 2 -ci'
alias shfmt4='shfmt -l -w -i 4 -ci'
# shellcheck
alias tclsh='rlwrap tclsh'
alias lua="rlwrap -Ar -pcyan --always-readline lua"
alias iperl='rlwrap -A -S "iperl> " perl -MData::Printer -wnE '\'' BEGIN { say "HI"; } say eval()//$@'\' # sudo cpan Data::Printer 有返回值回显1
alias vi='vim -u ~/.vimrc-backup'
# ntpdate -s time.nist.gov
alias tt0='tmux select-window -t :=10'
alias tt1='tmux select-window -t :=11'
alias tt2='tmux select-window -t :=12'
alias tt3='tmux select-window -t :=13'
alias tt4='tmux select-window -t :=14'
alias tt5='tmux select-window -t :=15'
alias tt6='tmux select-window -t :=16'
alias tt7='tmux select-window -t :=17'
alias tt8='tmux select-window -t :=18'
alias tt9='tmux select-window -t :=19'
alias tt680='tmux switch -t FAP680-M1'
alias tt5G03='tmux switch -t WB_5G03'
alias tttmp='tmux switch -t tmp'
alias ttplast='tmux last-pane; tmux resize-pane -Z'
alias tpl='tmux last-pane; tmux resize-pane -Z'
alias xsync='pwd > /mnt/hgfs/ftptmp/xsync'
alias eu='pwd > /mnt/hgfs/ftptmp/xsync'
alias psmem10='ps auxf | sort -nr -k 4 | head -n 10'
alias pscpu10='ps auxf | sort -nr -k 3 | head -n 10'
cdvim(){
local oldpwd=$(pwd)
cdroot
[ -d vimwork ] && cd vimwork || cd ${oldpwd}
}
vimdone(){
local oldpwd=$(pwd)
cdroot
[ -d vimwork ] && rm -rf vimwork
cd ${oldpwd}
}
vimwork(){
local oldpwd=$(pwd)
cdroot
[ -d vimwork ] || mkdir vimwork
for dir in $@; do
[ ${dir%/*} = ${dir} ] || {
[ -d ${dir} ] && ln -sf ${dir} vimwork/${dir##*/}
continue
}
if [ -d qsdk/package/system ]; then
cdir=$(find qsdk/package -name "${dir}*" -type d)
[ -d $(pwd)/${cdir} ] && ln -sf $(pwd)/${cdir} vimwork
continue
fi
if [ -d source/user ]; then
[ -d source/user/${dir} ] && ln -sf $(pwd)/source/user/${dir} vimwork
continue
fi
if [ -d package/system ]; then
cdir=$(find package -name "${dir}*" -type d)
[ -d $(pwd)/${cdir} ] && ln -sf $(pwd)/${cdir} vimwork
continue
fi
done
[ -n "$1" ] && { cd ${oldpwd}; return; }
if [ -d qsdk/package/system ]; then
[ -d $(pwd)/qsdk/package/libs/libconfig_data_api ] && ln -sf $(pwd)/qsdk/package/libs/libconfig_data_api vimwork
[ -d $(pwd)/qsdk/package/libs/libdev_op_api ] && ln -sf $(pwd)/qsdk/package/libs/libdev_op_api vimwork
[ -d $(pwd)/qsdk/package/libs/libcomm_api ] && ln -sf $(pwd)/qsdk/package/libs/libcomm_api vimwork
[ -d $(pwd)/qsdk/package/system/checkapp ] && ln -sf $(pwd)/qsdk/package/system/checkapp vimwork
[ -d $(pwd)/qsdk/package/system/configmanage ] && ln -sf $(pwd)/qsdk/package/system/configmanage vimwork
[ -d $(pwd)/qsdk/package/system/timertasket ] && ln -sf $(pwd)/qsdk/package/system/timertasket vimwork
[ -d $(pwd)/qsdk/package/system/xc_acd ] && ln -sf $(pwd)/qsdk/package/system/xc_acd vimwork
[ -d $(pwd)/qsdk/package/system/client-monitor ] && ln -sf $(pwd)/qsdk/package/system/client-monitor vimwork
[ -d $(pwd)/qsdk/package/system/macmanage ] && ln -sf $(pwd)/qsdk/package/system/macmanage vimwork
[ -d $(pwd)/qsdk/package/system/systemconf ] && ln -sf $(pwd)/qsdk/package/system/systemconf vimwork
[ -d $(pwd)/qsdk/package/system/openCAPWAP ] && ln -sf $(pwd)/qsdk/package/system/openCAPWAP vimwork
[ -d $(pwd)/qsdk/package/network/utils/cloud-client ] && ln -sf $(pwd)/qsdk/package/network/utils/cloud-client vimwork
[ -d $(pwd)/qsdk/package/network/utils/cgi-bin ] && ln -sf $(pwd)/qsdk/package/network/utils/cgi-bin vimwork
[ -d $(pwd)/qsdk/package/network/utils/cloud-rzx ] && ln -sf $(pwd)/qsdk/package/network/utils/cloud-rzx vimwork
fi
if [ -d source/user ]; then
[ -d source/user/client-monitor ] && ln -sf $(pwd)/source/user/client-monitor vimwork
[ -d source/user/client_roaming ] && ln -sf $(pwd)/source/user/client_roaming vimwork
[ -d source/user/cloudiot ] && ln -sf $(pwd)/source/user/cloudiot vimwork
[ -d source/user/apmanage ] && ln -sf $(pwd)/source/user/apmanage vimwork
[ -d source/user/cgi-bin ] && ln -sf $(pwd)/source/user/cgi-bin vimwork
[ -d source/user/macaddr ] && ln -sf $(pwd)/source/user/macaddr vimwork
[ -d source/user/uwifi_tools ] && ln -sf $(pwd)/source/user/uwifi_tools vimwork
[ -d source/user/configmanage ] && ln -sf $(pwd)/source/user/configmanage vimwork
[ -d source/user/json-c-0.12.1 ] && ln -sf $(pwd)/source/user/json-c-0.12.1 vimwork
[ -d source/user/libcomm_api ] && ln -sf $(pwd)/source/user/libcomm_api vimwork
[ -d source/user/libconfig_data_api ] && ln -sf $(pwd)/source/user/libconfig_data_api vimwork
[ -d source/user/libdev_op_api ] && ln -sf $(pwd)/source/user/libdev_op_api vimwork
[ -d source/user/systemconf ] && ln -sf $(pwd)/source/user/systemconf vimwork
[ -d source/user/sysupgrade ] && ln -sf $(pwd)/source/user/sysupgrade vimwork
[ -d source/user/openCAPWAP ] && ln -sf $(pwd)/source/user/openCAPWAP vimwork
fi
if [ -d package/system ]; then
[ -d $(pwd)/package/libs/libconfig_data_api ] && ln -sf $(pwd)/qsdk/package/libs/libconfig_data_api vimwork
[ -d $(pwd)/package/libs/libdev_op_api ] && ln -sf $(pwd)/qsdk/package/libs/libdev_op_api vimwork
[ -d $(pwd)/package/libs/libcomm_api ] && ln -sf $(pwd)/qsdk/package/libs/libcomm_api vimwork
[ -d $(pwd)/package/system/checkapp ] && ln -sf $(pwd)/qsdk/package/system/checkapp vimwork
[ -d $(pwd)/package/system/configmanage ] && ln -sf $(pwd)/qsdk/package/system/configmanage vimwork
[ -d $(pwd)/package/system/timertasket ] && ln -sf $(pwd)/qsdk/package/system/timertasket vimwork
[ -d $(pwd)/package/system/xc_acd ] && ln -sf $(pwd)/qsdk/package/system/xc_acd vimwork
[ -d $(pwd)/package/system/client-monitor ] && ln -sf $(pwd)/qsdk/package/system/client-monitor vimwork
[ -d $(pwd)/package/system/macmanage ] && ln -sf $(pwd)/qsdk/package/system/macmanage vimwork
[ -d $(pwd)/package/system/systemconf ] && ln -sf $(pwd)/qsdk/package/system/systemconf vimwork
[ -d $(pwd)/package/system/openCAPWAP ] && ln -sf $(pwd)/qsdk/package/system/openCAPWAP vimwork
[ -d $(pwd)/package/network/utils/cloud-client ] && ln -sf $(pwd)/qsdk/package/network/utils/cloud-client vimwork
[ -d $(pwd)/package/network/utils/cgi-bin ] && ln -sf $(pwd)/qsdk/package/network/utils/cgi-bin vimwork
[ -d $(pwd)/package/network/utils/cloud-rzx ] && ln -sf $(pwd)/qsdk/package/network/utils/cloud-rzx vimwork
fi
cd vimwork
[ -d .git ] || {
git init
# cp /home/wangfuli/git/gitignore/C.gitignore ./.gitignore
git add *
git commit -m "init"
}
cd ${oldpwd}
}
putyc(){
[ -d libconfig_data_api ] || svnuser;
[ -n "$1" ] && dest="/mnt/hgfs/ftptmp/$1" || {
[ -n "$PRODUCT_DIR" ] && dest="/mnt/hgfs/ftptmp/$PRODUCT_DIR" || {
echo "putyc project_name"
}
}
shift
mkdir $dest
[ -d client-monitor ] && cp -r client-monitor $dest > /dev/null 2>&1
[ -d client_roaming ] && cp -r client_roaming $dest > /dev/null 2>&1
[ -d cloudiot ] && cp -r cloudiot $dest > /dev/null 2>&1
[ -d apmanage ] && cp -r apmanage $dest > /dev/null 2>&1
[ -d cgi-bin ] && cp -r cgi-bin $dest > /dev/null 2>&1
[ -d macaddr ] && cp -r macaddr $dest > /dev/null 2>&1
[ -d uwifi_tools ] && cp -r uwifi_tools $dest > /dev/null 2>&1
[ -d configmanage ] && cp -r configmanage $dest > /dev/null 2>&1
[ -d json-c-0.12.1 ] && cp -r json-c-0.12.1 $dest > /dev/null 2>&1
[ -d libcomm_api ] && cp -r libcomm_api $dest > /dev/null 2>&1
[ -d libconfig_data_api ] && cp -r libconfig_data_api $dest > /dev/null 2>&1
[ -d libdev_op_api ] && cp -r libdev_op_api $dest > /dev/null 2>&1
[ -d systemconf ] && cp -r systemconf $dest > /dev/null 2>&1
[ -d sysupgrade ] && cp -r sysupgrade $dest > /dev/null 2>&1
[ -d openCAPWAP ] && cp -r openCAPWAP $dest > /dev/null 2>&1
for app in $@; do
[ -d "$app" ] && cp -r "$app" $dest > /dev/null 2>&1
done
# ( cd /mnt/hgfs/ftptmp/$1; find -name "*.o" | xargs rm -f; find -name "*.so*" | xargs rm -f; find -name ".git" | xargs rm -f; )
}