diff options
author | EuAndreh <eu@euandre.org> | 2019-04-28 13:18:49 +0000 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2019-04-28 13:18:49 +0000 |
commit | 4a73dca595e57751448899053cddb958c17fe75c (patch) | |
tree | 8c1a0b9d997fc4a0531559f6b7e8102deae25f74 /bash | |
parent | Update os-installation.sh (diff) | |
parent | Split vagrant cmds. (diff) | |
download | dotfiles-4a73dca595e57751448899053cddb958c17fe75c.tar.gz dotfiles-4a73dca595e57751448899053cddb958c17fe75c.tar.xz |
Merge remote-tracking branch 'srht/master'
Diffstat (limited to 'bash')
-rw-r--r-- | bash/agents.sh | 6 | ||||
-rw-r--r-- | bash/aliases.sh | 39 | ||||
-rw-r--r-- | bash/bash_profile.sh | 4 | ||||
-rw-r--r-- | bash/bashrc.sh | 13 | ||||
-rw-r--r-- | bash/colors.sh | 3 | ||||
-rw-r--r-- | bash/config.sh | 2 | ||||
-rw-r--r-- | bash/env.sh | 9 | ||||
-rw-r--r-- | bash/facepalm/rotten-apple.sh | 4 | ||||
-rw-r--r-- | bash/fake-symlinks.sh | 31 | ||||
-rw-r--r-- | bash/init.sh | 12 | ||||
-rw-r--r-- | bash/npm.sh | 4 | ||||
-rw-r--r-- | bash/platform.sh | 4 | ||||
-rw-r--r-- | bash/symlinks.sh | 88 | ||||
-rw-r--r-- | bash/tests.sh | 2 | ||||
-rwxr-xr-x | bash/tmuxinator-templates.sh | 9 | ||||
-rw-r--r-- | bash/util.sh | 32 | ||||
-rw-r--r-- | bash/x.sh | 2 | ||||
-rw-r--r-- | bash/youtube.sh | 29 |
18 files changed, 175 insertions, 118 deletions
diff --git a/bash/agents.sh b/bash/agents.sh index 7ce1fef..d49757b 100644 --- a/bash/agents.sh +++ b/bash/agents.sh @@ -1,8 +1,10 @@ #!/usr/bin/env bash +# shellcheck disable=SC2015 eval "$(thefuck --alias f)" -export GPG_TTY=$(tty) +GPG_TTY=$(tty) +export GPG_TTY export SSH_ENV="$HOME/.ssh/environment" start_agent() { @@ -16,7 +18,7 @@ start_agent() { [ -f "${SSH_ENV}" ] && { . "${SSH_ENV}" > /dev/null - ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || { + pgrep ^ssh-agent$ > /dev/null || { start_agent } } || start_agent diff --git a/bash/aliases.sh b/bash/aliases.sh index 07c46ea..2149d86 100644 --- a/bash/aliases.sh +++ b/bash/aliases.sh @@ -6,29 +6,39 @@ alias open="xdg-open" alias ros="rlwrap ros -l ~/.sbclrc" alias l="ls -lahp" alias ll="ls -lhp" -alias yt-dl="youtube-dl -o '$YT_TEMPLATE'" -alias copy="tr -d '\n' | xclip -sel clip" +alias yt-dl="yt_dl" +isLinux && { + alias copy="tr -d '\\n' | xclip -sel clip" +} +isMac && { + alias copy="tr -d '\\n' | pbcopy" +} +alias trim="tr -d '\\n'" +alias lowercase="tr [:upper:] [:lower:]" +alias lc="tr [:upper:] [:lower:]" alias pia-vpn="sudo openvpn --config $DOTFILES/VPN/euandreh.ovpn" # Source: https://unix.stackexchange.com/questions/25327/watch-command-alias-expansion#25329 -alias watch="watch " +alias watch="watch --color " alias mr="mr -s" alias sbcl="rlwrap sbcl" alias du="ncdu --color dark" alias perl6="rlwrap perl6" alias m="mail.sh" +alias a="atom.sh" +alias n="newsboat" + +alias gnome-control-center="XDG_CURRENT_DESKTOP=GNOME gnome-control-center" alias fim="play $DOTFILES/bash/Positive.ogg &> /dev/null" alias mux="tmuxinator" -isLinux && { - ,u() { - cd ~/annex; - git annex info --fast | grep available; - cd - > /dev/null; - } - export -f ,u +u() { + pushd ~/annex > /dev/null || exit 1; + git annex info --fast | grep available; + popd > /dev/null || exit 1; } +export -f u MY_PS1="$PS1" ps1() { @@ -36,8 +46,9 @@ ps1() { } # git -alias ,s="git status" -alias ,d="git diff" -alias ,ds="git diff --staged" +alias s="git status" +alias d="git diff" +alias ds="git diff --staged" -alias ,r="source $DOTFILES/bash/tests.sh && locked_init && source ~/.bashrc" +alias reload="source $DOTFILES/bash/tests.sh && locked_init && source ~/.bashrc" +alias r="source $DOTFILES/bash/tests.sh && locked_init && source ~/.bashrc" diff --git a/bash/bash_profile.sh b/bash/bash_profile.sh index 12ce7f9..0383eaa 100644 --- a/bash/bash_profile.sh +++ b/bash/bash_profile.sh @@ -1 +1,3 @@ -source ~/annex/dev/code/dotfiles/bash/bashrc.sh +#!/usr/bin/env bash + +source ~/dev/libre/dotfiles/bash/bashrc.sh diff --git a/bash/bashrc.sh b/bash/bashrc.sh index 9ddaf6f..2e68b80 100644 --- a/bash/bashrc.sh +++ b/bash/bashrc.sh @@ -1,4 +1,6 @@ -export DOTFILES=~/annex/dev/code/dotfiles +#!/usr/bin/env bash + +export DOTFILES=~/dev/libre/dotfiles source $DOTFILES/bash/platform.sh source $DOTFILES/bash/config.sh @@ -10,7 +12,6 @@ source $DOTFILES/bash/agents.sh source $DOTFILES/bash/init.sh source $DOTFILES/bash/symlinks.sh source $DOTFILES/bash/youtube.sh -source $DOTFILES/bash/tmuxinator-templates.sh source $DOTFILES/bash/facepalm/rotten-apple.sh source $DOTFILES/bash/npm.sh source $DOTFILES/bash/x.sh @@ -24,17 +25,19 @@ source ~/dev/nu/nucli/nu.bashcompletion env > ~/.spacemacs.env # tmp FIXME: move to mrconfig.ini -export PATH="$HOME/annex/dev/code/songbooks/cli:$PATH" +export PATH="$HOME/dev/libre/songbooks/cli:$PATH" alias sb="songbooks" -source "$(dirname $(readlink $(which autojump)))/../share/autojump/autojump.bash" - +isLinux && { + source "$(dirname "$(readlink "$(command -v autojump)")")/../share/autojump/autojump.bash" +} export PATH="$HOME/.perl6/bin:$PATH" isMac && { PATH="/usr/local/opt/make/libexec/gnubin:$PATH" + PATH="/usr/local/bin:$PATH" } export PATH="$HOME/tmp/rakudobrew/bin:$PATH" diff --git a/bash/colors.sh b/bash/colors.sh index 90cabc4..68acb06 100644 --- a/bash/colors.sh +++ b/bash/colors.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +# shellcheck disable=1117 disable=1004 disable=2034 disable=2154 # Customize BASH PS1 prompt to show current GIT repository and branch. # by Mike Stewart - http://MediaDoneRight.com @@ -208,7 +209,7 @@ function lightblueb { } export -f lightblueb -function ,colors { +function colors { black "black" blackb "blackb" white "white" diff --git a/bash/config.sh b/bash/config.sh index ac9f7c2..37a4806 100644 --- a/bash/config.sh +++ b/bash/config.sh @@ -30,3 +30,5 @@ shopt -s checkwinsize isLinux && { shopt -s globstar } + +stty -ixon diff --git a/bash/env.sh b/bash/env.sh index c81cba2..a0b750f 100644 --- a/bash/env.sh +++ b/bash/env.sh @@ -1,7 +1,5 @@ #!/usr/bin/env bash -export PATH="$HOME/Nextcloud/bin/:$PATH" - # # Git Annex # @@ -32,9 +30,12 @@ export PATH=~/.local/bin:$PATH export EDITOR=vi export PATH="$DOTFILES/scripts/:$PATH" export PATH="$DOTFILES/encrypted/scripts/:$PATH" -export YT_TEMPLATE="~/Downloads/yt-dl/%(uploader)s/%(upload_date)s %(title)s.%(ext)s" export INPUTRC=~/.inputrc -export CACHE_DIR="~/Nextcloud/cache" +export CACHE_DIR="$HOME/ownCloud/cache" +export PATH="$HOME/dev/libre/website/:$PATH" +export PATH="$DOTFILES/bin:$PATH" +export PATH="$HOME/dev/misc/flutter/bin:$PATH" +#export BROWSER="firefox" diff --git a/bash/facepalm/rotten-apple.sh b/bash/facepalm/rotten-apple.sh index 50d85c8..222a2b0 100644 --- a/bash/facepalm/rotten-apple.sh +++ b/bash/facepalm/rotten-apple.sh @@ -6,8 +6,8 @@ isMac && { alias limpar-derived-data="rm -rf ~/Library/Developer/Xcode/DerivedData/" alias fim="afplay $DOTFILES/bash/facepalm/Positive.mp3" - if [ -f $(brew --prefix)/etc/bash_completion ]; then - . $(brew --prefix)/etc/bash_completion + if [ -f "$(brew --prefix)/etc/bash_completion" ]; then + . "$(brew --prefix)/etc/bash_completion" fi [ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion diff --git a/bash/fake-symlinks.sh b/bash/fake-symlinks.sh index b61e798..3a5e885 100644 --- a/bash/fake-symlinks.sh +++ b/bash/fake-symlinks.sh @@ -1,12 +1,33 @@ #!/usr/bin/env bash if [[ -n "$GITHUB_TOKEN" ]]; then - cat $DOTFILES/git/gitconfig.ini | envsubst > ~/.gitconfig + envsubst < "$DOTFILES/git/gitconfig.ini" > ~/.gitconfig fi -repos=("org.euandreh.misc" "org.euandreh.http") -for repo in ${repos[@]}; do - cp "$DOTFILES/git/gitlab-ci.yml" "$DOTFILES/../$repo/.gitlab-ci.yml" - cp "$DOTFILES/git/default.nix" "$DOTFILES/../$repo/default.nix" +SRHT_REPOS=(website mentat cement pouchdb-materialized-view pires superlogin-client) +SRHT_REPOS_PATH="$HOME/dev/libre" + +for repo in "${SRHT_REPOS[@]}"; do + REPO="$repo" envsubst < "$DOTFILES/templates/sr-ht-build.yaml" > "$SRHT_REPOS_PATH/$repo/.build.yml" +done + +for repo in "${SRHT_REPOS[@]}"; do + if [[ "$repo" != "website" ]]; then + REPO="$repo" envsubst < "$DOTFILES/templates/env.sh" > "$SRHT_REPOS_PATH/$repo/env.sh" + fi done + +mkdir -p ~/.tmuxinator + +TMUXINATOR_TEMPLATES=(annex pires songbooks sosps) + +for template in "${TMUXINATOR_TEMPLATES[@]}"; do + cp "$DOTFILES/tmux/projects/$template.yml" "$HOME/.tmuxinator/$template.yml" +done + +# DHALL_BUILD_REPOS=(website) + +# for repo in "${DHALL_BUILD_REPOS[@]}"; do +# dhall 2> /dev/null <<< "./sr-ht-build.dhall \"$repo\"" | dhall-to-json --pretty > "$SRHT_REPOS_PATH/$repo/.build.yml" +# done diff --git a/bash/init.sh b/bash/init.sh index 777a322..4e0ee65 100644 --- a/bash/init.sh +++ b/bash/init.sh @@ -1,10 +1,10 @@ #!/usr/bin/env bash locked_init() { - pushd ~/ > /dev/null + pushd ~/ > /dev/null || exit 1 mkdir -p ~/.emacs.d/.cache/ - mkdir -p $(dirname "$AUTOJUMP_TXT") + mkdir -p "$(dirname "$AUTOJUMP_TXT")" touch "$AUTOJUMP_TXT" # clone all missing repos @@ -13,12 +13,12 @@ locked_init() { printf "" > /tmp/mr-repos mr inject > /dev/null - printf "(\n" > /tmp/mr-projectile + printf "(\\n" > /tmp/mr-projectile sed -E 's/\/home\/andreh/~/' /tmp/mr-repos | awk '{print "\""$1"/""\""}' >> /tmp/mr-projectile printf ")" >> /tmp/mr-projectile cp /tmp/mr-projectile ~/.emacs.d/.cache/projectile-bookmarks.eld - popd > /dev/null + popd > /dev/null || exit 1 } export -f locked_init @@ -32,7 +32,7 @@ export -f locked_init # Tests -pushd $DOTFILES > /dev/null +pushd "$DOTFILES" > /dev/null || exit 1 sizes=$(git diff-files --ignore-submodules | awk '{print $6}' | xargs du | awk '{print $1}') for size in $sizes; do @@ -42,4 +42,4 @@ for size in $sizes; do fi done -popd > /dev/null +popd > /dev/null || exit 1 diff --git a/bash/npm.sh b/bash/npm.sh index c23c074..7fbe4f7 100644 --- a/bash/npm.sh +++ b/bash/npm.sh @@ -2,9 +2,9 @@ # FIXME: port to NixOS npm_i() { - (which $1 &> /dev/null) || { + (command -v "$1" &> /dev/null) || { yellow "Installing $2" - npm i -g $2 + npm i -g "$2" } } diff --git a/bash/platform.sh b/bash/platform.sh index efa5061..eb262e9 100644 --- a/bash/platform.sh +++ b/bash/platform.sh @@ -1,11 +1,11 @@ #!/usr/bin/env bash isMac () { - [[ `uname` == 'Darwin' ]] + [[ "$(uname)" == 'Darwin' ]] } isLinux () { - [[ `uname` == 'Linux' ]] + [[ "$(uname)" == 'Linux' ]] } isMac && { diff --git a/bash/symlinks.sh b/bash/symlinks.sh index 335189a..f6adb0c 100644 --- a/bash/symlinks.sh +++ b/bash/symlinks.sh @@ -1,72 +1,84 @@ #!/usr/bin/env bash function upsert_dir_symlink() { - local readonly from="$1" - local readonly to="$2" - ([ -d "$to" ] || [ -L "$to" ]) || { + local from="$1" + local to="$2" + { [ -d "$to" ] || [ -L "$to" ]; } || { ln -s "$from" "$to" } } export -f upsert_dir_symlink -upsert_dir_symlink $DOTFILES/encrypted/borg ~/.config/borg +upsert_dir_symlink "$DOTFILES/encrypted/borg" ~/.config/borg -ln -fs $DOTFILES/bash/bashrc.sh ~/.bashrc -ln -fs $DOTFILES/bash/bash_profile.sh ~/.bash_profile -ln -fs $DOTFILES/git/gitattributes ~/.gitattributes -ln -fs $DOTFILES/git/gitignore ~/.gitignore_global -ln -fs $DOTFILES/git/bash_git.sh ~/.bash_git -ln -fs $DOTFILES/sbclrc.lisp ~/.sbclrc -ln -fs $DOTFILES/inputrc.conf ~/.inputrc -ln -fs $DOTFILES/Xmodmap.conf ~/.Xmodmap +ln -fs "$DOTFILES/bash/bashrc.sh" ~/.bashrc +ln -fs "$DOTFILES/bash/bash_profile.sh" ~/.bash_profile +ln -fs "$DOTFILES/git/gitattributes" ~/.gitattributes +ln -fs "$DOTFILES/git/gitignore" ~/.gitignore_global +ln -fs "$DOTFILES/git/bash_git.sh" ~/.bash_git +ln -fs "$DOTFILES/encrypted/nugitconfig.ini" ~/.nugitconfig +ln -fs "$DOTFILES/sbclrc.lisp" ~/.sbclrc +ln -fs "$DOTFILES/inputrc.conf" ~/.inputrc +ln -fs "$DOTFILES/Xmodmap.conf" ~/.Xmodmap isLinux && { - ln -fs $DOTFILES/nixos/npmrc.sh ~/.npmrc + ln -fs "$DOTFILES/nixos/npmrc.sh" ~/.npmrc } -ln -fs $DOTFILES/git/mrconfig.ini ~/.mrconfig +## SSH config +mkdir -p ~/.ssh +ln -fs "$DOTFILES/ssh_config.conf" ~/.ssh/config -upsert_dir_symlink $MEDIA_PREFIX/UTCLOUD ~/UTCLOUD -upsert_dir_symlink $MEDIA_PREFIX/SNEAKER ~/SNEAKER +ln -fs "$DOTFILES/git/mrconfig.ini" ~/.mrconfig + +upsert_dir_symlink "$MEDIA_PREFIX/UTCLOUD" ~/UTCLOUD +upsert_dir_symlink "$MEDIA_PREFIX/SNEAKER" ~/SNEAKER ## Clojure mkdir -p ~/.lein ~/.clojure -ln -fs $DOTFILES/lein/profiles.clj ~/.lein/profiles.clj -ln -fs $DOTFILES/lein/deps.edn ~/.clojure/deps.edn +ln -fs "$DOTFILES/lein/profiles.clj" ~/.lein/profiles.clj +ln -fs "$DOTFILES/lein/deps.edn" ~/.clojure/deps.edn ## AWS mkdir -p ~/.aws -ln -fs $DOTFILES/encrypted/aws/config ~/.aws/config -ln -fs $DOTFILES/encrypted/aws/credentials ~/.aws/credentials +ln -fs "$DOTFILES/encrypted/aws/config" ~/.aws/config +ln -fs "$DOTFILES/encrypted/aws/credentials" ~/.aws/credentials ## tmux -ln -fs $DOTFILES/tmux/tmux.conf ~/.tmux.conf -ln -fs $DOTFILES/tmux/tmux-macos.conf ~/.tmux-macos.conf -ln -fs $DOTFILES/tmux/tmux-gnu-linux.conf ~/.tmux-gnu-linux.conf +ln -fs "$DOTFILES/tmux/tmux.conf" ~/.tmux.conf +ln -fs "$DOTFILES/tmux/tmux-macos.conf" ~/.tmux-macos.conf +ln -fs "$DOTFILES/tmux/tmux-gnu-linux.conf" ~/.tmux-gnu-linux.conf + +## Newsboat +mkdir -p ~/.newsboat +ln -fs "$DOTFILES/newsboat/config" ~/.newsboat/config ## NixOS -ln -fs $DOTFILES/nixos/evince.destkop ~/.local/share/applications/evince.desktop -ln -fs $DOTFILES/nixos/firefox.destkop ~/.local/share/applications/firefox.desktop +ln -fs "$DOTFILES/nixos/evince.destkop" ~/.local/share/applications/evince.desktop +ln -fs "$DOTFILES/nixos/firefox.destkop" ~/.local/share/applications/firefox.desktop ## Emacs -mkdir -p $HOME/.emacs.d/private/layers/ -ln -fs $DOTFILES/spacemacs.el ~/.spacemacs -ln -fs $DOTFILES/emacs/gnus.el ~/.gnus.el -ln -fs $CACHE_DIR/euandreh-auto-save.el ~/.emacs.d/.cache/layouts/euandreh-auto-save +mkdir -p "$HOME/.emacs.d/private/layers/" +ln -fs "$DOTFILES/spacemacs.el" ~/.spacemacs +ln -fs "$DOTFILES/emacs/gnus.el" ~/.gnus.el +ln -fs "$CACHE_DIR/euandreh-auto-save.el" ~/.emacs.d/.cache/layouts/euandreh-auto-save ## xmonad mkdir -p ~/.xmonad -ln -fs $DOTFILES/xmonad/xsession.sh ~/.xsession -ln -fs $DOTFILES/xmonad/xmonad.hs ~/.xmonad/xmonad.hs -ln -fs $DOTFILES/xmonad/xmobar.hs ~/.xmobarrc +ln -fs "$DOTFILES/xmonad/xsession.sh" ~/.xsession +ln -fs "$DOTFILES/xmonad/xmonad.hs" ~/.xmonad/xmonad.hs +ln -fs "$DOTFILES/xmonad/xmobar.hs" ~/.xmobarrc ## Mail mkdir -p ~/mbsync/.notmuch/hooks ~/mbsync/EuAndreh ~/mbsync/Gmail ~/mbsync/Nubank -ln -fs $DOTFILES/mail/notmuch-post.sh ~/mbsync/.notmuch/hooks/post-new -ln -fs $DOTFILES/mail/mbsyncrc.ini ~/.mbsyncrc -ln -fs $DOTFILES/mail/notmuch.ini ~/.notmuch-config -ln -fs /tmp/mbsync.$(date +%Y-%m-%d).log /tmp/mbsync.log -ln -fs /tmp/notmuch.$(date +%Y-%m-%d).log /tmp/notmuch.log +ln -fs "$DOTFILES/mail/notmuch-post.sh" ~/mbsync/.notmuch/hooks/post-new +ln -fs "$DOTFILES/mail/mbsyncrc.ini" ~/.mbsyncrc +ln -fs "$DOTFILES/mail/notmuch.ini" ~/.notmuch-config +ln -fs /tmp/mbsync."$(date +%Y-%m-%d)".log /tmp/mbsync.log +ln -fs /tmp/notmuch."$(date +%Y-%m-%d)".log /tmp/notmuch.log ## GNUS -ln -fs $DOTFILES/encrypted/IMAP/authinfo.gpg ~/.authinfo.gpg +ln -fs "$DOTFILES/encrypted/IMAP/authinfo.gpg" ~/.authinfo.gpg + +## Buku +ln -fs /tmp/buku-xmonad."$(date +%Y-%m-%d)".log /tmp/buku-xmonad.log diff --git a/bash/tests.sh b/bash/tests.sh index 1fdfd79..6941614 100644 --- a/bash/tests.sh +++ b/bash/tests.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash -autotime test > /dev/null +# autotime test > /dev/null diff --git a/bash/tmuxinator-templates.sh b/bash/tmuxinator-templates.sh deleted file mode 100755 index adbbb5c..0000000 --- a/bash/tmuxinator-templates.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -mkdir -p ~/.tmuxinator - -templates=(annex pires songbooks sosps) - -for template in ${templates[@]}; do - cp $DOTFILES/tmux/projects/$template.yml ~/.tmuxinator/$template.yml -done diff --git a/bash/util.sh b/bash/util.sh index 833bc9c..e29d02f 100644 --- a/bash/util.sh +++ b/bash/util.sh @@ -1,20 +1,20 @@ #!/usr/bin/env bash extract () { - if [ -f $1 ] ; then - case $1 in - *.tar.bz2) tar xvjf $1 ;; - *.tar.gz) tar xvzf $1 ;; - *.bz2) bunzip2 $1 ;; - *.rar) unrar x $1 ;; - *.gz) gunzip $1 ;; - *.tar) tar xvf $1 ;; - *.tbz2) tar xvjf $1 ;; - *.tgz) tar xvzf $1 ;; - *.zip) unzip $1 ;; - *.Z) uncompress $1 ;; - *.7z) 7z x $1 ;; - *.xz) unxz $1 ;; + if [ -f "$1" ] ; then + case "$1" in + *.tar.bz2) tar xvjf "$1" ;; + *.tar.gz) tar xvzf "$1" ;; + *.bz2) bunzip2 "$1" ;; + *.rar) unrar x "$1" ;; + *.gz) gunzip "$1" ;; + *.tar) tar xvf "$1" ;; + *.tbz2) tar xvjf "$1" ;; + *.tgz) tar xvzf "$1" ;; + *.zip) unzip "$1" ;; + *.Z) uncompress "$1" ;; + *.7z) 7z x "$1" ;; + *.xz) unxz "$1" ;; *) echo "don't know how to extract '$1'..." ;; esac else @@ -24,11 +24,11 @@ extract () { merkle-tree () { dirname="${1-.}" - pushd "$dirname" > /dev/null + pushd "$dirname" > /dev/null || exit 1 find . -type f | \ sort | \ xargs -I{} sha256sum "{}" | \ sha256sum | \ awk '{print $1}' - popd > /dev/null + popd > /dev/null || exit 1 } @@ -15,4 +15,6 @@ isLinux && { xdg-settings set default-web-browser firefox.desktop xdg-mime default firefox.desktop text/html xdg-mime default firefox.desktop text/xml + + xdg-mime default nautilus.desktop inode/directory # FIXME } diff --git a/bash/youtube.sh b/bash/youtube.sh index c732e26..275e0b8 100644 --- a/bash/youtube.sh +++ b/bash/youtube.sh @@ -2,44 +2,53 @@ export DEFAULT_PLAYLIST_END=15 export DEFAULT_INC_STEP=10 +export YT_TEMPLATE="$HOME/Downloads/yt-dl/%(uploader)s/%(upload_date)s %(title)s.%(ext)s" +# Always downloads video, doesn't look at the download-archive +yt_dl() { + youtube-dl "$1" -o "$YT_TEMPLATE" --write-description +} +export -f yt_dl download() { youtube-dl "$1" \ - --download-archive ~/Nextcloud/cache/youtube-dl-seen.conf \ - --prefer-free-formats \ - --playlist-end $2 \ - --output "~/Downloads/yt-dl/%(uploader)s/%(upload_date)s - %(title)s.%(ext)s" + --download-archive ~/ownCloud/cache/youtube-dl-seen.conf \ + --prefer-free-formats \ + --playlist-end "$2" \ + --write-description \ + --output "$YT_TEMPLATE" } export -f download download_user() { - download "https://www.youtube.com/user/$1" ${2-$DEFAULT_PLAYLIST_END} + download "https://www.youtube.com/user/$1" "${2-$DEFAULT_PLAYLIST_END}" } export -f download_user download_channel() { - download "https://www.youtube.com/channel/$1" ${2-$DEFAULT_PLAYLIST_END} + download "https://www.youtube.com/channel/$1" "${2-$DEFAULT_PLAYLIST_END}" } export -f download_channel download_playlist() { - download "https://www.youtube.com/playlist?list=$1" ${2-$DEFAULT_PLAYLIST_END} + download "https://www.youtube.com/playlist?list=$1" "${2-$DEFAULT_PLAYLIST_END}" } export -f download_playlist - inc_download() { local fn="$1" local id="$2" local step="${3-$DEFAULT_INC_STEP}" local file="$HOME/.yt-db/$id" - local n_count="$(cat $file 2> /dev/null || printf 10)" - local n_count_new="$(($n_count + $step))" + mkdir -p "$HOME/.yt-db" + cat "$file" 2> /dev/null + local n_count + n_count="$(cat "$file" 2> /dev/null || printf 10)" + local n_count_new="$((n_count + step))" echo "$n_count_new" > "$file" |