From 8d30d0710597440c5f47c6e3b2183d1dd001c7ab Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 7 Feb 2022 13:48:26 +0100 Subject: [PATCH] Improve things? Probably? --- functions/fish_prompt.fish | 16 +++++--- functions/regex_mv.fish | 29 -------------- functions/sdl.fish | 4 +- functions/update_peertube.fish | 73 ---------------------------------- 4 files changed, 12 insertions(+), 110 deletions(-) delete mode 100644 functions/regex_mv.fish delete mode 100644 functions/update_peertube.fish diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish index 588465c..a85fe41 100644 --- a/functions/fish_prompt.fish +++ b/functions/fish_prompt.fish @@ -36,8 +36,8 @@ function fish_prompt # 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" set -g "CURRENT_IP" (who | grep "$USER" | awk '{print $5}') end @@ -47,11 +47,13 @@ function fish_prompt end if test -z "$CURRENT_IP" - set_color magenta - else if test "$CURRENT_IP" "=" "(:0)" set_color green - else + else if test "$CURRENT_IP" "=" "(:0)" + set_color brgreen + else if string match --regex '\(.+\)' "$CURRENT_IP" set_color cyan + else + set_color green end echo -n (prompt_hostname) @@ -63,8 +65,10 @@ function fish_prompt # Current working directory - if not test -x . + if not test -e "$PWD" set_color brblack + else if not test -x . + set_color white else if not test -r . set_color white else if not test -w . diff --git a/functions/regex_mv.fish b/functions/regex_mv.fish deleted file mode 100644 index caaebee..0000000 --- a/functions/regex_mv.fish +++ /dev/null @@ -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 diff --git a/functions/sdl.fish b/functions/sdl.fish index 1383fec..72e8453 100644 --- a/functions/sdl.fish +++ b/functions/sdl.fish @@ -1,3 +1,3 @@ -function sdl --wraps='journalctl -u' --description 'alias sdl journalctl -u' - journalctl -u $argv; +function sdj --wraps='journalctl -u' --description 'alias sdj journalctl -u' + journalctl -u $argv; end diff --git a/functions/update_peertube.fish b/functions/update_peertube.fish deleted file mode 100644 index eecb3bd..0000000 --- a/functions/update_peertube.fish +++ /dev/null @@ -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 \ No newline at end of file