-
Notifications
You must be signed in to change notification settings - Fork 5
Home
This solution allows you to have access to a large number of one-liners and makes them available for use on remote systems without having to cut & paste. Dmenu is the interface, which makes it easy to manage thousands of menu items quickly, since it dynamically narrows down results based on your keystrokes. Dmenu cats the output of the one-liners into xclip, then xdotool mimics Shift-Insert to paste the output of your one-liner into the remote server without executing it, so that you can modify it before executing.
This git repo is for sharing the one-liners. Contact JasonD or MattB for write access.
apt-get install dmenu xdotool xclip git-core
Put the following in ~/bin/snippets:
#!/bin/bash rs=~/rhel-snippets exe=$( ls -B $rs | dmenu -b ) echo $exe >> $rs/.stats cat $rs/$exe | sed -e '/^\#/d' -e '/^$/d' | perl -pe 'chop if eof' | xclip xdotool key "shift+Insert"
Also see Variations on the snippets script for how to display documentation, implement keybindings, or install the script on KDE.
Make the script executable:
chmod +x ~/bin/snippets
Also make sure $HOME/bin is in your $PATH.
cd git clone git://github.com/jasondunsmore/rhel-snippets.git
Install gconf-editor if you don’t have it, then edit the keybindings under apps – metacity – keybinding_commands and apps – metacity – global keybindings. More detailed instructions
Use kmenuedit to create a new menu item and then apply a shortcut to it.
(bind-keys global-keymap "M-S-s" (lambda () (system "snippets &")))
bind d exec /home/mattb/scripts/snippets
(Please add instructions for different window managers here)
Create a github.com account and contact Jason for write access.
Scripts should be named with the most general descriptor first. Descriptors should be separated by hyphens.
Multi-line scripts should end with “\” (backslash) so bash treats them as the same line. This will prevent scripts from executing automatically.
Comments should describe what the script does and give an example of the script output (when applicable).
Scripts with arguments that are buried in the middle of the line should use a bash function to move arguments to the end of the line.
For example:
function dropips () { for ip in $*; do iptables -I INPUT -s $ip -j DROP; done && iptables -L }; dropips