1
Fork 0
mirror of https://github.com/Steffo99/config-fish.git synced 2024-12-22 23:04:22 +00:00

Improve things? Probably?

This commit is contained in:
Steffo 2022-02-07 13:48:26 +01:00
parent afd8eb6f54
commit 8d30d07105
4 changed files with 12 additions and 110 deletions

View file

@ -36,7 +36,7 @@ function fish_prompt
# Hostname # Hostname
set -g CURRENT_IP (who am i | awk '{print $5}') set -g "CURRENT_IP" (who -m | awk '{print $5}')
if test -z "$CURRENT_IP" if test -z "$CURRENT_IP"
set -g "CURRENT_IP" (who | grep "$USER" | awk '{print $5}') set -g "CURRENT_IP" (who | grep "$USER" | awk '{print $5}')
@ -47,11 +47,13 @@ function fish_prompt
end end
if test -z "$CURRENT_IP" if test -z "$CURRENT_IP"
set_color magenta
else if test "$CURRENT_IP" "=" "(:0)"
set_color green set_color green
else else if test "$CURRENT_IP" "=" "(:0)"
set_color brgreen
else if string match --regex '\(.+\)' "$CURRENT_IP"
set_color cyan set_color cyan
else
set_color green
end end
echo -n (prompt_hostname) echo -n (prompt_hostname)
@ -63,8 +65,10 @@ function fish_prompt
# Current working directory # Current working directory
if not test -x . if not test -e "$PWD"
set_color brblack set_color brblack
else if not test -x .
set_color white
else if not test -r . else if not test -r .
set_color white set_color white
else if not test -w . else if not test -w .

View file

@ -1,29 +0,0 @@
function regex_mv
echo_progress "Find: "
echo_highlight "$argv[1]"
echo
echo_progress "Replace with: "
echo_highlight "$argv[2]"
echo
echo
for old in (ls)
set new (echo $old | sed -r "s/$argv[1]/$argv[2]/g")
echo_progress "$old"
echo_highlight "$new"
echo
end
if not confirm
return 1
end
for old in (ls)
set new (echo $old | sed -r "s/$argv[1]/$argv[2]/g")
mv "$old" "$new"
end
end

View file

@ -1,3 +1,3 @@
function sdl --wraps='journalctl -u' --description 'alias sdl journalctl -u' function sdj --wraps='journalctl -u' --description 'alias sdj journalctl -u'
journalctl -u $argv; journalctl -u $argv;
end end

View file

@ -1,73 +0,0 @@
function update_peertube
set -g PEERTUBE_USER "$argv[1]"
if test -z PEERTUBE_USER
echo_error "Missing argument 1: PEERTUBE_USER" \n
return 1
else
echo_progress "Peertube user is: "
echo_highlight "$PEERTUBE_USER" \n
end
set -g INSTALL_DIR "$argv[2]"
if test -z INSTALL_DIR
echo_error "Missing argument 2: INSTALL_DIR" \n
return 1
else
echo_progress "Install dir is: "
echo_highlight "$INSTALL_DIR" \n
end
set -g BACKUP_DIR "$INSTALL_DIR/backup"
set -g BACKUP_PATH "$BACKUP_DIR/sql-peertube_prod-"(date -Im)".bak"
echo_progress "Backup path will be: "
echo_highlight "$BACKUP_PATH" \n
set -g LATEST (curl -s https://api.github.com/repos/chocobozzz/peertube/releases/latest | grep tag_name | cut -d '"' -f 4)
echo_progress "Updating to Peertube "
echo_highlight "$LATEST" \n
confirm
echo_progress "Creating backup dir..." \n
mkdir -p "$BACKUP_DIR"
echo_progress "Dumping the database to the backup dir..." \n
pg_dump -F custom "peertube_prod" > "$BACKUP_PATH"
set -g VERSIONS_DIR "$INSTALL_DIR/versions"
echo_progress "Versions dir is: "
echo_highlight "$VERSIONS_DIR" \n
echo_progress "Downloading $LATEST from GitHub Releases..." \n
wget -q "https://github.com/Chocobozzz/PeerTube/releases/download/$LATEST/peertube-$LATEST.zip" -O "$VERSIONS_DIR/peertube-$LATEST.zip"
echo_progress "Unzipping..." \n
unzip -d "$VERSIONS_DIR" "$VERSIONS_DIR/peertube-$LATEST.zip"
set -g LATEST_DIR "$VERSIONS_DIR/peertube-$LATEST"
echo_progress "Version $LATEST dir is: "
echo_highlight "$LATEST_DIR" \n
echo_progress "Giving back all permissions to: $PEERTUBE_USER" \n
chown -R "$PEERTUBE_USER:" "$INSTALL_DIR"
echo_progress "Updating node dependencies..." \n
sudo -i -u $PEERTUBE_USER yarn --cwd "$LATEST_DIR" install --production --pure-lockfile
echo_progress "Ignoring configuration file update, it never changes anyways" \n
echo_progress "You can see the new one at: "
echo_highlight "$LATEST_DIR/config/default.yaml"
echo_progress "Ignoring nginx virtualhost update, we are using apache httpd" \n
echo_progress "You can see the new one at: "
echo_highlight "$LATEST_DIR/support/nginx/peertube"
echo_progress "Ignoring systemd unit file update, it never changes anyways" \n
echo_progress "You can see the new one at: "
echo_highlight "$LATEST_DIR/support/systemd/peertube.service"
echo_progress "Updating peertube-latest symlink..."
unlink "$INSTALL_DIR/peertube-latest"
ln -s "$LATEST_DIR" "$INSTALL_DIR/peertube-latest"
echo_progress "Update complete!"
end