Jump to content


Alias in Arch ?


  • Please log in to reply
16 replies to this topic

#1 OFFLINE   abarbarian

abarbarian

    Discussion Deity

  • Forum MVP
  • 3,643 posts

Posted 08 March 2012 - 10:18 AM

Hi I had a read at Arch Alias wiki and made a few alias's and placed them in ~/.bashrc.

These work just fine

QUOTE
alias yup="yaourt -Syua"
alias s5="scrot -d 5 ~/Mirages/screenshots/%Y-%m-%d-%T-screenshot.jpg"
alias s10="scrot -d 10 ~/Mirages/screenshots/%Y-%m-%d-%T-screenshot.jpg"


These do not work and I guess it is because they are complicated commands and I have missed something out.The commands do work if used in xterm but not when I try to make them an alias.

QUOTE
alias pcr100="mogrify -path PCR100 -thumbnail 100x100!" *.png
alias scots128="mogrify -path Scots128 -thumbnail 128x128!" *.png


cool.gif

Edited by abarbarian, 08 March 2012 - 10:22 AM.

Install ARCH
You'll never need to install it again
"I did and I'm really happy"

Posted Image~~~~~~~~~~~~~Posted Image

#2 OFFLINE   securitybreach

securitybreach

    CLI Phreak

  • Forum Admins
  • 15,661 posts

Posted 08 March 2012 - 10:25 AM

You forgot the closing quotes on your last two alias'. The closing quotes need to be at the end of the commands and not in the middle of them.
Posted ImagePosted Image Posted Image
CNI Radio/Archlinux G+/Configs/PGP Key π

"Do you begin to see, then, what kind of world we are creating? It is the exact opposite of the stupid hedonistic Utopias that the old reformers imagined. A world of fear and treachery and torment, a world of trampling and being trampled upon, a world which will grow not less but more merciless as it refines itself. Progress in our world will be progress toward more pain." -George Orwell, 1984

#3 OFFLINE   securitybreach

securitybreach

    CLI Phreak

  • Forum Admins
  • 15,661 posts

Posted 08 March 2012 - 10:28 AM

You should make these changes:
QUOTE
alias pcr100="mogrify -path PCR100 -thumbnail 100x100!" *.png
alias scots128="mogrify -path Scots128 -thumbnail 128x128!" *.png


to
QUOTE
alias pcr100="mogrify -path PCR100 -thumbnail 100x100! *.png"
alias scots128="mogrify -path Scots128 -thumbnail 128x128! *.png"

Posted ImagePosted Image Posted Image
CNI Radio/Archlinux G+/Configs/PGP Key π

"Do you begin to see, then, what kind of world we are creating? It is the exact opposite of the stupid hedonistic Utopias that the old reformers imagined. A world of fear and treachery and torment, a world of trampling and being trampled upon, a world which will grow not less but more merciless as it refines itself. Progress in our world will be progress toward more pain." -George Orwell, 1984

#4 OFFLINE   abarbarian

abarbarian

    Discussion Deity

  • Forum MVP
  • 3,643 posts

Posted 08 March 2012 - 11:16 AM

Thanks  blushing.gif I could have sworn I tried that variation.

This works for me and puts the screenshot into "~/Mirages/capture" from exterm(eg.2012-03-08_572x624.png)

QUOTE
scrot -s '%Y-%m-%d_$wx$h.png' -e 'mv $f ~/Mirages/capture/'


If I use "sc" in exterm this alias I have made puts a picture in "~/" (eg.2012-03-08_.png)

QUOTE
alias sc="scrot -s '%Y-%m-%d_$wx$h.png' -e 'mv $f ~/Mirages/capture/'"


and tells me this

QUOTE
mv: missing destination file operand after `/home/bloodaxe/Mirages/capture/'
Try `mv --help' for more information.


blushing.gif I guess I have missed or put something in the wrong place again
Install ARCH
You'll never need to install it again
"I did and I'm really happy"

Posted Image~~~~~~~~~~~~~Posted Image

#5 OFFLINE   V.T. Eric Layton

V.T. Eric Layton

    Nocturnal Slacker

  • Forum MVP
  • 18,747 posts

Posted 08 March 2012 - 11:35 AM

Google doesn't want you to use aliases. You MUST use the real command names when using Google. wink.gif

Posted ImagePosted ImagePosted ImagePosted ImagePosted Image


#6 OFFLINE   securitybreach

securitybreach

    CLI Phreak

  • Forum Admins
  • 15,661 posts

Posted 08 March 2012 - 11:45 AM

This may be because the $f variable is not working since you would normally get the mv error if you forget the destination folder in the command
EX: mv source /destination

Try changing:
QUOTE
alias sc="scrot -s '%Y-%m-%d_$wx$h.png' -e 'mv $f ~/Mirages/capture/'"


to:
QUOTE
alias sc="scrot -s '%Y-%m-%d_$wx$h.png' -e 'mv *.png ~/Mirages/capture/'"

Posted ImagePosted Image Posted Image
CNI Radio/Archlinux G+/Configs/PGP Key π

"Do you begin to see, then, what kind of world we are creating? It is the exact opposite of the stupid hedonistic Utopias that the old reformers imagined. A world of fear and treachery and torment, a world of trampling and being trampled upon, a world which will grow not less but more merciless as it refines itself. Progress in our world will be progress toward more pain." -George Orwell, 1984

#7 OFFLINE   abarbarian

abarbarian

    Discussion Deity

  • Forum MVP
  • 3,643 posts

Posted 08 March 2012 - 11:54 AM

QUOTE
alias sc="scrot -s '%Y-%m-%d_$wx$h.png' -e 'mv *.png ~/Mirages/capture/'"

alias sc="scrot -s '%Y-%m-%d_$wx$h.png' -e 'mv ~/*.png ~/Mirages/capture/'"


Nope my variation did not either.

Could it be to do with('") the single and double quote marcks at the end?

The $f works with scrot so I can not see why it is different as an alias  blushing.gif
Install ARCH
You'll never need to install it again
"I did and I'm really happy"

Posted Image~~~~~~~~~~~~~Posted Image

#8 OFFLINE   securitybreach

securitybreach

    CLI Phreak

  • Forum Admins
  • 15,661 posts

Posted 08 March 2012 - 12:06 PM

QUOTE (abarbarian @ Mar 8 2012, 09:54 AM) <{POST_SNAPBACK}>
Nope my variation did not either.

Could it be to do with('") the single and double quote marcks at the end?

The $f works with scrot so I can not see why it is different as an alias  blushing.gif

Oh wait aliases are supposed to have single quotes instead of double quotes around the command:
QUOTE
alias rb='dbus-send --system --print-reply --dest="org.freedesktop.Hal" /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Reboot'
alias ya='packer -Syu'

Posted ImagePosted Image Posted Image
CNI Radio/Archlinux G+/Configs/PGP Key π

"Do you begin to see, then, what kind of world we are creating? It is the exact opposite of the stupid hedonistic Utopias that the old reformers imagined. A world of fear and treachery and torment, a world of trampling and being trampled upon, a world which will grow not less but more merciless as it refines itself. Progress in our world will be progress toward more pain." -George Orwell, 1984

#9 OFFLINE   abarbarian

abarbarian

    Discussion Deity

  • Forum MVP
  • 3,643 posts

Posted 08 March 2012 - 05:23 PM

Single qoutes don't work either.

QUOTE
alias sc='scrot -s '%Y-%m-%d_$wx$h.png' -e 'mv $f ~/Mirages/capture/''


Xterm gives this if I try the above

CODE
bash: alias: /home/bloodaxe/Mirages/capture/: not found
[bloodaxe@longship ~]$ sc
mv: missing file operand
Try `mv --help' for more information.

.

An the Arch wiki shows double quotes,

QUOTE
# pacman aliases (if applicable, replace 'pacman' with 'yaourt'/'pacaur'/whatever)
alias pac="pacman -S"      # default action     - install one or more packages
alias pacu="pacman -Syu"   # '[u]pdate'         - upgrade all packages to their newest version
alias pacs="pacman -Ss"    # '[s]earch'         - search for a package using one or more keywords

Install ARCH
You'll never need to install it again
"I did and I'm really happy"

Posted Image~~~~~~~~~~~~~Posted Image

#10 OFFLINE   securitybreach

securitybreach

    CLI Phreak

  • Forum Admins
  • 15,661 posts

Posted 08 March 2012 - 05:30 PM

QUOTE (abarbarian @ Mar 8 2012, 03:23 PM) <{POST_SNAPBACK}>
CODE
bash: alias: /home/bloodaxe/Mirages/capture/: not found

Well there you go, the file is not located in the directory you specified. Check the folder contents again and make sure they match the filename.
Posted ImagePosted Image Posted Image
CNI Radio/Archlinux G+/Configs/PGP Key π

"Do you begin to see, then, what kind of world we are creating? It is the exact opposite of the stupid hedonistic Utopias that the old reformers imagined. A world of fear and treachery and torment, a world of trampling and being trampled upon, a world which will grow not less but more merciless as it refines itself. Progress in our world will be progress toward more pain." -George Orwell, 1984

#11 OFFLINE   abarbarian

abarbarian

    Discussion Deity

  • Forum MVP
  • 3,643 posts

Posted 08 March 2012 - 06:24 PM

QUOTE (securitybreach @ Mar 8 2012, 05:30 PM) <{POST_SNAPBACK}>
Well there you go, the file is not located in the directory you specified. Check the folder contents again and make sure they match the filename.


Thanks for the help. Seems like but it does not seem as though I am able to do as I would like. My expalnation is probably unclear.

QUOTE
This works for me and puts the screenshot into "~/Mirages/capture" from exterm (eg.2012-03-08_572x624.png)


scrot -s '%Y-%m-%d_$wx$h.png' -e 'mv $f ~/Mirages/capture/'


If I use "sc" in exterm this alias I have made puts a picture in "~/"  (eg.2012-03-08_.png)


alias sc="scrot -s '%Y-%m-%d_$wx$h.png' -e 'mv $f ~/Mirages/capture/'"


~/Mirages/capture/ is an empty directory. If I use scrot from exterm as above it puts a file into ~/Mirages/capture/ as the eg: shows.
If I make an alias "sc" and then run "sc"  a picture is put in ~/ and the file looks like the eg:

Thanks again for your time.  smile.gif
Install ARCH
You'll never need to install it again
"I did and I'm really happy"

Posted Image~~~~~~~~~~~~~Posted Image

#12 OFFLINE   securitybreach

securitybreach

    CLI Phreak

  • Forum Admins
  • 15,661 posts

Posted 09 March 2012 - 12:09 AM

I tried messing with the syntax and in the end, it seemed that bashrc reads thing in single quotes as the command whereas you needed scrot to read the single quotes. It works fine by itself but not as an alias.

Scrot always outputs unique filenames (date|number|resolution) and in png format:
EX: 2012-03-08-213720_5120x1080_scrot.png
(5120x1080 being my screen resolution)

So try this command instead:
CODE
scrot && mv 2012*.png Mirage/capture/

CODE
╔═ comhack@Cerberus 10:07 PM
╚═══ ~-> scrot && mv 2012*.png Mirage/capture/

╔═ comhack@Cerberus 10:07 PM
╚═══ ~-> ls Mirage/capture/
2012-03-08-220720_5120x1080_scrot.png


The reason I used 2012* is so that it would not move all .png files to that directory. It also works great as an alias as well:
CODE
╔═ comhack@Cerberus 10:08 PM
╚═══ ~-> cat .bashrc | grep sc
alias sc='scrot && mv 2012*.png Mirage/capture/'

╔═ comhack@Cerberus 10:09 PM
╚═══ ~-> sc

╔═ comhack@Cerberus 10:09 PM
╚═══ ~-> ls Mirage/capture/
2012-03-08-220720_5120x1080_scrot.png
2012-03-08-220902_5120x1080_scrot.png


As you can see it works beautifully. Time to remove the Mirage directory and the alias. cool.gif
Posted ImagePosted Image Posted Image
CNI Radio/Archlinux G+/Configs/PGP Key π

"Do you begin to see, then, what kind of world we are creating? It is the exact opposite of the stupid hedonistic Utopias that the old reformers imagined. A world of fear and treachery and torment, a world of trampling and being trampled upon, a world which will grow not less but more merciless as it refines itself. Progress in our world will be progress toward more pain." -George Orwell, 1984

#13 OFFLINE   abarbarian

abarbarian

    Discussion Deity

  • Forum MVP
  • 3,643 posts

Posted 09 March 2012 - 09:05 AM

Once again thanks for your time and efforts.

don't know what os you are trying this on but on my basic Arch it does not work as your example.

Trying your first command gets me

CODE
$ scrot && mv 2012*.png Mirage/capture/
mv: cannot move `2012-03-09-104208_1920x1200_scrot.png' to `Mirage/capture/': No such file or directory

[code]

This placed a file `2012-03-09-104208_1920x1200_scrot.png' in my "home" directory and then every time i tried to run the command I got

[code]$ ]$ scrot && mv 2012*.png Mirage/capture/
bash: ]$: command not found
[bloodaxe@longship ~]$ mv: cannot move `2012-03-09-104208_1920x1200_scrot.png' to `Mirage/capture/': No such file or directory
>


So I tried your suggestion as an alias and get
CODE
[bloodaxe@longship ~]$ sc
mv: cannot move `2012-03-09-105751_1920x1200_scrot.png' to `Mirage/capture/': No such file or directory
[bloodaxe@longship ~]$ sc
mv: target `Mirage/capture/' is not a directory
[bloodaxe@longship ~]$ sc


It does however put files in the "home" directory like so

QUOTE
2012-03-09-110311_1920x1200_scrot.png
2012-03-09-110319_1920x1200_scrot.png


Your code is for taking full screenshots and placing the file into a specific folder and can be used as an alias. however my opening post shows that I have already worked out how to do this.

I think that the reason a lot of the above did not work is that I have "Mirages" and not "Mirage" so my copying and pasting was no good and as it is not relevant to my problem I ain't trying it all again.

My problem is how to create an alias using the "-s" feature in scrot and place the file into a specific folder.  See post 4.

In exterm if I type in

CODE
scrot -s '%Y-%m-%d_$wx$h.png' -e 'mv $f ~/Mirages/capture/'


I get a series of files in ~/Mirages/capture/ but it is a pain to have to type in that command or copy and paste it from a file. So I am looking for a alternative.

After trying all sorts of permutations at making a alias I found that

CODE
alias sc='scrot -s && ~/Mirages/capture/.png'


Would place files in "~/"  and not overwrite them like so

QUOTE
2012-03-09-122030_255x442_scrot.png
2012-03-09-122550_179x502_scrot.png


So some of your code magic is working  biggrin.gif Mind you this does the same

QUOTE
alias sc='scrot -s && mv ~/Mirages/capture/'
alias sc='scrot -s && mv ~/Mirages/capture/*.png'
alias sc='scrot -s ~/Mirages/capture/.png'

with this message in xterm

CODE
$ sc
bash: /home/bloodaxe/Mirages/capture/%Y-%m-%d-%T.png: No such file or directory


Well I tried all sorts of permutations and kept getting similar results. Eventually I could get a file to apperar in ~/Mirages/capture/ but it would appear as " *.png" and get overwritten no matter what I did.

So finally I tried

QUOTE
alias sc='scrot -s && mv 2012*.png ~/Mirages/capture/'


An blow me down with a feather it worked.  biggrin.gif

Now if only I had spotted the missing "s" sooner and simply tried to put in "-s" I would have had a result much sooner.  hysterical.gif hysterical.gif  

Many thanks for the help worthy.gif
Install ARCH
You'll never need to install it again
"I did and I'm really happy"

Posted Image~~~~~~~~~~~~~Posted Image

#14 OFFLINE   securitybreach

securitybreach

    CLI Phreak

  • Forum Admins
  • 15,661 posts

Posted 09 March 2012 - 10:34 AM

The -s switch is for selecting the window to take a screenshot of a window, why would use that instead of just scrot? I use the -s switch if I have a specific window I want to take a screenshot of. otherwise it is just one more step to get a screenshot:
QUOTE
-s, --select     interactively choose a window or rectangle with the mouse


The -s should not be required at all to take a simple screenshot of everything on the screen.

Posted ImagePosted Image Posted Image
CNI Radio/Archlinux G+/Configs/PGP Key π

"Do you begin to see, then, what kind of world we are creating? It is the exact opposite of the stupid hedonistic Utopias that the old reformers imagined. A world of fear and treachery and torment, a world of trampling and being trampled upon, a world which will grow not less but more merciless as it refines itself. Progress in our world will be progress toward more pain." -George Orwell, 1984

#15 OFFLINE   abarbarian

abarbarian

    Discussion Deity

  • Forum MVP
  • 3,643 posts

Posted 09 March 2012 - 03:30 PM

I probably should have explained a bit better in the begining but I thought what I was after was self explanetry. I managed to set up scrot and alias's for taking full desktop screenshots with delays which can be a useful feature.
As I quite often need/want to take screenshots of part of a window or web page I wanted to set up scrot to work from an alias with the -s argument.Setting up scrot to do this is much easier than taking a full desktop/window shot and then cropping.
Idealy I would like to have an alias that allowed me to interactivley take a screenshot after a delay. This would be useful for shots that need pop up menues to appear or disapperar before the shot is taken.

Anyways your "&& mv 2012*.png" piece of code provided the solution so thanks again.  thumbsup.gif
Install ARCH
You'll never need to install it again
"I did and I'm really happy"

Posted Image~~~~~~~~~~~~~Posted Image

#16 OFFLINE   securitybreach

securitybreach

    CLI Phreak

  • Forum Admins
  • 15,661 posts

Posted 09 March 2012 - 03:41 PM

Well the delay part is simple using the -d switch:
CODE
╔═ comhack@Cerberus 01:40 PM
╚═══ ~-> scrot -cd 5
Taking shot in 5.. 4.. 3.. 2.. 1.. 0.


The -c part provides the countdown and can be used or not.
Posted ImagePosted Image Posted Image
CNI Radio/Archlinux G+/Configs/PGP Key π

"Do you begin to see, then, what kind of world we are creating? It is the exact opposite of the stupid hedonistic Utopias that the old reformers imagined. A world of fear and treachery and torment, a world of trampling and being trampled upon, a world which will grow not less but more merciless as it refines itself. Progress in our world will be progress toward more pain." -George Orwell, 1984

#17 OFFLINE   abarbarian

abarbarian

    Discussion Deity

  • Forum MVP
  • 3,643 posts

Posted 09 March 2012 - 04:20 PM

Yeah I already got the delay part sussed not woth the countdown feature though.Your bit of code there helped a lot though as I have been trying

CODE
scrot -d 5 -s && mv 2012*.png Mirage/capture/
scrot -s -d 5 && mv 2012*.png Mirage/capture/


Which did not work but

CODE
alias scd='scrot -sd 10 && mv 2012*.png ~/Mirages/capture/'


Works  bounce.gif

So finally with all the help I have

QUOTE
alias s5="scrot -d 5 ~/Mirages/screenshots/%Y-%m-%d-%T.jpg"
alias s10="scrot -d 10 ~/Mirages/screenshots/%Y-%m-%d-%T.jpg"
alias sc='scrot -s && mv 2012*.png ~/Mirages/capture/'
alias scd='scrot -sd 10 && mv 2012*.png ~/Mirages/capture/'


thumbsup.gif
Install ARCH
You'll never need to install it again
"I did and I'm really happy"

Posted Image~~~~~~~~~~~~~Posted Image




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users