-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New irssi scripts, better zsh scripts
Signed-off-by: Tomas Slusny <[email protected]>
- Loading branch information
Showing
10 changed files
with
364 additions
and
49 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,48 @@ | ||
; vim:ft=dosini | ||
|
||
[global] | ||
alignment = left | ||
allow_markup = yes | ||
bounce_freq = 0 | ||
browser = /usr/bin/firefox -new-tab | ||
dmenu = /usr/bin/dmenu -p dunst: | ||
font = Terminus 12 | ||
format = "<b>%s</b>\n%b" | ||
geometry = "0-15+40" | ||
history_length = 20 | ||
horizontal_padding = 10 | ||
idle_threshold = 120 | ||
ignore_newline = no | ||
indicate_hidden = yes | ||
line_height = 0 | ||
monitor = 0 | ||
follow = keyboard | ||
padding = 10 | ||
separator_color = frame | ||
separator_height = 1 | ||
show_age_threshold = 60 | ||
show_indicators = yes | ||
shrink = no | ||
sort = yes | ||
startup_notification = true | ||
sticky_history = yes | ||
transparency = 0 | ||
word_wrap = yes | ||
alignment = left | ||
allow_markup = yes | ||
bounce_freq = 0 | ||
browser = /usr/bin/firefox -new-tab | ||
dmenu = /usr/bin/dmenu -p dunst: | ||
font = Terminus 12 | ||
format = "<b>%s</b>\n%b" | ||
geometry = "0-15+40" | ||
history_length = 20 | ||
horizontal_padding = 10 | ||
idle_threshold = 120 | ||
ignore_newline = no | ||
indicate_hidden = yes | ||
line_height = 0 | ||
monitor = 0 | ||
follow = keyboard | ||
padding = 10 | ||
separator_color = frame | ||
separator_height = 1 | ||
show_age_threshold = 60 | ||
show_indicators = yes | ||
shrink = no | ||
sort = yes | ||
startup_notification = true | ||
sticky_history = yes | ||
transparency = 0 | ||
word_wrap = yes | ||
|
||
[frame] | ||
width = 0 | ||
width = 0 | ||
|
||
[urgency_low] | ||
background = "#002b36" | ||
foreground = "#839496" | ||
timeout = 10 | ||
background = "#002b36" | ||
foreground = "#839496" | ||
timeout = 10 | ||
|
||
[urgency_normal] | ||
background = "#073642" | ||
foreground = "#93a1a1" | ||
timeout = 20 | ||
background = "#073642" | ||
foreground = "#93a1a1" | ||
timeout = 20 | ||
|
||
[urgency_critical] | ||
background = "#268bd2" | ||
foreground = "#eee8d5" | ||
timeout = 0 | ||
background = "#268bd2" | ||
foreground = "#eee8d5" | ||
timeout = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
# Search within your typed history as you type (like ctrl-R in bash) | ||
# Usage: | ||
# * First do: /bind ^R /history_search | ||
# * Then type ctrl-R and type what you're searching for | ||
# * Optionally, you can bind something to "/history_search -forward" to go forward in the results | ||
|
||
# Copyright 2007-2009 Wouter Coekaerts <[email protected]> | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
|
||
use strict; | ||
use Irssi 20070804; | ||
use Irssi::TextUI; | ||
|
||
use vars qw($VERSION %IRSSI); | ||
$VERSION = '2.1'; | ||
%IRSSI = ( | ||
authors => 'Wouter Coekaerts', | ||
contact => '[email protected]', | ||
name => 'history_search', | ||
description => 'Search within your typed history as you type (like ctrl-R in bash)', | ||
license => 'GPLv2 or later', | ||
url => 'http://wouter.coekaerts.be/irssi/', | ||
); | ||
|
||
# is the searching enabled? | ||
my $enabled = 0; | ||
# the typed text (the query) last time a key was pressed | ||
my $prev_typed; | ||
# the position in the input of where the typed text started. | ||
# everything before it is not typed by the user but added by this script as part of the result | ||
my $prev_startpos; | ||
# the current list of matches | ||
my @matches; | ||
# at what place are we in @matches? | ||
my $current_match_index; | ||
|
||
Irssi::command_bind('history_search', sub { | ||
my ($data, $server, $item) = @_; | ||
if ($data !~ /^ *(-forward)? *$/) { | ||
Irssi::print("history_search: Unknown arguments: $data"); | ||
return; | ||
} | ||
my $forward = $1 eq '-forward'; | ||
|
||
if (! $enabled) { | ||
$enabled = 1; | ||
$prev_typed = ''; | ||
$prev_startpos = 0; | ||
@matches = (); | ||
$current_match_index = -1; | ||
} else { | ||
if ($forward) { | ||
if ($current_match_index + 1 < scalar(@matches)) { | ||
$current_match_index++; | ||
} | ||
} else { # backwards | ||
if ($current_match_index > 0) { | ||
$current_match_index--; | ||
} | ||
} | ||
} | ||
}); | ||
|
||
Irssi::signal_add_last 'gui key pressed' => sub { | ||
my ($key) = @_; | ||
|
||
if ($key == 10 || $key == 13 || $key == 27) { # enter or escape | ||
$enabled = 0; | ||
} | ||
|
||
return unless $enabled; | ||
|
||
# get the content of the input line | ||
my $prompt = Irssi::parse_special('$L'); | ||
my $pos = Irssi::gui_input_get_pos(); | ||
|
||
# stop if the cursor is before the position where the typing started (e.g. if user pressed backspace more than he typed characters) | ||
if ($pos < $prev_startpos) { | ||
$enabled = 0; | ||
return; | ||
} | ||
|
||
# get the part of the input line that the user typed (strip the part before and after which this script added) | ||
my $typed = substr($prompt, $prev_startpos, ($pos-$prev_startpos)); | ||
|
||
if ($typed ne $prev_typed) { # something changed | ||
# find matches | ||
find_matches($typed); | ||
|
||
# start searching from the end again | ||
$current_match_index = scalar(@matches) - 1; | ||
} | ||
|
||
# if nothing was found, just show what the user typed | ||
# else, show the current match | ||
my $result = ($current_match_index == -1) ? $typed : $matches[$current_match_index]; | ||
|
||
# update the input line | ||
my $startpos = index(lc($result), lc($typed)); | ||
Irssi::gui_input_set($result); | ||
Irssi::gui_input_set_pos($startpos + length($typed)); | ||
|
||
# remember for next time | ||
$prev_typed = $typed; | ||
$prev_startpos = $startpos; | ||
}; | ||
|
||
# find matches for the given user-typed text, and put it in @matches | ||
sub find_matches($) { | ||
my ($typed) = @_; | ||
if (Irssi::version() > 20090117) { | ||
$typed = lc($typed); | ||
my @history; | ||
if ($prev_typed ne '' && index($typed, lc($prev_typed)) != -1) { # previous typed plus more | ||
@history = @matches; # only search in previous results | ||
} else { | ||
@history = Irssi::active_win->get_history_lines(); | ||
} | ||
@matches = (); | ||
for my $history_line (@history) { | ||
my $startpos = index(lc($history_line), $typed); | ||
if ($startpos != -1) { | ||
push @matches, $history_line; | ||
} | ||
} | ||
} else { # older irssi version, can only get the last match | ||
@matches = (); | ||
my $last_match = Irssi::parse_special('$!' . $typed . '!'); | ||
if ($last_match ne '') { | ||
push @matches, $last_match; | ||
} | ||
} | ||
} |
Oops, something went wrong.