set -e $cmd_hist[1][(expr $num_items - $cmd_num)] ^ /dev/null
tput cuu1
return 0
set pcount (expr $pcount - 1)
end
set no_prompt_hist 'T'
return 1
end
end
##############
##############
...
@@ -262,7 +280,7 @@ function mark -d 'Create bookmark for present working directory.'
...
@@ -262,7 +280,7 @@ function mark -d 'Create bookmark for present working directory.'
set -U bookmarks $PWD $bookmarks
set -U bookmarks $PWD $bookmarks
set pwd_hist_lock true
set pwd_hist_lock true
commandline -f repaint
commandline -f repaint
end
end
end
end
function unmark -d 'Remove bookmark for present working directory.'
function unmark -d 'Remove bookmark for present working directory.'
...
@@ -270,7 +288,7 @@ function unmark -d 'Remove bookmark for present working directory.'
...
@@ -270,7 +288,7 @@ function unmark -d 'Remove bookmark for present working directory.'
set -e bookmarks[(contains -i $PWD $bookmarks)]
set -e bookmarks[(contains -i $PWD $bookmarks)]
set pwd_hist_lock true
set pwd_hist_lock true
commandline -f repaint
commandline -f repaint
end
end
end
end
function m -d 'List bookmarks, jump to directory in list with m <number>'
function m -d 'List bookmarks, jump to directory in list with m <number>'
...
@@ -279,33 +297,36 @@ function m -d 'List bookmarks, jump to directory in list with m <number>'
...
@@ -279,33 +297,36 @@ function m -d 'List bookmarks, jump to directory in list with m <number>'
set_color $fish_color_error[1]
set_color $fish_color_error[1]
echo 'Bookmark list is empty. '(set_color normal)'Enter '(set_color $fish_color_command[1])'mark '(set_color normal)'in INSERT mode or '(set_color $fish_color_command[1])'m '(set_color normal)'in NORMAL mode, if you want to add the current directory to your bookmark list.'
echo 'Bookmark list is empty. '(set_color normal)'Enter '(set_color $fish_color_command[1])'mark '(set_color normal)'in INSERT mode or '(set_color $fish_color_command[1])'m '(set_color normal)'in NORMAL mode, if you want to add the current directory to your bookmark list.'
return
return
end
end
for i in (seq $num_items)
for i in (seq $num_items)
if [ $PWD = $bookmarks[$i] ]
if [ $PWD = $bookmarks[$i] ]
set_color $budspencer_colors[10]
set_color $budspencer_colors[10]
else
else
if [ (expr \( $num_items - $i \) \% 2) -eq 0 ]
if [ (expr \( $num_items - $i \) \% 2) -eq 0 ]
set_color normal
set_color normal
else
else
set_color $budspencer_colors[4]
set_color $budspencer_colors[4]
end
end
end
echo '▶ '(expr $num_items - $i)\t$bookmarks[$i] | sed "s|$HOME|~|"
end
end
echo (expr $num_items - $i)\t$bookmarks[$i] | sed "s|$HOME|~|"
if [ $num_items -eq 1 ]
end
set last_item ''
if [ $num_items -eq 1 ]
else
set last_item ''
set last_item '-'(expr $num_items - 1)
else
end
set last_item '-'(expr $num_items - 1)
echo -en $budspencer_cursors[1]
end
set input_length (expr length (expr $num_items - 1))
@@ -317,9 +338,9 @@ function __budspencer_delete_zombi_sessions -d 'Delete zombi sessions'
...
@@ -317,9 +338,9 @@ function __budspencer_delete_zombi_sessions -d 'Delete zombi sessions'
set -l item (contains -i $i $budspencer_sessions_active_pid)
set -l item (contains -i $i $budspencer_sessions_active_pid)
set -e budspencer_sessions_active_pid[$item]
set -e budspencer_sessions_active_pid[$item]
set -e budspencer_sessions_active[$item]
set -e budspencer_sessions_active[$item]
end
end
end
end
end
end
function __budspencer_create_new_session -d 'Create a new session'
function __budspencer_create_new_session -d 'Create a new session'
set -U budspencer_session_cmd_hist_$argv[1] $$cmd_hist
set -U budspencer_session_cmd_hist_$argv[1] $$cmd_hist
...
@@ -332,20 +353,20 @@ function __budspencer_erase_session -d 'Erase current session'
...
@@ -332,20 +353,20 @@ function __budspencer_erase_session -d 'Erase current session'
set_color $fish_color_error[1]
set_color $fish_color_error[1]
echo 'Missing argument: name of session to erase'
echo 'Missing argument: name of session to erase'
return
return
end
end
if contains $argv[2] $budspencer_sessions_active
if contains $argv[2] $budspencer_sessions_active
set_color $fish_color_error[1]
set_color $fish_color_error[1]
echo "Session '$argv[2]' cannot be erased because it's currently active."
echo "Session '$argv[2]' cannot be erased because it's currently active."
return
return
end
end
if contains $argv[2] $budspencer_sessions
if contains $argv[2] $budspencer_sessions
set -e budspencer_session_cmd_hist_$argv[2]
set -e budspencer_session_cmd_hist_$argv[2]
set -e budspencer_session_dir_hist_$argv[2]
set -e budspencer_session_dir_hist_$argv[2]
set -e budspencer_sessions[(contains -i $argv[2] $budspencer_sessions)]
set -e budspencer_sessions[(contains -i $argv[2] $budspencer_sessions)]
else
else
set_color $fish_color_error[1]
set_color $fish_color_error[1]
echo "Session '$argv[2]' not found. "(set_color normal)'Enter '(set_color $fish_color_command[1])'s '(set_color normal)'to show a list of all recorded sessions.'
echo "Session '$argv[2]' not found. "(set_color normal)'Enter '(set_color $fish_color_command[1])'s '(set_color normal)'to show a list of all recorded sessions.'
end
end
end
end
function __budspencer_detach_session -d 'Detach current session'
function __budspencer_detach_session -d 'Detach current session'
...
@@ -353,35 +374,37 @@ function __budspencer_detach_session -d 'Detach current session'
...
@@ -353,35 +374,37 @@ function __budspencer_detach_session -d 'Detach current session'
set dir_hist dir_hist_nosession
set dir_hist dir_hist_nosession
if [ -z $$dir_hist ] ^ /dev/null
if [ -z $$dir_hist ] ^ /dev/null
set $dir_hist $PWD
set $dir_hist $PWD
end
end
set dir_hist_val (count $$dir_hist)
set dir_hist_val (count $$dir_hist)
set -e budspencer_sessions_active_pid[$argv] ^ /dev/null
set -e budspencer_sessions_active_pid[$argv] ^ /dev/null
set -e budspencer_sessions_active[$argv] ^ /dev/null
set -e budspencer_sessions_active[$argv] ^ /dev/null
set budspencer_session_current ''
set budspencer_session_current ''
cd $$dir_hist[1][$dir_hist_val]
cd $$dir_hist[1][$dir_hist_val]
set no_prompt_hist 'T'
end
end
function __budspencer_attach_session -d 'Attach session'
function __budspencer_attach_session -d 'Attach session'
set argv (echo -sn $argv\n | sed 's|[^[:alnum:]]|_|g')
set argv (echo -sn $argv\n | sed 's|[^[:alnum:]]|_|g')
if contains $argv[1] $budspencer_sessions_active
if contains $argv[1] $budspencer_sessions_active
wmctrl -a "✻ $argv[1]"
wmctrl -a "✻ $argv[1]"
else
else
wt "✻ $argv[1]"
wt "✻ $argv[1]"
__budspencer_detach_session $argv[-1]
__budspencer_detach_session $argv[-1]
set budspencer_sessions_active $budspencer_sessions_active $argv[1]
set budspencer_sessions_active $budspencer_sessions_active $argv[1]
set budspencer_sessions_active_pid $budspencer_sessions_active_pid %self
set budspencer_sessions_active_pid $budspencer_sessions_active_pid %self
set budspencer_session_current $argv[1]
set budspencer_session_current $argv[1]
if not contains $argv[1] $budspencer_sessions
if not contains $argv[1] $budspencer_sessions
__budspencer_create_new_session $argv[1]
__budspencer_create_new_session $argv[1]
end
end
set cmd_hist budspencer_session_cmd_hist_$argv[1]
set cmd_hist budspencer_session_cmd_hist_$argv[1]
set dir_hist budspencer_session_dir_hist_$argv[1]
set dir_hist budspencer_session_dir_hist_$argv[1]
if [ -z $$dir_hist ] ^ /dev/null
if [ -z $$dir_hist ] ^ /dev/null
set $dir_hist $PWD
set $dir_hist $PWD
end
set dir_hist_val (count $$dir_hist)
cd $$dir_hist[1][$dir_hist_val] ^ /dev/null
end
end
set dir_hist_val (count $$dir_hist)
set no_prompt_hist 'T'
cd $$dir_hist[1][$dir_hist_val] ^ /dev/null
end
end
end
function s -d 'Create, delete or attach session'
function s -d 'Create, delete or attach session'
...
@@ -401,70 +424,90 @@ function s -d 'Create, delete or attach session'
...
@@ -401,70 +424,90 @@ function s -d 'Create, delete or attach session'
set_color normal
set_color normal
echo ' to record the current session.'
echo ' to record the current session.'
return
return
end
end
for i in (seq $num_items)
for i in (seq $num_items)
if [ $budspencer_sessions[$i] = $budspencer_session_current ]
if [ $budspencer_sessions[$i] = $budspencer_session_current ]
set_color $budspencer_colors[8]
set_color $budspencer_colors[8]
else
else
if [ (expr \( $num_items - $i \) \% 2) -eq 0 ]
if [ (expr \( $num_items - $i \) \% 2) -eq 0 ]
set_color normal
set_color normal
else
else
set_color $budspencer_colors[4]
set_color $budspencer_colors[4]
end
end
end
end
if contains $budspencer_sessions[$i] $budspencer_sessions_active
if contains $budspencer_sessions[$i] $budspencer_sessions_active