-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathshorthands
44 lines (38 loc) · 1.11 KB
/
shorthands
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
# list of functions that are handy and shortcuts to common behavious
# I show while using the terminal
# Many of these have been taken from other sources such as paulirish/dotfiles
md() {
mkdir -p "$@" && "$@"
}
# List all files, long format, colorized, permissions in octal
la(){
# shellcheck disable=SC2012
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);
}'
}
# find shorthand
f() {
find . -iname "$1" 2>&1 | grep -v 'Permission denied'
}
fz() {
find . -iname "*$1*" 2>&1 | grep -v 'Permission denied'
}
# git commit browser. needs fzf
log() {
git log --graph --color=always \
--format="%C(auto)%h%d %s %C(black)%C(bold)%cr" "$@" |
fzf --ansi --no-sort --reverse --tiebreak=index --toggle-sort=\` \
--bind "ctrl-m:execute:
echo '{}' | grep -o '[a-f0-9]\{7\}' | head -1 |
xargs -I % sh -c 'git show --color=always % | less -R'"
}
csvpreview() {
csvtool readable "$@" | nvim -R -
}