mirror of
https://git.decapod.one/brethil/dotfiles
synced 2024-11-22 03:21:30 +01:00
functions: fix httpserver, cleanup
This commit is contained in:
parent
54c12dd03c
commit
7e2628cb71
19
functions.sh
19
functions.sh
|
@ -94,16 +94,6 @@ function beeper
|
||||||
while true; do printf "\e[?5h\007"; sleep 0.25; printf "\e[?5l"; read -s -n -t1 && break; done;
|
while true; do printf "\e[?5h\007"; sleep 0.25; printf "\e[?5l"; read -s -n -t1 && break; done;
|
||||||
}
|
}
|
||||||
|
|
||||||
## Search youtube for string ($1) and play video (uses mplayer)
|
|
||||||
function pyt
|
|
||||||
{
|
|
||||||
echo 'https://www.youtube.com/results?search_query='"$(sed 's/ /%20/g' <<< $(tr '\' '+' <<< "$@"))"; id=$(curl -s 'https://www.youtube.com/results?search_query='"$(sed 's/ /%20/g' <<< $(tr '\' '+' <<< "$@"))" | grep -om3 '"[[:alnum:]]\{11\}"' | awk NR==3 | tr -d \"); url='https://www.youtube.com/watch?v='"$id"; echo -e "URL:\t$url"; youtube-dl -q $url -o - | mplayer -vo corevideo -really-quiet /dev/fd/3 3<&0 </dev/tty;
|
|
||||||
}
|
|
||||||
## Same as above, only play music (uses mplayer)
|
|
||||||
function pmusic
|
|
||||||
{
|
|
||||||
echo 'https://www.youtube.com/results?search_query=HD%20'"$(sed 's/ /%20/g' <<< $(tr '\' '+' <<< "$@"))"; id=$(curl -s 'https://www.youtube.com/results?search_query='HD%20"$(sed 's/ /%20/g' <<< $(tr '\' '+' <<< "$@"))" | grep -om3 '"[[:alnum:]]\{11\}"' | awk NR==3 | tr -d \"); url='https://www.youtube.com/watch?v='"$id"; echo -e "URL:\t$url"; youtube-dl -q $url -o - | mplayer -vo corevideo -really-quiet /dev/fd/3 3<&0 </dev/tty;
|
|
||||||
}
|
|
||||||
|
|
||||||
## Simple http server for current directory (or path)
|
## Simple http server for current directory (or path)
|
||||||
function httpserver
|
function httpserver
|
||||||
|
@ -115,14 +105,15 @@ function httpserver
|
||||||
echo "Starting webserver in $PWD/"
|
echo "Starting webserver in $PWD/"
|
||||||
fi
|
fi
|
||||||
open "http://localhost:8000" &>/dev/null &
|
open "http://localhost:8000" &>/dev/null &
|
||||||
if [[ $(python --version) == "Python 3"* ]]; then
|
if [[ "$(command -v python3)" ]]; then
|
||||||
python -m http.server 8000
|
python=python3
|
||||||
else
|
else
|
||||||
python -m SimpleHTTPServer
|
python=python
|
||||||
fi
|
fi
|
||||||
|
$python -m http.server 8000
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
alias webserver='httpserver'
|
||||||
|
|
||||||
## Upload something using the transfer.sh service. Usage: transfer filename
|
## Upload something using the transfer.sh service. Usage: transfer filename
|
||||||
function transfer
|
function transfer
|
||||||
|
|
Loading…
Reference in New Issue
Block a user