-
Notifications
You must be signed in to change notification settings - Fork 0
/
env.sh
112 lines (95 loc) · 2.68 KB
/
env.sh
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
# -------
# General
# -------
# Commands history
# http://www.thegeekstuff.com/2008/08/15-examples-to-master-linux-command-line-history/
# Larger bash history (allow 32³ entries; default is 500)
export HISTSIZE=32768
# Eliminate the repeated commands.
export HiSTFILESIZE=$HISTSIZE
export HISTCONTROL=ignoredups
# Make some commands not show up in history
export HISTIGNORE="ls:ls *"
# Use vim
export EDITOR='vim'
set -o vi
# -------
# Aliases
# -------
alias v='vim -p'
alias c='clear'
alias e='exit'
alias ..="cd .."
alias ...="cd ../.."
alias py='python'
alias py3='python3'
alias cloc="cloc --read-lang-def=$HOME/.dotfiles/my_cloc_def.txt"
alias zshconfig="vim ~/.zshrc"
alias vimconfig="vim ~/.vimrc"
alias gitconfig="vim ~/.gitconfig"
alias root="sudo su -"
alias myip="ip -br -c a"
alias process="ps -aux"
# macOS only
alias icloud="cd ~/Library/Mobile\ Documents/com~apple~CloudDocs"
# grep
export GREP_OPTIONS='--color=always'
alias pygrep='grep --include=*.py -Ir '
alias htmlgrep='grep --include=*.html -Ir '
alias jsgrep='grep --include=*.js -Ir '
# ---------
# Functions
# ---------
function f() { find . -iname "*$1*" ${@:2} }
function r() { grep "$1" ${@:2} -R . }
function mkcd() { mkdir -p "$@" && cd "$_"; }
psgrep() {
if [ ! -z $1 ] ; then
echo "Grepping for processes matching $1..."
ps aux | grep $1 | grep -v grep
else
echo "!! Need name to grep for"
fi
}
grab() {
sudo chown -R ${USER} ${1:-.}
}
#netinfo - shows network information for your system
netinfo() {
echo "--------------- Network Information ---------------"
/sbin/ifconfig | awk /'inet addr/ {print $2}'
/sbin/ifconfig | awk /'Bcast/ {print $3}'
/sbin/ifconfig | awk /'inet addr/ {print $4}'
/sbin/ifconfig | awk /'HWaddr/ {print $4,$5}'
myip=`lynx -dump -hiddenlinks=ignore -nolist http://checkip.dyndns.org:8245/ | sed '/^$/d; s/^[ ]*//g; s/[ ]*$//g' `
echo "${myip}"
echo "---------------------------------------------------"
}
dirsize() {
du -shx * .[a-zA-Z0-9_]* 2> /dev/null | \
egrep '^ *[0-9.]*[MG]' | sort -n > /tmp/list
egrep '^ *[0-9.]*M' /tmp/list
egrep '^ *[0-9.]*G' /tmp/list
rm -rf /tmp/list
}
function rp() {
if [[ $# == 3 ]]; then
pattern=$1
replacement=$2
filename=$3
echo "$pattern -> $replacement in $filename"
mv "$filename" "$filename.old"
sed "s/$pattern/$replacement/g" < "$filename.old" > "$filename"
fi
}
function lla(){
ls -l "$@" | awk '
{
k=0;
for (i=0;i<=8;i++)
k+=((substr($1,i+2,1)~/[rwx]/) *2^(8-i));
if (k)
printf("%0o ",k);
printf(" %9s %3s %2s %5s %6s %s %s %s\n", $3, $6, $7, $8, $5, $9,$10, $11);
}'
}