DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: how do i.. with an alias?  (Read 7,398 times)

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • Coding Snacks
    • Volunteers/Staff
    • Gathering Badge
    • Participated in NANY Challenge Once
    • Linux User
how do i.. with an alias?
« on: April 27, 2007, 03:57 AM »
this should be easy for regex pros.. i have this alias here to eject removable drives and i want the semi-colon to be added automatically after the drive letter. e.g. if i type "eject e" --> "eject e:"; "eject e f" --> "eject e: f:" (minus quotes).. can someone give me a hand.. :)

Quote
RegEx Pattern: ^eject (.*)

EjectCD $$1 | "C:\Program Files\SysTools\EJECT.EXE" $$1

another type of alias that i'm looking for is to link a path with the keyword, say "games" then whenever i type "games <abc>", Farr will be searching <abc> in the path only.. something like the "cpanel" that is available right now..

jgpaiva

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: how do i.. with an alias?
« Reply #1 on: April 27, 2007, 09:21 AM »
For the first one...
Code
RegEx Pattern: ^eject (.*):?

EjectCD $$1 | "C:\Program Files\SysTools\EJECT.EXE" $$1:
(notice the ':' after '$$1')

As for the second part, see 'Keyword Modifiers' in the advanced section of the help file. ;)

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • Coding Snacks
    • Volunteers/Staff
    • Gathering Badge
    • Participated in NANY Challenge Once
    • Linux User
Re: how do i.. with an alias?
« Reply #2 on: April 27, 2007, 10:07 AM »
jgpaiva, sorry it doesn't seem to work.. see the screenshots..

Defining the alias
[attach=#]

and the result..
[attach=#]

as for the 2nd request, thanks for pointing in the correct direction.. :Thmbsup:
[attach=#]

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
Re: how do i.. with an alias?
« Reply #3 on: April 27, 2007, 10:34 AM »
actually jgpaiva's solution is basically correct -- you just need to update your alias result to SHOW YOU the : as well:

i.e. change
ejectCD $$1 | "C:\Program Files\SysTools\EJECT.EXE" $$1:

to
ejectCD $$1: | "C:\Program Files\SysTools\EJECT.EXE" $$1:


keep in mind this will not work on your example of "eject e f" since it will only add one : at the end of the f
but you could solve this by making another ejectcd alias which matches 2 drive letters and adds a : to both, but that would require a separate regular expression alias.

in this case, a better thing might be to launch a kind of batch file or script to invoke and do the replacement after the launch by this script. i urge people to use this kind of approach.

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • Coding Snacks
    • Volunteers/Staff
    • Gathering Badge
    • Participated in NANY Challenge Once
    • Linux User
Re: how do i.. with an alias?
« Reply #4 on: April 27, 2007, 10:54 AM »
keep in mind this will not work on your example of "eject e f" since it will only add one : at the end of the f
but you could solve this by making another ejectcd alias which matches 2 drive letters and adds a : to both, but that would require a separate regular expression alias.

thanks for the explanation, mouser.. so, how do i go about the alias that matches two drive letters?

jgpaiva

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: how do i.. with an alias?
« Reply #5 on: April 27, 2007, 11:12 AM »
This one should work.. ;)
Code
RegEx Pattern: ^eject (.):? (.):?

EjectCD $$1: $$2: | "C:\Program Files\SysTools\EJECT.EXE" $$1: $$2:
(the ':?' is just so that you can still optionally put the ':' there)

[edit] corrected error with the pattern [/edit]
« Last Edit: April 27, 2007, 11:15 AM by jgpaiva »

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • Coding Snacks
    • Volunteers/Staff
    • Gathering Badge
    • Participated in NANY Challenge Once
    • Linux User
Re: how do i.. with an alias?
« Reply #6 on: April 27, 2007, 11:22 AM »
thanks a lot, jgpaiva! :) now i can really work better with my removable drives :Thmbsup:

Original address: https://www.donationcoder.com/forum/index.php?topic=8272.0