Find the answer to your Linux question:
Results 1 to 6 of 6
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    how the make a script for an incomplete command


    I would like to make a script which starts the terminal (urxvt or others) just with a part of a command, let's say "which" . Then I would manually add the object a execute the command. Can anyone help me?

  2. #2
    Linux User peteh's Avatar
    Join Date
    Oct 2006
    Location
    UK
    Posts
    432
    Look up your bash manual (google "bash scripts", if necessary) and check command line parameters.
    I think this is what your're looking for.

  3. #3
    Linux Guru
    Join Date
    Dec 2013
    Posts
    2,747
    Quote Originally Posted by tiedzig View Post
    I would like to make a script which starts the terminal (urxvt or others) just with a part of a command, let's say "which" . Then I would manually add the object a execute the command. Can anyone help me?
    why not do it in the terminal straightaway? there you have tab completion and whatnot.

    if it really has to be exactly as you stated, you're going to have to write a script around 'which' - seems pretty superfluous to me.

  4. $spacer_open
    $spacer_close
  5. #4
    @nihili
    of course, "which" was just meant as an example. In fact, I have a lot of tools running in terminal (like ncdu, appimagetool) on other volumes and I don't want to type the long paths in the terminal every time again. So I was thinking about short scripts or keybinding. I'll appreciate the simplest solution.

  6. #5
    Linux Guru
    Join Date
    Dec 2013
    Posts
    2,747
    i don't think there's a "simple" solution because you don't specify.
    do you want one script for all these commands together, or one script for each specific action?
    do you want command line options and arguments to be included ("hardcoded") in the script?
    why do you need to "type the long paths"? isn't "which" in your $PATH?

    i still don't see how tab completion and aliases aren't a better solution.

  7. #6
    Linux Newbie sarlacii's Avatar
    Join Date
    May 2005
    Location
    South Africa
    Posts
    223
    -->
    Quote Originally Posted by tiedzig View Post
    I would like to make a script which starts the terminal (urxvt or others) just with a part of a command, let's say "which" . Then I would manually add the object a execute the command. Can anyone help me?
    How about loading a script that printed the incomplete command as text, and then asked for user input, but without a prompt. That way it looks like you are completing the command. Grab the input and add it to the command then execute.

    Re. long paths, look at creating a soft link, else check out the pushd/popd collection of commands to send directories to a stack for quick recall.

    Go well.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •