Move a few more shellscript functions to their own files

darcs-hash:20060212131421-ac50b-861f8941af76cf9a1e6fb7da2ac7f33795fab272.gz
This commit is contained in:
axel
2006-02-12 23:14:21 +10:00
parent 3b03bd6a10
commit a2cd8c8a8d
11 changed files with 145 additions and 70 deletions

View File

@@ -4,76 +4,6 @@
# function is used by the default prompt command.
#
if test (uname) = Darwin
function prompt_pwd -d "Print the current working directory, shortend to fit the prompt"
if test "$PWD" != "$HOME"
printf "%s" (echo $PWD|sed -e 's|/private||' -e "s|^$HOME|~|" -e 's-/\([^/]\)\([^/]*\)-/\1-g')
echo $PWD|sed -e 's-.*/[^/]\([^/]*$\)-\1-'
else
echo '~'
end
end
else
function prompt_pwd -d "Print the current working directory, shortend to fit the prompt"
if test "$PWD" != "$HOME"
printf "%s" (echo $PWD|sed -e "s|^$HOME|~|" -e 's-/\([^/]\)\([^/]*\)-/\1-g')
echo $PWD|sed -e 's-.*/[^/]\([^/]*$\)-\1-'
else
echo '~'
end
end
end
#
# This function is bound to Alt-L, it is used to list the contents of
# the directory under the cursor
#
function __fish_list_current_token -d "List contents of token under the cursor if it is a directory, otherwise list the contents of the current directory"
set val (eval echo (commandline -t))
if test -d $val
ls $val
else
set dir (dirname $val)
if test $dir != . -a -d $dir
ls $dir
else
ls
end
end
end
function pushd -d "Push directory to stack"
# Comment to avoid set completions
set -g dirstack (command pwd) $dirstack
cd $argv[1]
end
function popd -d "Pop dir from stack"
if test $dirstack[1]
cd $dirstack[1]
else
printf (_ "%s: Directory stack is empty...") popd
return 1
end
set -e dirstack[1]
end
function dirs -d "Print directory stack"
echo -n (command pwd)" "
for i in $dirstack
echo -n $i" "
end
echo
end
function prevd-or-backward-word --key-binding
if test -z (commandline)
prevd