some aliases moved to utils
This commit is contained in:
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
alias bashrc='source ~/.bashrc'
|
alias bashrc='source ~/.bashrc'
|
||||||
alias zshrc='source ~/.zshrc'
|
alias zshrc='source ~/.zshrc'
|
||||||
# alias aliases='cat ~/.bash_aliases' # use 'alias' instead (without args)
|
|
||||||
alias realias='source ~/.bash_aliases'
|
alias realias='source ~/.bash_aliases'
|
||||||
alias stow="stow -v"
|
alias stow="stow -v"
|
||||||
alias unstow="stow -D"
|
alias unstow="stow -D"
|
||||||
@@ -10,6 +9,7 @@ alias restow="stow -R"
|
|||||||
alias reload='exec ${SHELL} -l'
|
alias reload='exec ${SHELL} -l'
|
||||||
alias sudo='sudo ' # enable aliases to be sudo'ed
|
alias sudo='sudo ' # enable aliases to be sudo'ed
|
||||||
alias g='git'
|
alias g='git'
|
||||||
|
alias c='composer'
|
||||||
alias hosts="sudo nano /etc/hosts"
|
alias hosts="sudo nano /etc/hosts"
|
||||||
alias shrug="echo '¯\_(ツ)_/¯' | xclip -selection c"
|
alias shrug="echo '¯\_(ツ)_/¯' | xclip -selection c"
|
||||||
|
|
||||||
@@ -39,7 +39,6 @@ alias psg='ps aux | grep -v grep | grep -i -e VSZ -e'
|
|||||||
alias wine='LANG=ru_RU.utf8 wine'
|
alias wine='LANG=ru_RU.utf8 wine'
|
||||||
alias wine64='LANG=ru_RU.utf8 wine64'
|
alias wine64='LANG=ru_RU.utf8 wine64'
|
||||||
|
|
||||||
alias untargz='tar -czf'
|
|
||||||
alias ports='netstat -tulpan'
|
alias ports='netstat -tulpan'
|
||||||
|
|
||||||
# alias pubkey="more ~/.ssh/id_ed25519.pub | xclip -selection clipboard | echo '=> Public key copied to pasteboard.'"
|
# alias pubkey="more ~/.ssh/id_ed25519.pub | xclip -selection clipboard | echo '=> Public key copied to pasteboard.'"
|
||||||
@@ -50,105 +49,3 @@ alias gpg.list='gpg --list-keys --keyid-format SHORT'
|
|||||||
|
|
||||||
# https://obsproject.com/forum/threads/how-to-start-virtual-camera-without-sudo-privileges.139783/
|
# 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'"
|
# alias obscam="sudo modprobe v4l2loopback video_nr=2 card_label='OBS Virtual Camera'"
|
||||||
|
|
||||||
# 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 -- file/dir path
|
|
||||||
# $2 -- permissions (0644, 0755, etc)
|
|
||||||
# own() { #TODO refactor
|
|
||||||
# [ "$1" ] && PATH="${1/#\~/$HOME}" || {
|
|
||||||
# echo "Error (1): path not provided"
|
|
||||||
# }
|
|
||||||
# echo $PATH
|
|
||||||
|
|
||||||
# [ "$2" ] && PERM="$2" || {
|
|
||||||
# if [ -d $PATH ]; then
|
|
||||||
# PERM="0755"
|
|
||||||
# elif [ -f $PATH ]; then
|
|
||||||
# PERM="0644"
|
|
||||||
# else
|
|
||||||
# echo "Error (2): path not exists"
|
|
||||||
# fi;
|
|
||||||
# }
|
|
||||||
# echo $PERM
|
|
||||||
|
|
||||||
# sudo chmod $PERM -R --preserve-root $PATH
|
|
||||||
# sudo chown $USER. -R --preserve-root $PATH
|
|
||||||
# }
|
|
||||||
|
|
||||||
# function extract {
|
|
||||||
# if [ -z "$1" ]; then
|
|
||||||
# # display usage if no parameters given
|
|
||||||
# echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
|
|
||||||
# echo " extract <path/file_name_1.ext> [path/file_name_2.ext] [path/file_name_3.ext]"
|
|
||||||
# return 1
|
|
||||||
# else
|
|
||||||
# for n in $@
|
|
||||||
# do
|
|
||||||
# if [ -f "$n" ] ; then
|
|
||||||
# case "${n%,}" in
|
|
||||||
# *.tar.bz2|*.tar.gz|*.tar.xz|*.tbz2|*.tgz|*.txz|*.tar)
|
|
||||||
# tar xvf "$n" ;;
|
|
||||||
# *.lzma) unlzma ./"$n" ;;
|
|
||||||
# *.bz2) bunzip2 ./"$n" ;;
|
|
||||||
# *.rar) unrar x -ad ./"$n" ;;
|
|
||||||
# *.gz) gunzip ./"$n" ;;
|
|
||||||
# *.zip) unzip ./"$n" ;;
|
|
||||||
# *.z) uncompress ./"$n" ;;
|
|
||||||
# *.7z|*.arj|*.cab|*.chm|*.deb|*.dmg|*.iso|*.lzh|*.msi|*.rpm|*.udf|*.wim|*.xar)
|
|
||||||
# 7z x ./"$n" ;;
|
|
||||||
# *.xz) unxz ./"$n" ;;
|
|
||||||
# *.exe) cabextract ./"$n" ;;
|
|
||||||
# *)
|
|
||||||
# echo "extract: '$n' - unknown archive method"
|
|
||||||
# return 1
|
|
||||||
# ;;
|
|
||||||
# esac
|
|
||||||
# else
|
|
||||||
# echo "'$n' - file does not exist"
|
|
||||||
# return 1
|
|
||||||
# fi
|
|
||||||
# done
|
|
||||||
# fi
|
|
||||||
# }
|
|
||||||
|
|||||||
27
utils/.local/bin/docker-ips
Executable file
27
utils/.local/bin/docker-ips
Executable file
@@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -eo pipefail
|
||||||
|
|
||||||
|
# TODO not ready yet
|
||||||
|
exit
|
||||||
|
|
||||||
|
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,25 +1,39 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
if [ -f "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
case "$1" in
|
echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
|
||||||
*.tar.bz2) tar -jxvf "$1" ;;
|
echo " extract <path/file_name_1.ext> [path/file_name_2.ext] [path/file_name_3.ext]"
|
||||||
*.tar.gz) tar -zxvf "$1" ;;
|
exit 1
|
||||||
*.tar.xz) tar -Jxvf "$1" ;;
|
|
||||||
*.bz2) bunzip2 "$1" ;;
|
|
||||||
*.dmg) hdiutil mount "$1" ;;
|
|
||||||
*.gz) gunzip "$1" ;;
|
|
||||||
*.tar) tar -xvf "$1" ;;
|
|
||||||
*.tbz2) tar -jxvf "$1" ;;
|
|
||||||
*.tgz) tar -zxvf "$1" ;;
|
|
||||||
*.zip) unzip "$1" ;;
|
|
||||||
*.ZIP) unzip "$1" ;;
|
|
||||||
*.pax) cat "$1" | pax -r ;;
|
|
||||||
*.pax.Z) uncompress "$1" --stdout | pax -r ;;
|
|
||||||
*.rar) unrar x "$1" ;;
|
|
||||||
*.Z) uncompress "$1" ;;
|
|
||||||
*) echo "'$1' cannot be extracted/mounted via extract()" ;;
|
|
||||||
esac
|
|
||||||
else
|
|
||||||
echo "'$1' is not a valid file"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
for n in "$@"; do
|
||||||
|
if [ ! -f "$n" ] ; then
|
||||||
|
echo "File does not exist, skipping: '$n'"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "${n%,}" in
|
||||||
|
# *.tar) tar -xvf "$1" ;;
|
||||||
|
# *.tbz2) tar -jxvf "$1" ;;
|
||||||
|
# *.tar.bz2) tar -jxvf "$1" ;;
|
||||||
|
# *.tgz) tar -zxvf "$1" ;;
|
||||||
|
# *.tar.gz) tar -zxvf "$1" ;;
|
||||||
|
# *.tar.xz) tar -Jxvf "$1" ;;
|
||||||
|
*.tar.bz2|*.tar.gz|*.tar.xz|*.tbz2|*.tgz|*.txz|*.tar)
|
||||||
|
tar xvf "$n" ;;
|
||||||
|
*.7z|*.arj|*.cab|*.chm|*.deb|*.dmg|*.iso|*.lzh|*.msi|*.rpm|*.udf|*.wim|*.xar)
|
||||||
|
7z x ./"$n" ;;
|
||||||
|
*.lzma) unlzma ./"$n" ;;
|
||||||
|
*.bz2) bunzip2 ./"$n" ;;
|
||||||
|
*.rar) unrar x -ad ./"$n" ;;
|
||||||
|
*.gz) gunzip ./"$n" ;;
|
||||||
|
*.zip) unzip ./"$n" ;;
|
||||||
|
*.z) uncompress ./"$n" ;;
|
||||||
|
*.xz) unxz ./"$n" ;;
|
||||||
|
*.exe) cabextract ./"$n" ;;
|
||||||
|
*.pax) cat "$1" | pax -r ;;
|
||||||
|
*.pax.Z) uncompress "$1" --stdout | pax -r ;;
|
||||||
|
*) echo "extract: '$n' - unknown archive method" ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|||||||
4
utils/.local/bin/own
Executable file
4
utils/.local/bin/own
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -eo pipefail
|
||||||
|
|
||||||
|
sudo chown "$(whoami)". -R --changes --preserve-root "$@"
|
||||||
19
utils/.local/bin/ytmusic
Executable file
19
utils/.local/bin/ytmusic
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Download music from Youtube or Youtube Music
|
||||||
|
# and save as top quality flac file without video
|
||||||
|
# Playlist and video/track URLs are supported
|
||||||
|
# Usage: $ ytmusic https://www.youtube.com/watch?v=dQw4w9WgXcQ
|
||||||
|
# More info: https://github.com/ytdl-org/youtube-dl
|
||||||
|
|
||||||
|
DEST_PATH="${HOME}/ytmusic"
|
||||||
|
mkdir -p "${DEST_PATH}"
|
||||||
|
|
||||||
|
youtube-dl \
|
||||||
|
--extract-audio \
|
||||||
|
--audio-format flac \
|
||||||
|
--audio-quality 0 \
|
||||||
|
--format bestaudio \
|
||||||
|
--write-info-json \
|
||||||
|
--output "${DEST_PATH}/%(playlist_title)s/%(channel)s - %(title)s.%(ext)s" \
|
||||||
|
"$@"
|
||||||
Reference in New Issue
Block a user