function core_cli_bashrc

3.x core.drush.inc core_cli_bashrc($drush_command)
4.x core.drush.inc core_cli_bashrc($drush_command, $interactive_mode)

File

commands/core/core.drush.inc, line 789
Core drush commands.

Code

function core_cli_bashrc($drush_command) {
  // Set up our default bashrc file for the drush cli
  $bashrc_data = <<<EOD

PS1="drush> "

alias on="$drush_command"
alias drush="$drush_command"
DRUSH_CLI=true


function cdd() {
  TARGET=
  PARAM=\$1
  if [ \$# -gt 1 ] ; then
    TARGET=\$1
    PARAM=\$2
  fi
  DEST=`drush \$TARGET drupal-directory \$PARAM`
  if [ \$? != 0 ] || [ -z "\$DEST" ]
  then
    echo "Target \$1 was not found."
  else
    echo "cd \$DEST"
    cd \$DEST;
  fi
}

function lsd() {
  TARGET=
  PARAM=\$1
  if [ \$# -gt 1 ] ; then
    TARGET=\$1
    PARAM=\$2
  fi
  DEST=`drush \$TARGET drupal-directory \$PARAM`
  if [ \$? != 0 ] || [ -z "\$DEST" ]
  then
    echo "Target \$1 was not found."
  else
    echo "ls \$DEST"
    ls \$DEST;
  fi
}

EOD;

  // Add aliases for all of our commands
  $commands = drush_get_commands();
  foreach ($commands as $key => $command) {
    // Filter out old commands that still have spaces
    if (strpos($key, ' ') === FALSE) {
      $bashrc_data .= "function $key() {\n  $drush_command $key \"\$@\"\n}\n";
    }
  }

  return $bashrc_data;
}