1
0
Fork 0
bin/.bash_aliases

101 lines
2.8 KiB
Bash
Raw Permalink Normal View History

2015-12-11 10:29:22 +00:00
###############
### Aliases ###
###############
2016-04-09 15:51:20 +00:00
# cd up multiple directories at a time
alias ..='cd ..'
alias ...='cd ../../'
alias ....='cd ../../../'
alias .....='cd ../../../../'
alias ......='cd ../../../../../'
2015-12-11 10:29:22 +00:00
# some more ls aliases
alias ll='ls -hAtFl'
alias la='ls -hA'
alias l='ls -htFl'
# make cp and mv prompt before overwriting
alias cp='cp -i'
alias mv='mv -i'
2016-12-04 09:54:50 +00:00
# Make everything tell us what they're doing
2015-12-11 10:29:22 +00:00
alias mkdir='mkdir -pv'
alias rm='rm -v'
2016-12-04 09:54:50 +00:00
alias rmdir='rmdir -v'
2015-12-11 10:29:22 +00:00
# Make the permissions tweaking commands give us more information about what they are doing
2016-01-08 17:19:50 +00:00
alias chmod='chmod -c'
alias chown='chown -c'
alias chgrp='chgrp -c'
2015-12-11 10:29:22 +00:00
2016-03-21 19:58:47 +00:00
# Make time work properly
alias time=/usr/bin/time
2016-12-04 09:54:50 +00:00
# dfh: Show disk usage in a form we can actually understand
alias dfh='df -h'
2016-02-05 20:06:12 +00:00
# catz: gunzip & display commpressed gz files.
alias catz='gunzip -c'
2015-12-11 10:29:22 +00:00
# show colours in less
alias less='less -R'
# Alias to clear the screen for real
alias cls='printf "\033c"'
2016-09-12 19:25:10 +00:00
# mkfifo -> mkpipe
alias mkpipe='mkfifo'
2015-12-11 10:29:22 +00:00
# allow us to create a directory and immediately move into it
2016-04-12 07:12:30 +00:00
function mcd { mkdir -pv "$1" && cd "$1";}
2016-01-08 17:19:50 +00:00
# hr
alias hrh='hr - - = - -'
2016-01-13 09:28:17 +00:00
# termbins
alias sbrlbin='netcat starbeamrainbowlabs.com 9999'
alias termbin='netcat termbin.com 9999'
2016-02-05 20:06:12 +00:00
2016-03-21 19:58:47 +00:00
# termbin for any kind of file
transfer() { if [ $# -eq 0 ]; then echo "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"; return 1; fi
tmpfile=$( mktemp -t transferXXX ); if tty -s; then basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g'); curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile; else curl --progress-bar --upload-file "-" "https://transfer.sh/$1" >> $tmpfile ; fi; cat $tmpfile; rm -f $tmpfile; }
2016-05-16 20:01:51 +00:00
# gitignore.io interface
2016-05-16 20:04:05 +00:00
function gitignore() { curl -L -s https://www.gitignore.io/api/$@; }
2016-05-16 20:01:51 +00:00
2016-02-05 20:06:12 +00:00
# Get / Set clipboard contents
alias setclip='xclip -selection c'
alias getclip='xclip -selection clipboard -o'
2016-03-21 19:58:47 +00:00
# Ubuntu's inbuilt image previewer. I'll never be able to remember eog...
alias image-preview=eog
2017-06-09 12:11:20 +00:00
# colourise man
function _colorman() {
env \
LESS_TERMCAP_mb=$(printf "\e[1;35m") \
LESS_TERMCAP_md=$(printf "\e[1;34m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[7;40m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;33m") \
"$@"
}
function man() { _colorman man "$@"; }
2017-11-15 21:52:46 +00:00
# Quickly jump around places
function telepeek() {
2017-11-17 23:07:36 +00:00
find . -type d 2>/dev/null | grep -iP "$1" | cat -n | sed 's/^[ 0-9]*[0-9]/\o033[34m&\o033[0m/' | less -R
2017-11-15 21:52:46 +00:00
}
function teleport() {
cd $(find . -type d 2>/dev/null | grep -m1 -iP "$1");
2017-11-15 21:52:46 +00:00
}
2017-11-17 23:07:36 +00:00
function telepick() {
telepeek $1;
read -p "jump to index: " line_number;
cd $(find . -type d 2>/dev/null | grep -iP "$1" | sed "${line_number}q;d");
}