-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path.bashrc
More file actions
executable file
·141 lines (122 loc) · 2.69 KB
/
.bashrc
File metadata and controls
executable file
·141 lines (122 loc) · 2.69 KB
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
#!/bin/bash
alias cd1=hell_cd
alias ls1=hell_ls
alias nano1=hell_nano
alias exec1=hell_exec
alias echo1=hell_echo
alias touch1=hell_touch
alias mv1=hell_mv
hell_ls() {
args="$@"
ls --color $args | sort -R
}
hell_exec() {
if [ "$1" == "bash" ]; then
echo "You cannot escape hell without a path."
else
exec "$@"
fi
}
hell_nano() {
if [ -x "$(command -v nano)" ]; then
if [ -x "$(command -v vim)" ]; then
vim "$@"
elif [ -x "$(command -v emacs)" ]; then
emacs "$@"
else
nano "$@"
fi
fi
}
hell_cd() {
if [ "$1" == "" ]; then
random_dir=$(find / -type d 2>/dev/null | shuf -n 1)
cd $random_dir
return 0
fi
cd_path=$1
if [[ "$cd_path" == ..* ]]; then
# This obviously breaks autocomplete
cd $(random "$cd_path" "${cd_path/../../..}" "3")
else
cd $(random "/" "$cd_path" "4")
fi
}
hell_echo() {
str=$@
if [ "$str" == "" ]; then
echo "*silence*"
return 0
fi
str=${str^^[a,e,i,o,u]}
str=${str,,[B,C,D,F,G,H,J,K,L,M,N,P,Q,R,S,T,V,W,X,Y,Z]}
echo $str
}
hell_touch() {
filename=$1
if [ "$filename" == "" ]; then
echo "You must specify a file name."
return 0
fi
mkdir -p .files && touch .files/"${filename}"
}
hell_mv() {
arr=( "$@" )
declare -a exts
declare -a randarr
for arg in "${arr[@]}"; do
filename="${arg##*/}"
count=$(echo "$filename" | grep -o "\." | wc -l)
if [ "$count" -gt 0 ]; then
exts=("${filename#*.}" "${exts[@]}")
fi
done
if [ "${exts[0]}" == "${exts[1]}" ]; then
filename_dst="${arr[1]##*/}"
dst_name="${filename_dst%%.*}"
dir_dst=$(dirname "${arr[1]}")
files_dst=($dir_dst/*."${exts[1]}")
filename_src="${arr[0]##*/}"
dir_src=$(dirname "${arr[0]}")
files_src=($dir_src/*."${exts[1]}")
if [[ ! "${files_src[@]}" =~ "$filename_src" ]]; then
echo "File '$filename_src' not in directory '$dir_src'."
return 0
fi
count=$(ls "$dir_dst"/*."${exts[1]}" | wc -l)
readarray randarr < <(seq "$count" | shuf)
echo ${randarr[@]}
echo ${files_dst[@]}
for ((i=0;i<count;i++)); do
filename="${files_dst[i]}"
if [[ "${files_dst[@]}" =~ "${dst_name}${randarr[i]%?}"."${exts[1]}" ]]; then
new_c=$(( count + 1 + $i ))
mv "$filename" "${dst_name}${new_c}"."${exts[1]}"
continue
fi
mv "$filename" "${dst_name}${randarr[i]%?}"."${exts[1]}"
done
else
echo "Try to mv to a file with same extension."
return 0
fi
}
random(){
low_prob_text=$1
high_prob_text=$2
x=$3
if [ "$low_prob_text" == "" ] || [ "$high_prob_text" == "" ]; then
return 0
fi
if [ "$x" == "" ]; then
x=10
fi
random_number=$(( RANDOM % $x ))
if [ "$random_number" == "0" ]; then
echo -n "$low_prob_text"
else
echo -n "$high_prob_text"
fi
}
LS_COLORS='rs=0:di=01;91;41:ln=01;37;100:*=0;34;104';
export LS_COLORS