mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-10 15:14:44 +00:00
Make mysql completions work with log-in (#7397)
Complete databases using credentials specified on the commandline.
This commit is contained in:
parent
3471db51c8
commit
4b74fbf1b7
3 changed files with 29 additions and 2 deletions
|
@ -1,3 +1,5 @@
|
|||
__fish_complete_mysql mysql
|
||||
|
||||
complete -c mysql -f
|
||||
|
||||
complete -c mysql -s I -s \? -l help -d 'Display a help message'
|
||||
|
@ -13,8 +15,7 @@ complete -c mysql -s c -l comments -d 'Preserve comments in statements'
|
|||
complete -c mysql -l skip-comments -d 'Discard comments in statements'
|
||||
complete -c mysql -s C -l compress -d 'Compress all information'
|
||||
complete -c mysql -l connect-timeout -x -d 'Set the number of seconds before connection timeout'
|
||||
complete -c mysql -s D -l database -x -d 'The database to use' -a '(mysqlshow 2>/dev/null | tail -n +3 | string replace -rf \'\| *(\S*) *\|\' \'$1\')'
|
||||
complete -c mysql -a '(mysqlshow 2>/dev/null | tail -n +3 | string replace -rf \'\| *(\S*) *\|\' \'$1\')'
|
||||
|
||||
complete -c mysql -s \# -l debug -d 'Write a debugging log'
|
||||
complete -c mysql -l debug-check -d 'Print some debugging information'
|
||||
complete -c mysql -s T -l debug-info -d 'Prints debugging information and memory and CPU usage'
|
||||
|
|
1
share/completions/mysqldump.fish
Normal file
1
share/completions/mysqldump.fish
Normal file
|
@ -0,0 +1 @@
|
|||
__fish_complete_mysql mysqldump
|
25
share/functions/__fish_complete_mysql.fish
Normal file
25
share/functions/__fish_complete_mysql.fish
Normal file
|
@ -0,0 +1,25 @@
|
|||
function __fish_mysql_query -a query
|
||||
argparse -i 'u/user=' 'P/port=' 'h/host=' 'p/password=?' 'S/socket=' -- (commandline -po)
|
||||
set -l mysql_cmd mysql
|
||||
for flag in u P h S
|
||||
if set -q _flag_$flag
|
||||
set -l flagvar _flag_$flag
|
||||
set -a mysql_cmd -$flag $$flagvar
|
||||
end
|
||||
end
|
||||
if [ -n "$_flag_p" ]
|
||||
set -a mysql_cmd -p$_flag_p
|
||||
end
|
||||
echo $query | $mysql_cmd 2>/dev/null
|
||||
end
|
||||
|
||||
function __fish_complete_mysql_databases
|
||||
__fish_mysql_query 'show databases'
|
||||
end
|
||||
|
||||
function __fish_complete_mysql
|
||||
set -l command $argv[1]
|
||||
|
||||
complete -c $command -s D -l database -x -d 'The database to use' -a '(__fish_complete_mysql_databases)'
|
||||
complete -c $command -a '(__fish_complete_mysql_databases)'
|
||||
end
|
Loading…
Reference in a new issue