Skip to content

Commit

Permalink
Merge pull request #2281 from Bash-it/ira/cleanup3
Browse files Browse the repository at this point in the history
  • Loading branch information
seefood authored Jan 26, 2025
2 parents 44623ff + 99fe7fd commit 14ee27c
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 22 deletions.
6 changes: 6 additions & 0 deletions clean_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,18 @@ plugins/available/osx-timemachine.plugin.bash
plugins/available/osx.plugin.bash
plugins/available/percol.plugin.bash
plugins/available/plenv.plugin.bash
plugins/available/postgres.plugin.bash
plugins/available/projects.plugin.bash
plugins/available/proxy.plugin.bash
plugins/available/pyenv.plugin.bash
plugins/available/python.plugin.bash
plugins/available/rails.plugin.bash
plugins/available/rbenv.plugin.bash
plugins/available/ruby.plugin.bash
plugins/available/rvm.plugin.bash
plugins/available/ssh.plugin.bash
plugins/available/sshagent.plugin.bash
plugins/available/subversion.plugin.bash
plugins/available/sudo.plugin.bash
plugins/available/textmate.plugin.bash
plugins/available/thefuck.plugin.bash
Expand Down
1 change: 1 addition & 0 deletions plugins/available/pipsi.plugin.bash
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# shellcheck shell=bash
cite about-plugin
about-plugin 'load pipsi, if you are using it'

Expand Down
19 changes: 10 additions & 9 deletions plugins/available/postgres.plugin.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
cite about-plugin
about-plugin 'postgres helper functions'

export PGVERSION=$(pg_config --version | awk '{print $2}')
export POSTGRES_BIN=$(pg_config --bindir)
PGVERSION=$(pg_config --version | awk '{print $2}')
POSTGRES_BIN=$(pg_config --bindir)
export POSTGRES_BIN PGVERSION
COMMON_PGDATA_PATHS=("/usr/local/var/postgres" "/var/pgsql" "/Library/Server/PostgreSQL/Data")
for possible in "${COMMON_PGDATA_PATHS[@]}"; do
:
Expand All @@ -18,22 +19,22 @@ function postgres_start {
group 'postgres'

echo 'Starting Postgres....'
$POSTGRES_BIN/pg_ctl -D $PGDATA -l $PGDATA/logfile start
"$POSTGRES_BIN/pg_ctl" -D "$PGDATA" -l "$PGDATA/logfile" start
}

function postgres_stop {
about 'Stops PostgreSQL server'
group 'postgres'

echo 'Stopping Postgres....'
$POSTGRES_BIN/pg_ctl -D $PGDATA -l $PGDATA/logfile stop -s -m fast
"$POSTGRES_BIN/pg_ctl" -D "$PGDATA" -l "$PGDATA/logfile" stop -s -m fast
}

function postgres_status {
about 'Returns status of PostgreSQL server'
group 'postgres'

# $POSTGRES_BIN/pg_ctl -D $PGDATA status
# "$POSTGRES_BIN/pg_ctl" -D "$PGDATA status"
if [[ $(is_postgres_running) == "no server running" ]]; then
echo "Postgres service [STOPPED]"
else
Expand All @@ -42,29 +43,29 @@ function postgres_status {
}

function is_postgres_running {
$POSTGRES_BIN/pg_ctl -D $PGDATA status | grep -F -o "no server running"
"$POSTGRES_BIN/pg_ctl" -D "$PGDATA" status | grep -F -o "no server running"
}

function postgres_restart {
about 'Restarts status of PostgreSQL server'
group 'postgres'

echo 'Restarting Postgres....'
$POSTGRES_BIN/pg_ctl -D $PGDATA restart
"$POSTGRES_BIN/pg_ctl" -D "$PGDATA" restart
}

function postgres_logfile {
about 'View the last 500 lines from logfile'
group 'postgres'

tail -500 $PGDATA/logfile | less
tail -500 "$PGDATA/logfile" | less
}

function postgres_serverlog {
about 'View the last 500 lines from server.log'
group 'postgres'

tail -500 $PGDATA/server.log | less
tail -500 "$PGDATA/server.log" | less
}

# function postgres_syslog {
Expand Down
5 changes: 3 additions & 2 deletions plugins/available/rails.plugin.bash
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# shellcheck shell=bash
cite about-plugin
about-plugin 'Helper functions for Ruby on Rails'

Expand All @@ -7,9 +8,9 @@ function killrails() {
group 'rails'

railsPid="$(cat tmp/pids/server.pid)"
if [ ! -z "$railsPid" ]; then
if [ -n "$railsPid" ]; then
echo "[OK] Rails Server Process Id : ${railsPid}"
kill -9 $railsPid
kill -9 "$railsPid"
echo "[OK] Process Killed"
else
echo "[FAIL] Error killing Rails server"
Expand Down
18 changes: 11 additions & 7 deletions plugins/available/rvm.plugin.bash
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
# shellcheck shell=bash
# Load RVM, if you are using it

cite about-plugin
about-plugin 'load rvm, if you are using it'

# shellcheck disable=SC1091
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

# Check to make sure that RVM is actually loaded before adding
# the customizations to it.
if [ "$rvm_path" ]; then
# Load the auto-completion script if RVM was loaded.
[[ -r $rvm_path/scripts/completion ]] && . $rvm_path/scripts/completion
# shellcheck disable=SC1091
[[ -r "$rvm_path/scripts/completion" ]] && . "$rvm_path/scripts/completion"

switch() {
rvm $1
local v=$(rvm_version)
rvm wrapper $1 textmate
echo "Switch to Ruby version: "$v
rvm "$1"
local v
v=$(rvm_version)
rvm wrapper "$1" textmate
echo "Switch to Ruby version: $v"
}

rvm_default() {
rvm --default $1
rvm wrapper $1 textmate
rvm --default "$1"
rvm wrapper "$1" textmate
}

function rvm_version() {
Expand Down
1 change: 1 addition & 0 deletions plugins/available/ssh.plugin.bash
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# shellcheck shell=bash
cite about-plugin
about-plugin 'ssh helper functions'

Expand Down
6 changes: 3 additions & 3 deletions plugins/available/sshagent.plugin.bash
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
# shellcheck shell=bash
cite about-plugin
about-plugin 'sshagent helper functions'

Expand All @@ -22,8 +22,8 @@ function _get_process_status_field() {
pid="${1}"
field="${2}"
status_file="/proc/${pid}/status"
if ! ([[ -d "${status_file%/*}" ]] \
&& [[ -r "${status_file}" ]]); then
if ! { [[ -d "${status_file%/*}" ]] \
&& [[ -r "${status_file}" ]]; }; then
echo ""
return
fi
Expand Down
3 changes: 2 additions & 1 deletion plugins/available/subversion.plugin.bash
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# shellcheck shell=bash
cite about-plugin
about-plugin 'svn helper functions'

Expand All @@ -10,7 +11,7 @@ rm_svn() {
reference rm_svn
return
fi
find $1 -name .svn -print0 | xargs -0 rm -rf
find "$1" -name .svn -print0 | xargs -0 rm -rf
}

svn_add() {
Expand Down

0 comments on commit 14ee27c

Please sign in to comment.