aboutsummaryrefslogtreecommitdiffhomepage
path: root/alias
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2024-11-08 15:40:31 +0800
committerHsieh Chin Fan <pham@topo.tw>2024-11-08 15:40:31 +0800
commit8943b38084f8e74893998fe877de39f6050f7f20 (patch)
tree914ea3aa7e66e7ef723fb2587c5369f882fcde61 /alias
parent71ca28742ac4f93ab2401eaee8e78471c023cd4b (diff)
Update
Diffstat (limited to 'alias')
-rw-r--r--alias115
1 files changed, 63 insertions, 52 deletions
diff --git a/alias b/alias
index df0a35f..90f0b1b 100644
--- a/alias
+++ b/alias
@@ -3,11 +3,21 @@
3alias al="$EDITOR $SETTING_DIR/alias && source $SETTING_DIR/alias" 3alias al="$EDITOR $SETTING_DIR/alias && source $SETTING_DIR/alias"
4 4
5# SHELL {{{ 5# SHELL {{{
6
7alias eof='IGNOREEOF=10'
8path() { echo $PATH; } # Should not use alias, because $PATH is not initialized
6eval "${shell}rc(){ 9eval "${shell}rc(){
7 local RCFILE=$XDG_CONFIG_HOME/${shell}/.${shell}rc 10 local RCFILE=$XDG_CONFIG_HOME/${shell}/.${shell}rc
8 vim \$RCFILE && source \$RCFILE 11 vim \$RCFILE && source \$RCFILE
9}" 12}"
10alias eof='IGNOREEOF=10' 13ps1.swap() {
14 if [ -z "$PS1_bak" ]; then PS1_bak="$PS1"
15 PS1="${1:->}"
16 PS1="${PS1%% } "
17 else PS1="$PS1_bak"
18 unset PS1_bak
19 fi
20}
11 21
12# }}} 22# }}}
13# CUSTOM HELPER {{{ 23# CUSTOM HELPER {{{
@@ -28,53 +38,68 @@ urlencode() {
28} 38}
29# }}} 39# }}}
30# UNIX {{{ 40# UNIX {{{
31alias chx='chmod +x'
32alias chr='chmod +r'
33config(){ cd ~/.config/$1; } 41config(){ cd ~/.config/$1; }
34alias k='kill %1' 42alias sound="echo -ne '\a'"
35alias s='sudo systemctl' 43alias hg='history | grep'
36alias j='sudo journalctl -xeu' 44prompt-vim() {
37alias ls='ls --color' 45 TMPFILE=$(mktemp)
38alias lsd='ls -d */' 46 echo -e "$@" >$TMPFILE \
39alias grep='grep --color' 47 && vim $TMPFILE \
40path() { echo $PATH; } # Should not use alias, because $PATH is not initialized 48 && sed -i '$ q; s/$/ \\/' $TMPFILE \
41ps1.swap() { 49 && eval $(<$TMPFILE tee /dev/tty)
42 if [ -z "$PS1_bak" ]; then PS1_bak="$PS1" 50 rm $TMPFILE
43 PS1="${1:->}"
44 PS1="${PS1%% } "
45 else PS1="$PS1_bak"
46 unset PS1_bak
47 fi
48} 51}
49fd() { echo /proc/$$/fd; ls -l /proc/$$/fd; } 52
50port() { sudo lsof -i :$1; } 53
51alias ports='sudo lsof -i -Pn | grep LISTEN' 54# ls
52alias ll='ls -lh' 55alias ll='ls -lh'
53alias lla='ls -lha' 56alias lla='ls -lha'
54alias lld='ls -lh -d */' 57alias lld='ls -lh -d */'
58alias ls='ls --color'
59alias lsd='ls -d */'
55llw() { which $1 | xargs ls -alh; } 60llw() { which $1 | xargs ls -alh; }
56alias hg='history | grep' 61
57trash() { mv $@ /tmp/ 2>/dev/null || rm -rf $@; } 62# process
58rmrf() { rm -rf $@; }
59alias rr='_move_to_tmp'
60alias sound="echo -ne '\a'"
61pst(){ pstree -ps ${1:-$$}; } 63pst(){ pstree -ps ${1:-$$}; }
64alias k='kill %1'
65fd() { echo /proc/$$/fd; ls -l /proc/$$/fd; }
66
67# date
68alias iso8601='date --iso-8601=minutes'
69alias clock.reset='hwclock --systohc'
70date.reset() {
71 sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"
72}
73
74# grep
75alias grep='grep --color'
76unalias gr &>/dev/null
77gr() { grep -IR $@ . | sed '/^.\{2048\}./d'; }
78highlight() { grep --color -E "$1|\$"; }
79
80# cron
81alias ce='crontab -e'
82alias cl='crontab -l'
83
84# file system
85port() { sudo lsof -i :$1; }
86alias ports='sudo lsof -i -Pn | grep LISTEN'
62alias duu='du -hd 1 . | sort -hr' 87alias duu='du -hd 1 . | sort -hr'
88_move_to_tmp() { mv $@ /tmp; }
63name() { find . -iname "$1"; } 89name() { find . -iname "$1"; }
64alias latest='find . -type f | xargs ls -ltr | tail' 90alias latest='find . -type f | xargs ls -ltr | tail'
91alias lock='sudo chattr +i' # Make file undeletable
92alias chx='chmod +x'
93alias chr='chmod +r'
94alias findn='find . -iname'
95trash() { mv $@ /tmp/ 2>/dev/null || rm -rf $@; }
96rmrf() { rm -rf $@; }
97alias df='df -h'
98bak() { cp $1 $1.bak; }
65cdp() { 99cdp() {
66 [[ ! -d $1 ]] && mkdir -p $1 100 [[ ! -d $1 ]] && mkdir -p $1
67 cd $1 101 cd $1
68} 102}
69_move_to_tmp() { mv $@ /tmp; }
70prompt-vim() {
71 TMPFILE=$(mktemp)
72 echo -e "$@" >$TMPFILE \
73 && vim $TMPFILE \
74 && sed -i '$ q; s/$/ \\/' $TMPFILE \
75 && eval $(<$TMPFILE tee /dev/tty)
76 rm $TMPFILE
77}
78file.sort() { 103file.sort() {
79 find $1 -type f -print0 |\ 104 find $1 -type f -print0 |\
80 xargs -0 ls --sort=size -lh |\ 105 xargs -0 ls --sort=size -lh |\
@@ -97,26 +122,12 @@ file.size() {
97 printf("%3d%s: %6d\n", a[1],substr("kMGTEPYZ",a[2]+1,1),$2) 122 printf("%3d%s: %6d\n", a[1],substr("kMGTEPYZ",a[2]+1,1),$2)
98 }' 123 }'
99} 124}
100highlight() { grep --color -E "$1|\$"; }
101alias iso8601='date --iso-8601=minutes'
102# Make file undeletable
103alias lock='sudo chattr +i'
104# Reset clock
105date.reset() {
106 sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"
107}
108alias clock.reset='hwclock --systohc'
109unalias gr &>/dev/null
110gr() {
111 grep -IR $@ . | sed '/^.\{2048\}./d'
112}
113alias findn='find . -iname'
114alias ce='crontab -e'
115alias cl='crontab -l'
116alias df='df -h'
117bak() { cp $1 $1.bak; }
118 125
119# }}} 126# }}}
127# Systemctl {{{
128alias s='sudo systemctl'
129alias j='sudo journalctl -xeu'
130# }}}
120# Clipboard{{{ 131# Clipboard{{{
121alias xi='xsel -ib' 132alias xi='xsel -ib'
122alias xii='`fc -ln -1` | head -1 | xsel -ib' 133alias xii='`fc -ln -1` | head -1 | xsel -ib'