zsh-config/.zshrc.d/02-aliases.zsh

68 lines
2.1 KiB
Bash
Raw Permalink Normal View History

2022-03-20 19:08:26 +00:00
# Just a funky little collection of more or less useful aliases
#Various impractical jokes and tools
if [ -n "$LOCALCITY" ]; then
alias weatherfetch="curl -sf https://wttr.in/$LOCALCITY | head -n 7 && echo ''"
fi
if [ -n "$DESKTOP_SESSION" ]; then
2022-09-03 13:16:34 +00:00
# winver is a thing, so here's linver
alias linver="nohup zenity --info --text=\"Linux version: \\n$(uname -srm)\" > /dev/null"
# tools to manipulate xclip easier
2022-03-20 19:08:26 +00:00
alias paste="xclip -o -selection clipboard"
alias copy="xclip -o | xclip -i -selection clipboard"
fi
2022-09-03 13:16:34 +00:00
# unless you're using vim to this day, this is what most people do
2022-03-20 19:08:26 +00:00
alias vim="nvim"
function nojail() {
2022-09-03 13:16:34 +00:00
# specific tool for firejail to disable jailing at all
2022-03-20 19:08:26 +00:00
PATH=`echo $PATH | sed "s/:\/usr\/local\/bin//g" | sed "s/:\/usr\/local\/sbin//g"` $@
}
2022-09-03 13:16:34 +00:00
# Set a default music path
if [ -z "$MUSIC_PATH" ]; then
export MUSIC_PATH="$HOME/Music/"
2022-03-20 19:08:26 +00:00
fi
2022-09-03 13:16:34 +00:00
# Try to be sensible about youtube-dl downloader
if ! which yt-dlp > /dev/null; then
if ! which youtube-dl > /dev/null; then
alias yt-dlp="echo Unable to execute: youtube-dl or yt-dlp not found; false "
else
# No, really. Not even an ad, it just runs faster because people keep fixing the throttling issue, which youtube-dl got stuck on.
alias yt-dlp="echo youtube-dl is heavily outdated, consider installing yt-dlp; youtube-dl "
fi
fi
function ytdl() {
# Download and convert to audio a youtube video
if [ -z "$1" ]; then
echo "USAGE: ytdl <video name or URL>"
return
fi
mkdir -p $MUSIC_PATH/ytdl
yt-dlp -x --default-search "ytsearch:" --output "$MUSIC_PATH/ytdl/%(title)s.%(ext)s" $1
}
function scdl() {
# Download audio from soundcloud
if [ -z "$1" ]; then
echo "USAGE: scdl <audio name or URL>"
return
fi
mkdir -p $MUSIC_PATH/soundclown
yt-dlp -x --default-search "scsearch:" --output "$MUSIC_PATH/soundclown/%(title)s.%(ext)s" $1
}
function countlines() {
if [ -z "$1" ]; then
echo "USAGE: countlines <file extension>"
return
fi
for file in $(find . -name \*.$1); do
cat $file
done | wc -l
}