def chain_commands(commands):
  """Chain commands together using `&&` "and" operator

  Parameters
  ----------
  commands : list
    A list of commands to be chained together

  Returns
  -------
  str
    Chained command
  """
  # separate them
  if isinstance(commands, type('42')):
    commands = commands.split('&&')
  # get root command
  root = commands[0]
  # add exec to subsequent commands
  subseq = [ 'exec {}'.format(command) for command in commands[1:] ]
  # chain them
  return root + ' ' + ' && '.join(subseq)