Skip to content

Instantly share code, notes, and snippets.

@mgol
Last active April 25, 2017 10:28
Show Gist options
  • Select an option

  • Save mgol/10657381 to your computer and use it in GitHub Desktop.

Select an option

Save mgol/10657381 to your computer and use it in GitHub Desktop.

Revisions

  1. mgol revised this gist Jan 26, 2015. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions psa
    Original file line number Diff line number Diff line change
    @@ -3,17 +3,17 @@
    # Usage: move this file to ~/bin/ and create a link ~/bin/psa-full -> psa.
    # `psa STRING` will show you the output clipped to current number of columns in
    # the terminal, `psa-full STRING` will give the full output.
    # Tested on OS X 10.9.
    # Tested on OS X 10.9-10.10.

    if [[ "`basename "$0"`" == *-full ]]; then
    COLS=10000
    COLS=10000
    else
    COLS=`tput cols`
    COLS=`tput cols`
    fi
    PS_COMMAND='ps axo pid,ppid,tty,user,group,time,pcpu,pmem,args'

    if [ $# -eq 0 ]; then
    eval "$PS_COMMAND" | cut -b1-$COLS
    eval "$PS_COMMAND" | cut -b1-$COLS
    else
    eval "$PS_COMMAND" | egrep -v "(/bin/sh $HOME/bin/psa|$PS_COMMAND|egrep)" | egrep -i '(PID\s+PPID\s+TTY\s+USER\s+GID\s+TIME\s+\%CPU\s+\%MEM\s+ARGS|'"$1"')' | cut -b1-$COLS
    eval "$PS_COMMAND" | egrep -v "(/bin/sh $HOME/bin/psa|$PS_COMMAND|egrep)" | egrep -i '(PID\s+PPID\s+TTY\s+USER\s+GID\s+TIME\s+\%CPU\s+\%MEM\s+ARGS|'"$1"')' | cut -b1-$COLS
    fi
  2. mgol revised this gist Apr 14, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions psa
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,7 @@
    # Usage: move this file to ~/bin/ and create a link ~/bin/psa-full -> psa.
    # `psa STRING` will show you the output clipped to current number of columns in
    # the terminal, `psa-full STRING` will give the full output.
    # Tested on OS X 10.9.

    if [[ "`basename "$0"`" == *-full ]]; then
    COLS=10000
  3. mgol revised this gist Apr 14, 2014. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions psa
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,9 @@
    #!/bin/sh

    # Usage: move this file to ~/bin/ and create a link ~/bin/psa-full -> psa.
    # `psa STRING` will show you the output clipped to current number of columns in
    # the terminal, `psa-full STRING` will give the full output.

    if [[ "`basename "$0"`" == *-full ]]; then
    COLS=10000
    else
  4. mgol created this gist Apr 14, 2014.
    14 changes: 14 additions & 0 deletions psa
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    #!/bin/sh

    if [[ "`basename "$0"`" == *-full ]]; then
    COLS=10000
    else
    COLS=`tput cols`
    fi
    PS_COMMAND='ps axo pid,ppid,tty,user,group,time,pcpu,pmem,args'

    if [ $# -eq 0 ]; then
    eval "$PS_COMMAND" | cut -b1-$COLS
    else
    eval "$PS_COMMAND" | egrep -v "(/bin/sh $HOME/bin/psa|$PS_COMMAND|egrep)" | egrep -i '(PID\s+PPID\s+TTY\s+USER\s+GID\s+TIME\s+\%CPU\s+\%MEM\s+ARGS|'"$1"')' | cut -b1-$COLS
    fi