Macros automatically loaded up

*Looking for a way to write macros that load up with a Konsole session.

I found a good reference for the bash commands.

Thanks.
*

On 08/06/2013 05:06 PM, andy77586 wrote:
> Looking for a way to write macros that load up with a Konsole session.

when you say macro, what do you mean?
do you mean a bash script? or a service or what?

in fact, just tell us what are you wanting to accomplish…because
an automatically starting ‘macro’ is (most likely) not the answer to
your wishes…


dd
http://tinyurl.com/DD-Caveat
http://tinyurl.com/DD-Complaints

andy77586 wrote:
> -Looking for a way to write macros that load up with a Konsole session.
>
> I found a good reference for the bash commands.

You’re probably looking to put some code in your .bashrc

And if you want it to be conditional on being inside a Konsole then
you’ll need to put the code inside an if statement that tests the
terminal type.

I use Windows XP.

I am sure OpenSuse has something equivalent.

Going to a console can be accomplished by pre-loading commands in a buffer.

This saves a boatload of typing repetitive commands.

For ex.

cop2 copy $1 $2 is one macro.

From a console, typing cop2 *.txt c:\linux would copy all text files in the current directory to the linux directory.

You can have around 20 “commands” in memory for use.

Andy

I don’t know why the icon is there. I typed

''c:\"

On Wed, 07 Aug 2013 00:56:04 +0000, andy77586 wrote:

> I don’t know why the icon is there. I typed Code:
> --------------------
> ''c:"
> --------------------

Linux isn’t Windows - it doesn’t understand Windows pathnames.

What you want to do is create a shell script, it sounds like - comparable
to a batch file on Windows.

Bash shell programming is an entire language unto itself (just like
Powershell is on Windows). Have a look for the online bash shell
programming primers, that should get you started.

As I recall, there’s a good one at the Linux Documentation Project:

http://tldp.org/LDP/Bash-Beginners-Guide/html/

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

On 2013-08-07 03:34, Jim Henderson wrote:
> On Wed, 07 Aug 2013 00:56:04 +0000, andy77586 wrote:
>
>> I don’t know why the icon is there. I typed Code:
>> --------------------
>> ''c:"
>> --------------------
>
> Linux isn’t Windows - it doesn’t understand Windows pathnames.

I think he may be seeing a smiley instead, on web side :wink:

> What you want to do is create a shell script, it sounds like - comparable
> to a batch file on Windows.

Or an alias. If you type “alias” in a terminal, you see a lot of things
that when typed get replaced with others - which is what he describes.

For example this one:


alias dir='ls -l'

makes that typing “dir” produces a directory listing, when “dir” is not
a linux command.

It can be understood as terminal macros :slight_smile:


Cheers / Saludos,

Carlos E. R.
(from 11.4, with Evergreen, x86_64 “Celadon” (Minas Tirith))

On Wed, 07 Aug 2013 02:14:36 +0000, Carlos E. R. wrote:

> On 2013-08-07 03:34, Jim Henderson wrote:
>> On Wed, 07 Aug 2013 00:56:04 +0000, andy77586 wrote:
>>
>>> I don’t know why the icon is there. I typed Code:
>>> --------------------
>>> ''c:"
>>> --------------------
>>
>> Linux isn’t Windows - it doesn’t understand Windows pathnames.
>
> I think he may be seeing a smiley instead, on web side :wink:

Yeah, I see that - but more importantly, though, as a DOS pathname, Linux
wouldn’t understand it regardless.

>> What you want to do is create a shell script, it sounds like -
>> comparable to a batch file on Windows.
>
> Or an alias. If you type “alias” in a terminal, you see a lot of things
> that when typed get replaced with others - which is what he describes.
>
> For example this one:
>
>


> alias dir='ls -l'
> 

>
> makes that typing “dir” produces a directory listing, when “dir” is not
> a linux command.
>
> It can be understood as terminal macros :slight_smile:

Certainly, that’s an option as well, but a depending on what he
specifically wants to do, a script may be more appropriate. We need more
info.

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

On 08/07/2013 02:56 AM, andy77586 wrote:

> I use Windows XP.

the problem is that i’ve not used windows in so long i don’t know
what a person means when they say they want a ‘macro’

> I am sure OpenSuse has something equivalent.
>
> Going to a console can be accomplished by pre-loading commands in a
> buffer.
>
> This saves a boatload of typing repetitive commands.

so, what you describe sounds like a alias to me also…

but, you can also so just press and release the up arrow and bash
will step back in time through all the commands you have put in
before…when you get to the one you want just press Enter…

but, if you come to one which is only close to what you want to
use, then you can edit what you see, _then push the Enter…

ok, i said it will step back though ‘all’ which not actually correct
because it does have a max it holds in its memory…the default is a
LOT more than 20, and you can set it to ‘remember’ what ever you want…

AND, at the bash prompt press Ctrl+r and bash goes into it search
backwards more, so type in something you remember in the command you
want to use again, and bingo it will pop up, then press enter…or
edit and then press enter…


dd

On 2013-08-07 06:31, Jim Henderson wrote:
> On Wed, 07 Aug 2013 02:14:36 +0000, Carlos E. R. wrote:

>> I think he may be seeing a smiley instead, on web side :wink:
>
> Yeah, I see that - but more importantly, though, as a DOS pathname, Linux
> wouldn’t understand it regardless.

Oh, absolutely, but he was giving an example of what he does in Windows.
He says that there he can define a macro as:


cop2 copy $1 $2

(name expansion) so that when he types:


cop2 *.txt c:\linux

it would be expanded to:


copy *.txt c:\linux

And in the second post he was wondering that he saw an icon instead of
what he typed - because he did not use code tags - I guess, because I’m
on nntp and off the network.

(alias)

>> It can be understood as terminal macros :slight_smile:
>
> Certainly, that’s an option as well, but a depending on what he
> specifically wants to do, a script may be more appropriate. We need more
> info.

See above :slight_smile:

However… I’m not familiar with those Window macros. I don’t know if
they are interpreted by the shell, or by the terminal emulator. In
linux, both aliases and scripts are interpreted by the shell, terminals
are transparent.


Cheers / Saludos,

Carlos E. R.
(from 11.4, with Evergreen, x86_64 “Celadon” (Minas Tirith))

Carlos E. R. wrote:
> terminals are transparent.

Not quite. The different types respond differently to different escape
codes, so sometimes it is important to know the terminal type.

On 2013-08-07 13:04, Dave Howorth wrote:
> Carlos E. R. wrote:
>> terminals are transparent.
>
> Not quite. The different types respond differently to different escape
> codes, so sometimes it is important to know the terminal type.

Oh, right, but they don’t interpret commands or macros :slight_smile:


Cheers / Saludos,

Carlos E. R.
(from 11.4, with Evergreen, x86_64 “Celadon” (Minas Tirith))

Carlos E. R. wrote:
> On 2013-08-07 13:04, Dave Howorth wrote:
>> Carlos E. R. wrote:
>>> terminals are transparent.
>> Not quite. The different types respond differently to different escape
>> codes, so sometimes it is important to know the terminal type.
>
> Oh, right, but they don’t interpret commands or macros :slight_smile:

Well, since the point of some macros is to change the prompt, yes they do!

On 2013-08-07 13:44, Dave Howorth wrote:
> Carlos E. R. wrote:
>> On 2013-08-07 13:04, Dave Howorth wrote:
>>> Carlos E. R. wrote:
>>>> terminals are transparent.
>>> Not quite. The different types respond differently to different escape
>>> codes, so sometimes it is important to know the terminal type.
>>
>> Oh, right, but they don’t interpret commands or macros :slight_smile:
>
> Well, since the point of some macros is to change the prompt, yes they do!

Oh?


Cheers / Saludos,

Carlos E. R.
(from 11.4, with Evergreen, x86_64 “Celadon” (Minas Tirith))

Great, you are the first one to understand. :wink:

mac·ro [mak-roh] Show IPA adjective, noun, plural mac·ros.
adjective 1. very large in scale, scope, or capability.

  1. Also called macroinstruction. Computers. an instruction that represents a sequence of instructions in abbreviated form.

dd wrote:

> so, what you describe sounds like a alias to me also…
>
> but, you can also so just press and release the up arrow and bash
> will step back in time through all the commands you have put in
> before…when you get to the one you want just press Enter…
>
> but, if you come to one which is only close to what you want to
> use, then you can edit what you see, _then push the Enter…
>
> ok, i said it will step back though ‘all’ which not actually correct
> because it does have a max it holds in its memory…the default is a
> LOT more than 20, and you can set it to ‘remember’ what ever you want…
>
> AND, at the bash prompt press Ctrl+r and bash goes into it search
> backwards more, so type in something you remember in the command you
> want to use again, and bingo it will pop up, then press enter…or
> edit and then press enter…
>

Don’t forget my favourite - alt+Page Up
Type the begining of a command you remember the Alt+Page Up and the last
time you used the command with its full path will appear.
e.g.

ent (Alt+Page Up) gives


graham@linux:~> encfs /datab5/.asd /datab5/asd

appears (for me)

On 2013-08-08 04:26, andy77586 wrote:

> Great, you are the first one to understand. :wink:
>
> mac·ro [mak-roh] Show IPA adjective, noun, plural mac·ros.
> adjective 1. very large in scale, scope, or capability.

Then see “man alias” :slight_smile:


Cheers / Saludos,

Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)

Carlos E. R. wrote:
> On 2013-08-08 04:26, andy77586 wrote:
>
>> Great, you are the first one to understand. :wink:
>>
>> mac·ro [mak-roh] Show IPA adjective, noun, plural mac·ros.
>> adjective 1. very large in scale, scope, or capability.
>
> Then see “man alias” :slight_smile:

Which refers you to man bash, which says:

For almost every purpose, aliases are superseded by shell functions.

On 08/08/2013 11:59 AM, Dave Howorth wrote:
>> Then see “man alias” :slight_smile:
>
> Which refers you to man bash, which says:
>
> For almost every purpose, aliases are superseded by shell functions.

then this might be useful:

http://tinyurl.com/mvstj9u


dd
http://tinyurl.com/DD-Caveat
http://tinyurl.com/DD-Complaints

On 2013-08-08 11:59, Dave Howorth wrote:
> Carlos E. R. wrote:
>> On 2013-08-08 04:26, andy77586 wrote:
>>
>>> Great, you are the first one to understand. :wink:
>>>
>>> mac·ro [mak-roh] Show IPA adjective, noun, plural mac·ros.
>>> adjective 1. very large in scale, scope, or capability.
>>
>> Then see “man alias” :slight_smile:
>
> Which refers you to man bash, which says:

Not in my system.

ALIAS(1P) POSIX Programmer’s Manual ALIAS(1P)

PROLOG
This manual page is part of the POSIX Programmer’s Man-
ual. The Linux implementation of this interface may
differ (consult the corresponding Linux manual page for
details of Linux behavior), or the interface may not be
implemented on Linux.

NAME
alias - define or display aliases

SYNOPSIS
alias [alias-name[=string] …]

DESCRIPTION
The alias utility shall create or redefine alias defini-
tions or write the values of existing alias definitions
to standard output. An alias definition provides a
string value that shall replace a command name when it
is encountered; see Alias Substitution .

An alias definition shall affect the current shell exe-
cution environment and the execution environments of the
subshells of the current shell. When used as specified
by this volume of IEEE Std 1003.1-2001, the alias defi-
nition shall not affect the parent process of the cur-
rent shell nor any utility environment invoked by the
shell; see Shell Execution Environment .


IEEE/The Open Group 2003 ALIAS(1P)

I fact, the word “bash” is not found in the entire page.


Cheers / Saludos,

Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)