Fedora :: Bash - Binding A Function To Control-something Key Combo - F11
Aug 20, 2009
I want to set a key binding in bash for "history-search-backward" readline command to a combination of Control+some other key (I'm using 2 as an example), but I'm unable to do so. in fact, I'm unable to alter or add bindings to Control+key combinations.
After several tries my ~/.inputrc now looks like this
But it doesn't work and bind -p | grep "-2" gives nothing. If I try something without the control key:
I can search in the history by prssing the sequence C + - + 2.
bind -p gives control in C form, for example:
I've tried different formats in my inputrc:
But nothing works.
works if I press Escape followed by 2.
Setup:
Fedora 11:
Bash version 4.0.23(1)
GNU Readline 5.2 (according to the man page)
View 2 Replies
ADVERTISEMENT
Nov 16, 2010
I wanted to make an alias with arguments (like in cshell) which is in bash done by functions. The function must simply perform a command (nedit), append the arguments from the cli and make it run in the background (adding &).
So here is the function in a naive attempt:
Code:
when using the command
Code:
Code:
How can i use arguments and still start it in background? In cshell it was like:
View 8 Replies
View Related
Feb 14, 2011
This should be a simple thing to accomplish, but I can seem to figure it out. Essentially, I want to have a bash alias or function that will let me recursively grep the current directory. A while back I added this to my .bashrc:
Code:
alias rg="grep -r --exclude=*/.svn/* --exclude=*.swp"
This works fine, (and also ignores any svn and vim swp files), and I can call it like:
Code:
rg foo *
However, 99.999% of the time, I am only interested in searching in the current directory, so the "*" is a bit redundant. Also, I would say 5-10% of the time, I am typing faster than thinking and forget the "*", so grep just sits there trying to read from stdin. It's a pretty minor thing, but ideally I'd like to be able to just type:
Code:
rg foo
I've tried creating a function to handle this:
Code:
function rg(){
grep -r --exclude=*/.svn/* --exclude=*.swp $1 *
}
but it behaves exactly the same as the alias above. escaping the "*" with 's doesn't work, and neither does trying `pwd` (or even a hard-coded path) in its place.
View 2 Replies
View Related
Jun 20, 2010
I looked on the net for such function or example and didin't find anything, thus after having made one i guess it would be legitimate to drop it to see what others thinks of it.
#!/bin/bash
addelementtoarray()
{
local arrayname=$1
[code]....
View 10 Replies
View Related
Jun 28, 2010
Im running a dual monitor setup in gnome, with the closed nvidia drivers in twinview mode. most of the times i want to be able to maximize windows to a single monitor (this is the default behavior in 10.04 lucid i believe), but sometimes i want to span a window on both screens. compiz doesn't allow windows to resized past screenborders, and gdevilspie wasn't able to get past this.
After a lot of googling and toying around i came up with the following sollution, i'm posting it here so other people can enjoy it as well (and i'll be able to find it again after my next install).
I made a script to switch between the streched mode and the doublescreen mode to use it, you'll have to stop the autodetection of the outputs in compiz. this option is found in compiz config settings manager under general settings > display settings or though the gconf-editor in /apps/compiz/general/screen0/options/detect_outputs
This script switches between the two modes, but you need to edit the resolutions of your monitors! (i have a double 1280x1024 setup)
Code:
My way of using this:
1. use the script to switch to the span mode
2. start photo/video edit software
3. work
4. close the software
5. use the script to switch back
View 4 Replies
View Related
Jan 24, 2011
I don't care if this is done in the bios or a kernel module or software. Is there any way at all to do make the 'fn' key act as 'control' and the 'control' key act as 'fn' in linux running on a macbook pro?
PS. You can do this with software in OSX with the application KeyRemap4MacBook.
View 1 Replies
View Related
Apr 24, 2010
I have the following combo dvd/cdrw drive: 'MATSHITA' 'UJDA730 DVD/CDRW'
Currently, the only way I get it to work is by manually mounting it, i.e.
Code:
mount -t iso9660 /dev/scd0 /media/cdrom0
How can I get this device to auto-mount when a cd is in it? Prior to Fedora 12, I had Ubuntu and it would auto-mount successfully.
NOTE:
I've already tried adding the following to fstab file:
Code:
/dev/scd0 /media/cdrom0 iso9660 noauto,user,exec,rw,sync 0 0
View 4 Replies
View Related
Apr 18, 2011
This is my Keyboard layout (Norwegian layout on a US keyboard on a HP Mini 1000), but I just can't find the combination to hit when I need to pipe (> <) things.
Can anyone help me find the combination so I can use my netbook for more than just simple browsing?
View 3 Replies
View Related
Mar 9, 2010
After the update on 7/03/10 edge+mouse button combo's don't work anymore, keyboard short cuts for the same function are still working. Example "Scale", keyboard short-cut ctrl-s working, edge+mouse button Right Edge - Right Mouse Button no action. Worked before...
View 6 Replies
View Related
May 2, 2011
I am trying to build a function inside a script.
Code:
#!/bin/sh
#System commands and other configurable.
IPT=/sbin/iptables
IP6T=/sbin/ip6tables
IPST=/usr/sbin/ipset
MODP=/sbin/modprobe
GET=/usr/bin/wget
INT_NET=192.168.1.0/24 .....
I can find lots of tutorials in how to use if, then, else. However, how do I define a variable inside the function?
SEE>>
Code:
for c in $ISO
Also, am I using the 'test' command correctly( -/+ week as valid test)?
View 7 Replies
View Related
Jun 19, 2010
If you set or export an environment variable in bash, you can unset it. If you set an alias in bash, you can unalias it. But there doesn't seem to be an unfunction.
Consider this (trivial) bash function, for example, set in a .bash_aliases file and read at shell initialization.
function foo () { echo "bar" ; }
How can I clear this function definition from my current shell? (Changing the initialization files or restarting the shell doesn't count.)
View 1 Replies
View Related
Jan 23, 2011
I made a script that calls a function. However when I run the script I cannot get a value from the first parameter. Here is the function:
Code:
$cat function_library
_file_info()
{
if [ -e "$1" ]
then
[Code]....
View 6 Replies
View Related
Jun 8, 2011
I have trouble with using an alias inside aash function. I would like to ssh into multiple machines by executing:ssh machine To achieve this, I put something like the following into my ~/.bashrc:
alias machine='user@machine'
ssh()
{
[code]....
View 1 Replies
View Related
Oct 29, 2010
I have taken into count spacing of functions as a reason for not working. Can you get this function to work on your machine?
quickfind () { find . -maxdepth 2 -iname "*$1*" }
It does not print the retired output but find . -maxdepth 2 -iname "*$1*" does work. What is wrong?
quickfind () { f
ind . -maxdepth 2 -iname "*$1*" ; }
If I run this from the command line I don't get an error but no output? I am not running this inside a script but from the command line. I want to be able to run any function () from the command line. I have more functions that I can't get to work?
tt () { tree -pFCfa . | grep "$1" | less -RgIKNs -P "H >>> " }
View 1 Replies
View Related
Apr 16, 2010
I have been working on this way too long now...this *should* be simple. I must be missing something simple at this point.
Code:
function f_is_ip()
{
if [ "`echo "$1" | /bin/egrep "[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}"`" != "" ] ## Error on this line
[Code]....
When I echo $1 ## prints 192.168.1.22
View 4 Replies
View Related
Jun 15, 2011
I'm making a small script for searching and doing some operations with photos, but I'm kinda stuck on this little function:
Code:
function findallformat {
prefix=""
if [ $1 = -pre ] then
[code]....
That function should find for every file with a certain type; and you can specify a prefix using a "-pre" followed by the prefix that you want to search. The format should be "stackable", so you can use as many types that you want, without repeating the same function on the code.
Example: findallformat -pre IMG_ .JPG .CR2 #That should search files that start with "IMG_" and finishes with .JPG and .CR2. My problem it's that, when I try to use it on the script, it says "bash: syntax error near `token' unexpected `}'"
View 4 Replies
View Related
Aug 8, 2010
I was wondering if possible in bash for a variable to take the value of a function, I mean the function returns a value and a variable will take it. example:
[Code]....
View 3 Replies
View Related
Feb 4, 2011
I found a weather function for bash from searching google, and started to finesse it. This is what I have so far, any tips to finesse it even more?
Code:
# Based on code by Crouse at www.bashscripts.org
weather() {
declare -a WEATHERARRAY
WEATHERARRAY=('lynx -dump "[URL]?hl=en&lr=&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&q=weather+${1}&btnG=Search" | grep -A 18 -m 1 "Current:" | sed -e 's/^[ ]*//' | cut -d '|' -f 1-5 ')
echo Weather for the zipcode of $1:$'
' ${WEATHERARRAY[@] } }
View 10 Replies
View Related
Apr 24, 2010
I just wonder the distinction calling the function between $(one_function) and one_function in bash shell script.
When I set the variable PS1 in ~/.bashrc, I can't invoke the function by one_func
ex:
export PS1="
[e[31m] $(one_func) # it works
export PS1="
[e[31m] one_func # it doesn't work
View 3 Replies
View Related
Jul 6, 2010
I have packer installed for AUR packages, but I want to be able to use the pacman command for both. I think I will need a function for this -- what I mean is that whenever I use pacman, it will try using packer and if that fails (invalid option) it will use pacman-color. It could also decide which program to use based on the arguments. I can't just use packer (alias pacman='sudo packer') because packer doesn't have some options like -R to remove packages. I want to always use it to install and upgrade packages however, because It can install from the default repositories as well as AUR.
Does someone know how to accomplish this, or could point me in the right direction? I'm new to bash scripting. error (e.g. pacman -V prints packer: Option '-V' is not valid.).
View 1 Replies
View Related
Mar 17, 2010
i am dealing with this problemI have a function
function Une {
...
return $some_variable
[code]...
View 6 Replies
View Related
Jun 28, 2011
I'm slowly coming to terms with Gnome 3 but one thing I can't get used to is using the "Windows Key".
For me it's a difficult key to use regularly. What I'd rather to is remap the "Switch between overview and desktop" action to alt-space, which I am used to from "Launchy" which I have been using in Windows for some time.
A couple of issues though - this is already mapping to "Activate the window menu". I never use it though. Are there any implications of remaping it?
Secondly, what is the command I need to map the key to, in order to emulate the Gnome 3 "Windows Key" behaviour?
View 3 Replies
View Related
Apr 9, 2010
I just started writing bash scripts and have a little question about the text editors. I now use gedit which I really like (don't like emacs for some reason), but I do miss some function for inserting/removing comment signs (in this case # for bash scripts) on a whole block of text. For example in Matlab you can simply mark a whole block and comment/uncomment all of it at once. Is this possible in gedit (via some plug-in or something?), or maybe in some other nice editor you can recommend?
View 7 Replies
View Related
Jul 15, 2010
I created a system restore file.
code:
And hav tried out:
Code has been streaming past for ages. Longer than a fresh install!
I'm wondering if i've done something to create a cycle?
How and should i interupt it? If i ctl alt F7, will it take me back to Desktop?
View 6 Replies
View Related
Feb 14, 2009
I just installed FC 10 and have apache running with the default config. the problem is that it is only listening on ipv6 for ports 80 and 443
Code:
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:587 0.0.0.0:* LISTEN 2059/exim
tcp 0 0 0.0.0.0:465 0.0.0.0:* LISTEN 2059/exim
[code]....
here is the only part in the httpd.conf file that seems to have anything to do with this:
Code:
Listen 80
which from my understanding should make it listen on all interfaces, ipv4 and ipv6
View 8 Replies
View Related
Apr 11, 2009
Can I bind 2 interent connections or more on same fedora server to create bigger one with double bandwidth ,or it needs a specific router to be able to do this.
View 1 Replies
View Related
Oct 19, 2010
I have tried a combination of the following lines in .bashrc to try and control duplicates in the bash history file:
export HISTCONTROL=ignoreboth
export HISTCONTROL=erasedups
export HISTCONTROL=ignoredups
[code]....
View 5 Replies
View Related
Sep 10, 2010
I had tried to control lynx by bash script. I can use bash script to let lynx open an url. After that, I can't do anymore. I don't understand how to move the cursor or fill some textbox in the webpage opened by linx in bash script.
View 3 Replies
View Related
Jul 25, 2010
Two processes are communicating through a pipe: A | B. A is writing data faster than B is reading it in. Is there any way to have A limit its writing rate to match B's reading rate?
AFAIK the pipe will get full, and will make A's writing block, waiting for B to read in more data. But is there a way to limit A's writing rate before the pipe fills up? (In a way it's like having a pipe with a really small capacity, but as far as I know pipe capacity is a constant compiled into the kernel.)
Code:
EXAMPLE FOR CLARIFICATION
Right now the command is printing out the following in 1-second intervals:
But with flow control it should print out (again in 1-second intervals):
...since "date" would block on the writing loop due to the slow reading loop.
View 4 Replies
View Related
Mar 18, 2011
I'm making an bash script.
As input you can input different numbers from 1 to 3.
Depending from the input a text shows up.
View 2 Replies
View Related