diff options
author | Tharre <tharre3@gmail.com> | 2018-05-09 02:58:18 +0200 |
---|---|---|
committer | Tharre <tharre3@gmail.com> | 2018-05-09 17:28:13 +0200 |
commit | 321d9a8247d50cd634615ffed707aed3f4376108 (patch) | |
tree | 32fbd27e3a9e8c3f41d68232ffe203ef0ce10999 /.zshrc | |
parent | 3cb67ddae1d11e4cda22b9843665b6d3775828da (diff) | |
download | dotfiles-321d9a8247d50cd634615ffed707aed3f4376108.tar.gz dotfiles-321d9a8247d50cd634615ffed707aed3f4376108.tar.xz dotfiles-321d9a8247d50cd634615ffed707aed3f4376108.zip |
Move various scripts and functions into bin/
Diffstat (limited to '.zshrc')
-rw-r--r-- | .zshrc | 89 |
1 files changed, 1 insertions, 88 deletions
@@ -108,95 +108,8 @@ function 256color_test { done ) } -function utf8font_test { - curl http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-demo.txt -} - -# requires youtube-dl, mpv -function play { - # Skip DASH manifest for speed purposes. This might actually disable - # being able to specify things like 'bestaudio' as the requested format, - # but try anyway. - # Use "$*" so that quoting the requested song isn't necessary. - mpv $(youtube-dl --default-search=ytsearch: \ - --max-downloads 1 \ - --youtube-skip-dash-manifest \ - --format="bestaudio/best" \ - -g "$*") --no-video -} - -function set_xdg_dirs { - xdg-user-dirs-update --set DESKTOP ~/var/desktop - xdg-user-dirs-update --set DOWNLOAD ~/var/downloads - xdg-user-dirs-update --set TEMPLATES ~/var/templates - xdg-user-dirs-update --set PUBLICSHARE ~/share/public - xdg-user-dirs-update --set DOCUMENTS ~/var/documents - xdg-user-dirs-update --set MUSIC ~/media/music - xdg-user-dirs-update --set PICTURES ~/media/pictures - xdg-user-dirs-update --set VIDEOS ~/media/videos - - rmdir ~/Desktop ~/Downloads ~/Templates ~/Public ~/Documents ~/Music \ - ~/Pictures ~/Videos -} - -# update -function update_dotfiles() { - dotfiles="$HOME/dotfiles" - epoch_file="$dotfiles/.updated" - epoch_curr=$(date +'%s') - [ -e "$epoch_file" ] && epoch_old=$(<"$epoch_file") - epoch_diff=$(($epoch_curr - ${epoch_old:-0})) - max_time=$((60 * 60 * 24 * 7)) - - if [ $(($epoch_diff / $max_time)) -ne 0 ]; then - echo "Updating dotfiles ..." - - cd "$dotfiles" - git pull --rebase --stat origin master - echo $epoch_curr > "$epoch_file" - ./install.sh - cd - - - echo "Finished." - fi -} - -function suspend_after() { - trap 'kill $!' INT TERM EXIT - systemd-inhibit --what=handle-lid-switch sleep 1d & - eval "$*" - systemctl suspend -} - -function reset_usb() { - for i in /sys/bus/pci/drivers/[uoex]hci_hcd/*:*; do - echo "${i##*/}" | sudo tee "${i%/*}/"{unbind,bind} - done -} - -function setup_borgbackup() { - setopt ERR_RETURN - - BORG_SECRET=~/.borg_secret - BORG_SSH_KEY=~/.ssh/borg_key - - if [ ! -f "$BORG_SECRET" ]; then - install -m600 /dev/null "$BORG_SECRET" - pass backups/$(hostname) > "$BORG_SECRET" - fi - - if [ ! -f "$BORG_SSH_KEY" ]; then - ssh-keygen -q -N "" -f "$BORG_SSH_KEY" - KEY=$(< ${BORG_SSH_KEY}.pub) - - printf '%s\n' "command=\"cd /srv/borgbackup/repos/$(hostname);borg serve --restrict-to-path /srv/borgbackup/repos/$(hostname)\",restrict $KEY" | ssh "$1" "cat >> /srv/borgbackup/.ssh/authorized_keys" - - echo "Added key to remote server." - fi -} - ## PATH -export PATH=$PATH:$HOME/bin +export PATH="$HOME/bin:$PATH" ## alias |