0

Is there a possibility to add some text at the end of every command i type in the terminal? For example i type "ps" and after pressing enter, it becomes "ps -a", I type "ls" and it's "ls -a"

  • 6
    And rm becomes rm -a, and you get an error message for an invalid option? (same for mv) Are you sure you want to add that to each and every command line? – ilkkachu Aug 29 '18 at 20:51
  • It's a very specific setup, not going to use commands which doesn't have -a option – MSSC Sep 2 '18 at 17:17
1

It sounds like you want to create an alias in your .bashrc (hidden and located in user home directory)

Just add the following lines to your .bashrc:

alias ls='ls -a'
alias ps='ps -a'

and then run the command to source your .bashrc

source ~/.bashrc

Doing this will now cause every ls to also show hidden files (files starting with a .) and every ps you run to show all processes except both session leaders and processes not associate with a terminal.

  • Simple and reliable – MSSC Sep 2 '18 at 17:17
0

Easy to do with a shellscript:

#!/bin/bash

while :
do
    echo "\$ \c"
    read command
    [ $command == "quit" ] && break
    eval $command -a
done

Not the answer you're looking for? Browse other questions tagged or ask your own question.