From fbf33e6eef5a3ce57c0215a9c9f7422b3e2e89a0 Mon Sep 17 00:00:00 2001 From: xerus2000 <27jf@pm.me> Date: Mon, 12 Oct 2020 22:20:06 +0200 Subject: [PATCH] config/shell: Make functions safer & add arch --- .config/shell/arch | 8 ++++++++ .config/shell/functions | 4 ++-- .config/shell/music | 5 +++-- .local/bin/focus | 2 -- 4 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 .config/shell/arch diff --git a/.config/shell/arch b/.config/shell/arch new file mode 100644 index 0000000..50d7fa1 --- /dev/null +++ b/.config/shell/arch @@ -0,0 +1,8 @@ +which pacman >/dev/null || return + +# Arch aliases +alias pac='sudo pacman' +alias pacs='pac -Syu --needed' +alias pacr='pac -R' +alias yays='yay -Syu --needed' + diff --git a/.config/shell/functions b/.config/shell/functions index 8240ddd..d59a634 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -287,7 +287,7 @@ mvk() { mv "$1" "$2" } -# Moves from $1 to $2 and creates a symlink in place of $2 +# Moves from $1 to $2 and replaces the original with a relative symlink mvln() { file=$(test -f "$1" && echo 1 || echo 0) if test -d $1; then @@ -297,7 +297,7 @@ mvln() { mv -v $1 $2 fi [ $file -gt 0 -a -d $2 ] && 2="$2/$(basename $1)" - ln -vsr $2 $1 + ln -vsr "$2" "$1" } # OTHER diff --git a/.config/shell/music b/.config/shell/music index 526e446..fb086c7 100644 --- a/.config/shell/music +++ b/.config/shell/music @@ -1,5 +1,6 @@ -MUSIC="$HOME/daten/music" -AUDIO="$HOME/daten/audio" +export DATA="$(test -d $HOME/data && echo $HOME/data || $HOME/daten)" +export MUSIC="$DATA/music" +export AUDIO="$DATA/audio" MUSIC_RAW="$AUDIO/songs/_raw" edpl() { diff --git a/.local/bin/focus b/.local/bin/focus index 8514265..ff91411 100755 --- a/.local/bin/focus +++ b/.local/bin/focus @@ -1,5 +1,3 @@ -#!/bin/sh -MUSIC="$HOME/daten/music" playlistPath="$MUSIC/Playlists" result="$(test "$1" && (find $playlistPath -iname "focus-$1.m3u8" | grep . || find $playlistPath -iname "$1.m3u*" | grep . || find $MUSIC -iname "*$1*") || echo "$playlistPath/focus.m3u8" )" vp "$result"