.bash_aliases
· 3.3 KiB · Bash
Surowy
#!/bin/bash
# alias bashrc='source ~/.bashrc'
alias zshrc='source ~/.zshrc'
alias realias='source ~/.bash_aliases'
alias reload='exec ${SHELL} -l'
alias sudo='sudo ' # enable aliases to be sudo’ed
alias g='git'
alias hosts="sudo nano /etc/hosts"
alias shrug="echo '¯\_(ツ)_/¯' | xclip -selection c"
alias ..='cd ..' # zsh builtin
alias ~='cd ~' # zsh builtin
# alias "--"='cd -' # zsh builtin
alias chmod='chmod --preserve-root'
alias chown='chown --preserve-root'
alias free='free -h'
alias duh='du -ha --max-depth=1'
alias sduh='sudo du -ha --max-depth=1'
alias l='ls -pCFh --color=auto'
alias la='ls -pAFh --color=auto'
alias ll='ls -palFh --color=auto'
alias mkdir='mkdir -pv'
alias where='whereis' # zsh builtin
alias ps='ps auxf'
alias psg='ps aux | grep -v grep | grep -i -e VSZ -e'
alias is='type -a'
alias upgrade='sudo apt update && sudo apt upgrade -y && sudo snap refresh'
alias untargz='tar -czf'
alias mkcd="mkdir -p $1 && cd $1"
alias cl='cd $1 && ll'
alias myip='curl http://ipecho.net/plain; echo'
alias ports='netstat -tulpan'
alias ssh.pub='cat ~/.ssh/*.pub'
alias gpg.new="gpg --full-generate-key"
alias gpg.pub="gpg --armor --export $@"
alias gpg.list='gpg --list-keys --keyid-format SHORT'
alias lite-xl="LITE_SCALE=1 lite-xl"
alias wine='LANG=ru_RU.utf8 wine'
alias docker.prune='docker image prune -f; docker network prune -f; docker container prune -f'
# https://obsproject.com/forum/threads/how-to-start-virtual-camera-without-sudo-privileges.139783/
alias obscam="sudo modprobe v4l2loopback video_nr=2 card_label='OBS Virtual Camera'"
curltime() {
curl -w @- -o /dev/null -s "$@" <<'EOF'
time_namelookup: %{time_namelookup} sec\n
time_connect: %{time_connect} sec\n
time_appconnect: %{time_appconnect} sec\n
time_pretransfer: %{time_pretransfer} sec\n
time_redirect: %{time_redirect} sec\n
time_starttransfer: %{time_starttransfer} sec\n
---------------\n
time_total: %{time_total} sec\n
EOF
}
# Download music from Youtube or Youtube Music
# and save as top quality flac file without video
# Playlist and video/track URLs are supported
# Usage: $ ytm https://www.youtube.com/watch\?v=dQw4w9WgXcQ
# More info: https://github.com/ytdl-org/youtube-dl
ytm() {
youtube-dl \
--extract-audio \
--audio-format flac \
--audio-quality 0 \
--format bestaudio \
--write-info-json \
--output "${HOME}/Музыка/ytm/%(playlist_title)s/%(channel)s - %(title)s.%(ext)s" \
$@
}
docker.ip() {
if [ "$1" ]; then
if [ "$1" = "-a" ]; then
docker ps -aq \
| xargs -n 1 docker inspect --format '{{.Name}}{{range .NetworkSettings.Networks}} {{.IPAddress}}{{end}}' \
| sed -e 's#^/##' \
| column -t
elif [ "$1" = "-c" ]; then
docker-compose ps -q \
| xargs -n 1 docker inspect --format '{{.Name}}{{range .NetworkSettings.Networks}} {{.IPAddress}}{{end}}' \
| sed -e 's#^/##' \
| column -t
else
docker inspect --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$1"
docker port "$1"
fi
else
docker ps -q \
| xargs -n 1 docker inspect --format '{{.Name}}{{range .NetworkSettings.Networks}} {{.IPAddress}}{{end}}' \
| sed -e 's#^/##' \
| column -t
fi
}
| 1 | #!/bin/bash |
| 2 | |
| 3 | # alias bashrc='source ~/.bashrc' |
| 4 | alias zshrc='source ~/.zshrc' |
| 5 | alias realias='source ~/.bash_aliases' |
| 6 | alias reload='exec ${SHELL} -l' |
| 7 | alias sudo='sudo ' # enable aliases to be sudo’ed |
| 8 | alias g='git' |
| 9 | alias hosts="sudo nano /etc/hosts" |
| 10 | alias shrug="echo '¯\_(ツ)_/¯' | xclip -selection c" |
| 11 | |
| 12 | alias ..='cd ..' # zsh builtin |
| 13 | alias ~='cd ~' # zsh builtin |
| 14 | # alias "--"='cd -' # zsh builtin |
| 15 | |
| 16 | alias chmod='chmod --preserve-root' |
| 17 | alias chown='chown --preserve-root' |
| 18 | |
| 19 | alias free='free -h' |
| 20 | alias duh='du -ha --max-depth=1' |
| 21 | alias sduh='sudo du -ha --max-depth=1' |
| 22 | |
| 23 | alias l='ls -pCFh --color=auto' |
| 24 | alias la='ls -pAFh --color=auto' |
| 25 | alias ll='ls -palFh --color=auto' |
| 26 | |
| 27 | alias mkdir='mkdir -pv' |
| 28 | alias where='whereis' # zsh builtin |
| 29 | |
| 30 | alias ps='ps auxf' |
| 31 | alias psg='ps aux | grep -v grep | grep -i -e VSZ -e' |
| 32 | |
| 33 | alias is='type -a' |
| 34 | alias upgrade='sudo apt update && sudo apt upgrade -y && sudo snap refresh' |
| 35 | alias untargz='tar -czf' |
| 36 | alias mkcd="mkdir -p $1 && cd $1" |
| 37 | alias cl='cd $1 && ll' |
| 38 | alias myip='curl http://ipecho.net/plain; echo' |
| 39 | alias ports='netstat -tulpan' |
| 40 | |
| 41 | alias ssh.pub='cat ~/.ssh/*.pub' |
| 42 | alias gpg.new="gpg --full-generate-key" |
| 43 | alias gpg.pub="gpg --armor --export $@" |
| 44 | alias gpg.list='gpg --list-keys --keyid-format SHORT' |
| 45 | |
| 46 | alias lite-xl="LITE_SCALE=1 lite-xl" |
| 47 | alias wine='LANG=ru_RU.utf8 wine' |
| 48 | alias docker.prune='docker image prune -f; docker network prune -f; docker container prune -f' |
| 49 | |
| 50 | # https://obsproject.com/forum/threads/how-to-start-virtual-camera-without-sudo-privileges.139783/ |
| 51 | alias obscam="sudo modprobe v4l2loopback video_nr=2 card_label='OBS Virtual Camera'" |
| 52 | |
| 53 | curltime() { |
| 54 | curl -w @- -o /dev/null -s "$@" <<'EOF' |
| 55 | time_namelookup: %{time_namelookup} sec\n |
| 56 | time_connect: %{time_connect} sec\n |
| 57 | time_appconnect: %{time_appconnect} sec\n |
| 58 | time_pretransfer: %{time_pretransfer} sec\n |
| 59 | time_redirect: %{time_redirect} sec\n |
| 60 | time_starttransfer: %{time_starttransfer} sec\n |
| 61 | ---------------\n |
| 62 | time_total: %{time_total} sec\n |
| 63 | EOF |
| 64 | } |
| 65 | |
| 66 | # Download music from Youtube or Youtube Music |
| 67 | # and save as top quality flac file without video |
| 68 | # Playlist and video/track URLs are supported |
| 69 | # Usage: $ ytm https://www.youtube.com/watch\?v=dQw4w9WgXcQ |
| 70 | # More info: https://github.com/ytdl-org/youtube-dl |
| 71 | ytm() { |
| 72 | youtube-dl \ |
| 73 | --extract-audio \ |
| 74 | --audio-format flac \ |
| 75 | --audio-quality 0 \ |
| 76 | --format bestaudio \ |
| 77 | --write-info-json \ |
| 78 | --output "${HOME}/Музыка/ytm/%(playlist_title)s/%(channel)s - %(title)s.%(ext)s" \ |
| 79 | $@ |
| 80 | } |
| 81 | |
| 82 | docker.ip() { |
| 83 | if [ "$1" ]; then |
| 84 | if [ "$1" = "-a" ]; then |
| 85 | docker ps -aq \ |
| 86 | | xargs -n 1 docker inspect --format '{{.Name}}{{range .NetworkSettings.Networks}} {{.IPAddress}}{{end}}' \ |
| 87 | | sed -e 's#^/##' \ |
| 88 | | column -t |
| 89 | elif [ "$1" = "-c" ]; then |
| 90 | docker-compose ps -q \ |
| 91 | | xargs -n 1 docker inspect --format '{{.Name}}{{range .NetworkSettings.Networks}} {{.IPAddress}}{{end}}' \ |
| 92 | | sed -e 's#^/##' \ |
| 93 | | column -t |
| 94 | else |
| 95 | docker inspect --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$1" |
| 96 | docker port "$1" |
| 97 | fi |
| 98 | else |
| 99 | docker ps -q \ |
| 100 | | xargs -n 1 docker inspect --format '{{.Name}}{{range .NetworkSettings.Networks}} {{.IPAddress}}{{end}}' \ |
| 101 | | sed -e 's#^/##' \ |
| 102 | | column -t |
| 103 | fi |
| 104 | } |
| 105 |