-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bash_aliases
101 lines (75 loc) · 2.38 KB
/
.bash_aliases
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
# ----- Aliases -----
# For ourselves
alias ba="vim ~/.bash_aliases"
alias brc="vim ~/.bashrc"
alias rl="readlink -f"
# Git
alias gitroot='cd $(git rev-parse --show-toplevel)'
alias config='/usr/bin/git --git-dir=/home/sbeer/.myconfig/ --work-tree=/home/sbeer'
function lg { ll | grep $1; }
# 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
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Some common greps
alias lg='ls -alF | grep -i'
alias cg='crontab -l | grep -i'
alias pg='ps aux | grep -i'
# Use nvim by default
# alias vim='nvim'
# 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 -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias rgf='rg --files | rg'
# Some stuff I picked up on the internet
alias please='sudo !!'
alias cl='clear'
alias rr='curl -s -L https://raw.githubusercontent.com/keroserene/rickrollrc/master/roll.sh | bash'
alias update='sudo apt-get update && sudo apt-get upgrade'
# Copy using osc52 copy command
# alias cpy='echo -en "\x1b]52;c;$(base64 -w0 -)\x07"'
alias cpy='xclip -selection clipboard'
chdir() {
mkdir -p "$1"
cd "$1"
}
alias v='nvim'
# ----- Keybindings -----
# Helper commands to work with readline bindings
_save_command_line() {
READLINE_LINE_OLD="$READLINE_LINE"
READLINE_POINT_OLD="$READLINE_POINT"
READLINE_LINE=
READLINE_POINT=0
}
_restore_command_line() {
READLINE_LINE="$READLINE_LINE_OLD"
READLINE_POINT="$READLINE_POINT_OLD"
}
dirstack_next() {
pushd +1 > /dev/null
}
dirstack_prev() {
pushd -0 > /dev/null
}
# Restore cl is universal
bind -x '"\201":"_restore_command_line"'
# Go up one directory
bind -x '"\204":"_save_command_line; cd .."'
bind '"\eh":"\204\n\201"'
# Rotate pushed directories
bind -x '"\202":"_save_command_line; dirstack_next"'
bind '"\ek":"\202\n\201"'
bind -x '"\203":"_save_command_line; dirstack_prev"'
bind '"\ej":"\203\n\201"'
# Better ls -al
bind -x '"\el":"ls -latr"'