Home > shell > Set alias which doesn't send specified text?

Set alias which doesn't send specified text?

May 11Hits:1
Advertisement

EDIT

I set a alias task in ~/.bashrc. The following:

alias join="clear; screen -ls; screen -rx [<ID_OF_THE_RUNNING_SCREEN> quit]" 

If i the task join is executed, the following has to pre-fill my commandline:

screen -rx I will add [<ID_OF_THE_RUNNING_SCREEN>] quit.

-- How does I have to edit the alias, that this will be my result? --

Answers

If you just want to prompt for user input after displaying the screen -ls results, I think you could do that using a shell read command. Note, I'm writing this as a shell function although since it doesn't require comandline arguments I don't know of any reason you couldn't define it as an alias, it just seems a bit "big" for an alias. For example, in bash :

function join() {
    clear
    screen -ls
    read -p "enter session " args
    screen -rx "$args"
}

You could simulate interactive execution of the final screen -r command just by making the prompt text equal to the command text i.e.

function join() {
    clear
    screen -ls
    read -p "screen -rx " args
    screen -rx "$args"
}

or making use of eval, possibly even

function join() {
    clear
    screen -ls
    cmd="echo screen -rx"
    read -p "$cmd " args
    eval "$cmd" "$args"
}

Related Articles

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.648 s.