mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-07-31 04:01:51 -07:00
prompt completion: case-sensitivity
Provide a way to perform case-insensitive file / directory completion. We're using compgen to generate completion candidates, and this is case-sensitive by default. We can control this by setting the completion-ignore-case Readline variable prior to invoking compgen. If we're running a Bash with Readline support, this works as expected. Otherwise, it has no effect -- completion candidates are still returned, but compgen generates them in a case-sensitive manner. To avoid breaking changes, the signatures and behavior of existing exported functions are unchanged: - XMonad.Layout.WorkspaceDir.changeDir - XMonad.Prompt.Directory.directoryPrompt - XMonad.Prompt.Shell.getShellCompl New variations of these functions are provided, allowing the caller to specify the desired case-sensitivity via a ComplCaseSensitivity argument: - XMonad.Layout.WorkspaceDir.changeDir' - XMonad.Prompt.Directory.directoryPrompt' - XMonad.Prompt.Shell.getShellCompl' The XMonad.Prompt.Shell exports a couple new functions: - compgenDirectories - compgenFiles We make use of this in XMonad.Prompt.Directory to avoid duplicating the compgen code.
This commit is contained in:
@@ -26,6 +26,7 @@ module XMonad.Layout.WorkspaceDir (
|
||||
-- $usage
|
||||
workspaceDir,
|
||||
changeDir,
|
||||
changeDir',
|
||||
WorkspaceDir,
|
||||
) where
|
||||
|
||||
@@ -33,8 +34,8 @@ import System.Directory ( setCurrentDirectory, getCurrentDirectory )
|
||||
import Control.Monad ( when )
|
||||
|
||||
import XMonad hiding ( focus )
|
||||
import XMonad.Prompt ( XPConfig )
|
||||
import XMonad.Prompt.Directory ( directoryPrompt )
|
||||
import XMonad.Prompt ( ComplCaseSensitivity (ComplCaseSensitive), XPConfig )
|
||||
import XMonad.Prompt.Directory ( directoryPrompt' )
|
||||
import XMonad.Layout.LayoutModifier
|
||||
import XMonad.StackSet ( tag, currentTag )
|
||||
|
||||
@@ -87,4 +88,7 @@ scd :: String -> X ()
|
||||
scd x = catchIO $ setCurrentDirectory x
|
||||
|
||||
changeDir :: XPConfig -> X ()
|
||||
changeDir c = directoryPrompt c "Set working directory: " (sendMessage . Chdir)
|
||||
changeDir = changeDir' (ComplCaseSensitive True)
|
||||
|
||||
changeDir' :: ComplCaseSensitivity -> XPConfig -> X ()
|
||||
changeDir' csn c = directoryPrompt' csn c "Set working directory: " (sendMessage . Chdir)
|
||||
|
Reference in New Issue
Block a user